caboose-cms 0.8.44 → 0.8.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/admin_page_edit_content.js +14 -10
- data/app/assets/javascripts/caboose/block_modal_controllers/#Untitled-1# +3 -0
- data/app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js +255 -0
- data/app/assets/javascripts/caboose/{modal_controllers/modal_button_controller.js → block_modal_controllers/button_modal_controller.js} +1 -1
- data/app/assets/javascripts/caboose/block_modal_controllers/default_block_modal_controller.js +237 -0
- data/app/assets/javascripts/caboose/{modal_controllers/modal_media_controller.js → block_modal_controllers/media_modal_controller.js} +36 -37
- data/app/assets/javascripts/caboose/block_modal_controllers/richtext_modal_controller.js +94 -0
- data/app/assets/javascripts/caboose/modal_controller.js +129 -0
- data/app/assets/javascripts/caboose/model/bound_richtext.js +5 -0
- data/app/assets/javascripts/caboose/tinymce_init.js +15 -0
- data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +0 -9
- data/app/assets/stylesheets/caboose/icomoon_fonts.css +10 -2
- data/app/assets/stylesheets/caboose/modal_inline.css +12 -0
- data/app/controllers/caboose/blocks_controller.rb +29 -34
- data/app/views/caboose/blocks/tinymce.js.erb +1 -0
- data/app/views/caboose/pages/admin_edit_content.html.erb +7 -4
- data/lib/caboose/version.rb +1 -1
- metadata +11 -6
- data/app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js +0 -325
- data/app/assets/javascripts/caboose/modal_controllers/modal_controller.js +0 -217
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
var
|
2
|
+
var MediaModalController = DefaultBlockModalController.extend({
|
3
3
|
|
4
4
|
media_id: false,
|
5
5
|
top_cat_id: false,
|
@@ -24,6 +24,20 @@ var ModalMediaController = ModalController.extend({
|
|
24
24
|
'plupload/jquery.ui.plupload/css/jquery.ui.plupload.css'
|
25
25
|
];
|
26
26
|
},
|
27
|
+
|
28
|
+
refresh: function(callback)
|
29
|
+
{
|
30
|
+
var that = this;
|
31
|
+
that.refresh_block(function() {
|
32
|
+
that.refresh_categories(function() {
|
33
|
+
that.refresh_media(function() {
|
34
|
+
that.refresh_policy(function() {
|
35
|
+
that.print();
|
36
|
+
});
|
37
|
+
});
|
38
|
+
});
|
39
|
+
})
|
40
|
+
},
|
27
41
|
|
28
42
|
refresh_categories: function(after)
|
29
43
|
{
|
@@ -74,31 +88,12 @@ var ModalMediaController = ModalController.extend({
|
|
74
88
|
});
|
75
89
|
},
|
76
90
|
|
77
|
-
|
91
|
+
print_content: function()
|
78
92
|
{
|
79
93
|
var that = this;
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
.append($('<div/>').attr('id', 'top_controls'))
|
84
|
-
.append($('<div/>').attr('id', 'media' ))
|
85
|
-
.append($('<div/>').attr('id', 'controls')
|
86
|
-
.append($('<p/>').css('clear', 'both')
|
87
|
-
.append($('<input/>').attr('type', 'button').val('Close' ).click(function(e) { that.parent_controller.render_blocks(); that.close(); }))
|
88
|
-
)
|
89
|
-
);
|
90
|
-
that.modal(div, 800);
|
91
|
-
that.refresh(function() {
|
92
|
-
that.refresh_categories(function() {
|
93
|
-
that.refresh_media(function() {
|
94
|
-
that.refresh_policy(function() {
|
95
|
-
that.print();
|
96
|
-
});
|
97
|
-
});
|
98
|
-
});
|
99
|
-
})
|
100
|
-
return;
|
101
|
-
}
|
94
|
+
$('#modal_content').empty()
|
95
|
+
.append($('<div/>').attr('id', 'top_controls' ))
|
96
|
+
.append($('<div/>').attr('id', 'media' ));
|
102
97
|
that.print_top_controls();
|
103
98
|
that.print_media();
|
104
99
|
that.autosize();
|
@@ -214,9 +209,13 @@ var ModalMediaController = ModalController.extend({
|
|
214
209
|
.append($('<p/>').append($('<div/>').attr('id', 'media_' + media_id + '_description' )))
|
215
210
|
.append($('<h2/>').append('Image URLs'))
|
216
211
|
.append(image_urls);
|
217
|
-
$('#
|
212
|
+
$('#modal_controls').empty()
|
218
213
|
.append($('<p/>').css('clear', 'both')
|
219
|
-
.append($('<input/>').attr('type', 'button').val('< Back' ).click(function(e) {
|
214
|
+
.append($('<input/>').attr('type', 'button').val('< Back' ).click(function(e) {
|
215
|
+
that.print_top_controls();
|
216
|
+
that.print_media();
|
217
|
+
that.print_controls();
|
218
|
+
}))
|
220
219
|
.append($('<input/>').attr('type', 'button').val('Select this Image' ).click(function(e) { that.select_media(media_id) }))
|
221
220
|
.append($('<input/>').attr('type', 'button').val('Close' ).click(function(e) { that.parent_controller.render_blocks(); that.close(); }))
|
222
221
|
);
|
@@ -240,17 +239,17 @@ var ModalMediaController = ModalController.extend({
|
|
240
239
|
$('#image_urls input.url' ).css('width', '270px').css('border', '#ccc 1px solid');
|
241
240
|
$('#image_urls button').css('width', '60px');
|
242
241
|
|
243
|
-
c = new Clipboard('.clippy');
|
244
|
-
c.on('success', function(e) {
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
});
|
250
|
-
c.on('error', function(e) {
|
251
|
-
|
252
|
-
|
253
|
-
});
|
242
|
+
//c = new Clipboard('.clippy');
|
243
|
+
//c.on('success', function(e) {
|
244
|
+
// console.info('Action:', e.action);
|
245
|
+
// console.info('Text:', e.text);
|
246
|
+
// console.info('Trigger:', e.trigger);
|
247
|
+
// e.clearSelection();
|
248
|
+
//});
|
249
|
+
//c.on('error', function(e) {
|
250
|
+
// console.error('Action:', e.action);
|
251
|
+
// console.error('Trigger:', e.trigger);
|
252
|
+
//});
|
254
253
|
|
255
254
|
that.autosize();
|
256
255
|
},
|
@@ -0,0 +1,94 @@
|
|
1
|
+
|
2
|
+
var RichtextModalController = DefaultBlockModalController.extend({
|
3
|
+
|
4
|
+
tinymce_initialized: false,
|
5
|
+
modal_width: 820,
|
6
|
+
modal_height: 500,
|
7
|
+
|
8
|
+
assets_to_include: function()
|
9
|
+
{
|
10
|
+
return [
|
11
|
+
'//cdn.tinymce.com/4/tinymce.min.js'
|
12
|
+
//'//tinymce.cachefly.net/4.0/tinymce.min.js',
|
13
|
+
//'caboose/tinymce_init.js'
|
14
|
+
]
|
15
|
+
},
|
16
|
+
|
17
|
+
print_content: function()
|
18
|
+
{
|
19
|
+
var that = this;
|
20
|
+
|
21
|
+
$(document).bind('cbox_cleanup', function(){
|
22
|
+
if (tinymce.get('block_' + that.block_id + '_value'))
|
23
|
+
tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value');
|
24
|
+
});
|
25
|
+
|
26
|
+
var exists = true;
|
27
|
+
try { exists = tinymce && tinymce != null; } catch(err) { exists = false; }
|
28
|
+
if (!exists)
|
29
|
+
{
|
30
|
+
$('#modal_content').html("<p class='loading'>Loading...</p>");
|
31
|
+
setTimeout(function() { that.print_content(); }, 100)
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
that.init_tinymce();
|
35
|
+
//if (tinymce.get('block_' + that.block_id + '_value'))
|
36
|
+
// tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value');
|
37
|
+
|
38
|
+
$('#modal_content').empty().append($('<div/>').attr('id', 'block_' + that.block_id + '_value'));
|
39
|
+
$(document).ready(function() {
|
40
|
+
m = new ModelBinder({
|
41
|
+
name: 'Block',
|
42
|
+
id: that.block.id,
|
43
|
+
update_url: that.block_url(),
|
44
|
+
authenticity_token: that.authenticity_token,
|
45
|
+
attributes: [{
|
46
|
+
name: 'value',
|
47
|
+
nice_name: 'Content',
|
48
|
+
type: 'richtext',
|
49
|
+
value: that.block.value,
|
50
|
+
width: 800,
|
51
|
+
height: 300,
|
52
|
+
fixed_placeholder: false,
|
53
|
+
after_update: function() {
|
54
|
+
tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value');
|
55
|
+
that.parent_controller.render_blocks();
|
56
|
+
that.close();
|
57
|
+
},
|
58
|
+
after_cancel: function() { that.parent_controller.render_blocks(); that.close(); }
|
59
|
+
}]
|
60
|
+
});
|
61
|
+
});
|
62
|
+
that.autosize();
|
63
|
+
},
|
64
|
+
|
65
|
+
before_crumbtrail_click: function() { var that = this; tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value'); },
|
66
|
+
before_close: function() { var that = this; tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value'); },
|
67
|
+
before_print_advanced: function() { var that = this; tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'block_' + that.block_id + '_value'); },
|
68
|
+
|
69
|
+
init_tinymce: function(force)
|
70
|
+
{
|
71
|
+
var that = this;
|
72
|
+
if (force || that.parent_controller.tinymce_initialized == undefined)
|
73
|
+
{
|
74
|
+
console.log("Initializing tinymce...");
|
75
|
+
|
76
|
+
tinymce.init({
|
77
|
+
selector: 'textarea.tinymce',
|
78
|
+
width: '800px',
|
79
|
+
height: '300px',
|
80
|
+
convert_urls: false,
|
81
|
+
plugins: 'advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking table contextmenu directionality emoticons template paste textcolor caboose',
|
82
|
+
toolbar1: 'caboose_save caboose_cancel | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
83
|
+
image_advtab: true,
|
84
|
+
external_plugins: { 'caboose': '//d9hjv462jiw15.cloudfront.net/assets/tinymce/plugins/caboose/plugin.js' },
|
85
|
+
setup: function(editor) {
|
86
|
+
var control = ModelBinder.tinymce_control(editor.id);
|
87
|
+
editor.on('keyup', function(e) { control.tinymce_change(editor); });
|
88
|
+
}
|
89
|
+
});
|
90
|
+
that.parent_controller.tinymce_initialized = true;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
});
|
@@ -0,0 +1,129 @@
|
|
1
|
+
|
2
|
+
var ModalController = Class.extend({
|
3
|
+
|
4
|
+
modal_width: false,
|
5
|
+
modal_height: false,
|
6
|
+
modal_element: false,
|
7
|
+
parent_controller: false,
|
8
|
+
|
9
|
+
modal: function(el, width, height, callback)
|
10
|
+
{
|
11
|
+
var that = this;
|
12
|
+
if (!width) width = that.modal_width ? that.modal_width : 400;
|
13
|
+
if (!height) height = that.modal_height ? that.modal_height : $(el).outerHeight(true);
|
14
|
+
that.modal_element = el;
|
15
|
+
el.attr('id', 'the_modal').addClass('modal').css('width', '' + width + 'px');
|
16
|
+
$.colorbox({
|
17
|
+
html: el,
|
18
|
+
initialWidth: width,
|
19
|
+
//initialHeight: height,
|
20
|
+
innerWidth: width,
|
21
|
+
//innerHeight: height,
|
22
|
+
scrolling: false,
|
23
|
+
closeButton: false,
|
24
|
+
opacity: 0.50,
|
25
|
+
onComplete: function() {
|
26
|
+
var arr = ['TopLeft','TopCenter','TopRight','BottomLeft','BottomCenter','BottomRight','MiddleLeft','MiddleRight'];
|
27
|
+
for (var i in arr) $('#cbox' + arr[i]).css('background-color', '#fff !important');
|
28
|
+
$("#cboxClose").hide();
|
29
|
+
if (callback) callback();
|
30
|
+
}
|
31
|
+
});
|
32
|
+
},
|
33
|
+
|
34
|
+
last_size: 0,
|
35
|
+
autosize: function(msg, msg_container, flag)
|
36
|
+
{
|
37
|
+
var that = this;
|
38
|
+
if (!flag)
|
39
|
+
that.last_size = 0;
|
40
|
+
if (!that.modal_element) return;
|
41
|
+
if (msg) $('#' + (msg_container ? msg_container : 'modal_message')).html(msg);
|
42
|
+
var h = that.modal_height ? that.modal_height : $(that.modal_element).outerHeight(true) + 20;
|
43
|
+
if (h > 0 && h > that.last_size)
|
44
|
+
$.colorbox.resize({ innerHeight: '' + h + 'px' });
|
45
|
+
that.last_size = h;
|
46
|
+
|
47
|
+
if (!flag || flag < 2)
|
48
|
+
setTimeout(function() { that.autosize(false, false, flag ? flag + 1 : 1); }, 200);
|
49
|
+
},
|
50
|
+
|
51
|
+
before_close: false,
|
52
|
+
close: function()
|
53
|
+
{
|
54
|
+
var that = this;
|
55
|
+
if (that.before_close) that.before_close();
|
56
|
+
$.colorbox.close();
|
57
|
+
},
|
58
|
+
|
59
|
+
/*****************************************************************************
|
60
|
+
Asset management
|
61
|
+
*****************************************************************************/
|
62
|
+
|
63
|
+
// To be overridden in each controller
|
64
|
+
assets_to_include: function() { return []; },
|
65
|
+
|
66
|
+
// Called at the beginning of init to include modal assets,
|
67
|
+
// and can be called at anytime with more assets
|
68
|
+
include_assets: function(arr)
|
69
|
+
{
|
70
|
+
var that = this;
|
71
|
+
if (!arr) arr = that.assets_to_include();
|
72
|
+
if (!arr) return;
|
73
|
+
|
74
|
+
if (!that.parent_controller.included_assets || that.parent_controller.included_assets == undefined)
|
75
|
+
that.parent_controller.included_assets = [];
|
76
|
+
if (typeof arr == 'string') arr = [arr];
|
77
|
+
$.each(arr, function(i, url) {
|
78
|
+
if (that.parent_controller.included_assets.indexOf(url) > -1) return;
|
79
|
+
var full_url = url.match(/^http:.*?/) || url.match(/^https:.*?$/) || url.match(/^\/\/.*?$/) ? url : that.assets_path + url;
|
80
|
+
if (url.match(/\.js/))
|
81
|
+
{
|
82
|
+
var el = document.createElement('script');
|
83
|
+
el.setAttribute('type', 'text/javascript');
|
84
|
+
el.setAttribute('src', full_url);
|
85
|
+
document.getElementsByTagName('head')[0].appendChild(el)
|
86
|
+
}
|
87
|
+
else if (url.match(/\.css/))
|
88
|
+
{
|
89
|
+
var el = document.createElement('link');
|
90
|
+
el.setAttribute('rel', 'stylesheet');
|
91
|
+
el.setAttribute('type', 'text/css');
|
92
|
+
el.setAttribute('href', full_url);
|
93
|
+
document.getElementsByTagName('head')[0].appendChild(el)
|
94
|
+
}
|
95
|
+
that.parent_controller.included_assets.push(url);
|
96
|
+
});
|
97
|
+
},
|
98
|
+
|
99
|
+
include_inline_css: function(str)
|
100
|
+
{
|
101
|
+
var that = this;
|
102
|
+
|
103
|
+
if (!that.parent_controller.included_css || that.parent_controller.included_css == undefined)
|
104
|
+
that.parent_controller.included_css = [];
|
105
|
+
var h = that.hashify(str);
|
106
|
+
if (that.parent_controller.included_css.indexOf(h) > -1)
|
107
|
+
return;
|
108
|
+
|
109
|
+
var el = document.createElement('style');
|
110
|
+
el.setAttribute('type', 'text/css');
|
111
|
+
el.innerHTML = str;
|
112
|
+
document.getElementsByTagName('head')[0].appendChild(el)
|
113
|
+
|
114
|
+
that.parent_controller.included_css.push(h);
|
115
|
+
},
|
116
|
+
|
117
|
+
hashify: function(str)
|
118
|
+
{
|
119
|
+
var hash = 0, i, chr, len;
|
120
|
+
if (str.length === 0) return hash;
|
121
|
+
for (i=0, len=str.length; i<len; i++) {
|
122
|
+
chr = str.charCodeAt(i);
|
123
|
+
hash = ((hash << 5) - hash) + chr;
|
124
|
+
hash |= 0; // Convert to 32bit integer
|
125
|
+
}
|
126
|
+
return hash;
|
127
|
+
}
|
128
|
+
|
129
|
+
});
|
@@ -43,6 +43,11 @@ BoundRichText = BoundControl.extend({
|
|
43
43
|
setTimeout(function() {
|
44
44
|
//tinymce.EditorManager.execCommand("mceAddEditor", false, this2.el);
|
45
45
|
//tinymce.EditorManager.execCommand("mceAddEditor", false, this2.el);
|
46
|
+
|
47
|
+
if (tinymce.get(this2.el))
|
48
|
+
{
|
49
|
+
try { tinymce.EditorManager.execCommand('mceRemoveEditor', true, this2.el); } catch(err) {}
|
50
|
+
}
|
46
51
|
tinymce.execCommand("mceAddEditor", false, this2.el);
|
47
52
|
//var ed = tinymce.EditorManager.createEditor(this2.el);
|
48
53
|
//alert(ed);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
tinymce.init({
|
3
|
+
selector: 'textarea.tinymce',
|
4
|
+
width: '800px',
|
5
|
+
height: '300px',
|
6
|
+
convert_urls: false,
|
7
|
+
plugins: 'advlist autolink lists link image charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking table contextmenu directionality emoticons template paste textcolor caboose',
|
8
|
+
toolbar1: 'caboose_save caboose_cancel | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
9
|
+
image_advtab: true,
|
10
|
+
external_plugins: { 'caboose': '//d9hjv462jiw15.cloudfront.net/assets/tinymce/plugins/caboose/plugin.js' },
|
11
|
+
setup: function(editor) {
|
12
|
+
var control = ModelBinder.tinymce_control(editor.id);
|
13
|
+
editor.on('keyup', function(e) { control.tinymce_change(editor); });
|
14
|
+
}
|
15
|
+
});
|
@@ -155,12 +155,3 @@
|
|
155
155
|
}
|
156
156
|
}
|
157
157
|
}
|
158
|
-
|
159
|
-
#the_modal div.icons { height: 400px; overflow-y: scroll; }
|
160
|
-
#the_modal div.icons h2 { clear: both; padding: 20px 0px 10px 0; text-align: center; }
|
161
|
-
#the_modal div.icons a { display: block; float: left; margin: 4px; border: #fff 0px solid; width: 120px; height: 100px; text-align: center; vertical-align: middle; border: #666 4px solid; }
|
162
|
-
#the_modal div.icons a span.icon { display: block; padding: 10px 20px; font-size: 24pt; color: #fff; }
|
163
|
-
#the_modal div.icons a span.name { display: block; }
|
164
|
-
#the_modal div.icons a:hover { background: #fff69f; color: #000; border: #666 0px solid; border: #666 4px solid; }
|
165
|
-
#the_modal div.icons a:hover span.icon { color: #000; }
|
166
|
-
#the_modal div.icons a:hover span.name { color: #000; }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/*
|
1
2
|
@font-face {
|
2
3
|
font-family: 'icomoon';
|
3
4
|
src:url('/assets/icomoon.eot?-tne7s4');
|
@@ -8,9 +9,16 @@
|
|
8
9
|
font-weight: normal;
|
9
10
|
font-style: normal;
|
10
11
|
}
|
12
|
+
*/
|
11
13
|
|
12
|
-
[class^="icon-"],
|
13
|
-
|
14
|
+
#the_modal div.icons [class^="icon-"]:before,
|
15
|
+
#the_modal div.icons [class*=" icon-"]:before {
|
16
|
+
font-family: 'icomoon' !important;
|
17
|
+
}
|
18
|
+
|
19
|
+
#the_modal div.icons [class^="icon-"],
|
20
|
+
#the_modal div.icons [class*=" icon-"] {
|
21
|
+
font-family: 'icomoon' !important;
|
14
22
|
speak: none;
|
15
23
|
font-style: normal;
|
16
24
|
font-weight: normal;
|
@@ -1,4 +1,13 @@
|
|
1
1
|
|
2
|
+
#the_modal div.icons { max-height: 800px; overflow-y: scroll; }
|
3
|
+
#the_modal div.icons h2 { clear: both; padding: 20px 0px 10px 0; text-align: center; }
|
4
|
+
#the_modal div.icons a { display: block; float: left; margin: 4px; width: 120px; height: 100px; text-align: center; vertical-align: middle; border: #000 1px solid; text-decoration: none; border-radius: 3px; overflow: hidden; }
|
5
|
+
#the_modal div.icons a span.icon { display: block; padding: 10px 20px; font-size: 24pt; color: #000 !important; }
|
6
|
+
#the_modal div.icons a span.name { display: block; font-size: 12pt; color: #000 !important; }
|
7
|
+
#the_modal div.icons a:hover { color: #000 !important; background: #fff69f; border: #000 1px solid; }
|
8
|
+
#the_modal div.icons a:hover span.icon { color: #000 !important; }
|
9
|
+
#the_modal div.icons a:hover span.name { color: #000 !important; }
|
10
|
+
|
2
11
|
#the_modal { box-sizing: border-box; }
|
3
12
|
#the_modal p { margin-bottom: 10px; }
|
4
13
|
#the_modal .mb_container input { border: #ccc 1px solid; }
|
@@ -7,4 +16,7 @@
|
|
7
16
|
#the_modal div.mb_container select { border: #ccc 1px solid; height: 36px; }
|
8
17
|
#the_modal div.mb_container select option { font-size: 16px; }
|
9
18
|
#the_modal div.mb_container input[type=checkbox] { top: 12px; }
|
19
|
+
#the_modal #modal_crumbtrail,
|
20
|
+
#the_modal #modal_crumbtrail h2,
|
21
|
+
#the_modal #modal_crumbtrail h2 a { font-size: 16pt !important; }
|
10
22
|
|
@@ -82,18 +82,18 @@ module Caboose
|
|
82
82
|
'id' => b.id,
|
83
83
|
'parent_id' => b.parent_id,
|
84
84
|
'page_id' => b.page_id,
|
85
|
-
'post_id' => b.post_id,
|
86
|
-
'
|
87
|
-
'block_type_id' => bt.id,
|
88
|
-
'children' => admin_tree_helper(b),
|
89
|
-
'field_type' => bt.field_type,
|
90
|
-
'allow_child_blocks' => bt.allow_child_blocks,
|
91
|
-
'use_js_for_modal' => bt.use_js_for_modal,
|
92
|
-
'name' => b.name ? b.name : bt.name,
|
85
|
+
'post_id' => b.post_id,
|
86
|
+
'name' => b.name,
|
93
87
|
'value' => b.value,
|
94
88
|
'constrain' => b.constrain,
|
95
89
|
'full_width' => b.full_width,
|
90
|
+
'block_type' => bt,
|
91
|
+
'children' => admin_tree_helper(b),
|
96
92
|
'crumbtrail' => self.crumbtrail(b)
|
93
|
+
#'block_type_id' => bt.id,
|
94
|
+
#'field_type' => bt.field_type,
|
95
|
+
#'allow_child_blocks' => bt.allow_child_blocks,
|
96
|
+
#'use_js_for_modal' => bt.use_js_for_modal,
|
97
97
|
}
|
98
98
|
else
|
99
99
|
q = params[:page_id] ? ["parent_id is null and page_id = ?", params[:page_id]] : ["parent_id is null and post_id = ?", params[:post_id]]
|
@@ -103,17 +103,17 @@ module Caboose
|
|
103
103
|
'id' => b.id,
|
104
104
|
'parent_id' => b.parent_id,
|
105
105
|
'page_id' => b.page_id,
|
106
|
-
'post_id' => b.post_id,
|
107
|
-
'
|
108
|
-
'block_type_id' => bt.id,
|
109
|
-
'children' => admin_tree_helper(b),
|
110
|
-
'field_type' => bt.field_type,
|
111
|
-
'allow_child_blocks' => bt.allow_child_blocks,
|
112
|
-
'use_js_for_modal' => bt.use_js_for_modal,
|
113
|
-
'name' => b.name ? b.name : bt.name,
|
106
|
+
'post_id' => b.post_id,
|
107
|
+
'name' => b.name,
|
114
108
|
'value' => b.value,
|
115
109
|
'constrain' => b.constrain,
|
116
|
-
'full_width' => b.full_width
|
110
|
+
'full_width' => b.full_width,
|
111
|
+
'block_type' => bt,
|
112
|
+
'children' => admin_tree_helper(b)
|
113
|
+
#'block_type_id' => bt.id,
|
114
|
+
#'field_type' => bt.field_type,
|
115
|
+
#'allow_child_blocks' => bt.allow_child_blocks,
|
116
|
+
#'use_js_for_modal' => bt.use_js_for_modal,
|
117
117
|
}
|
118
118
|
end
|
119
119
|
end
|
@@ -143,16 +143,16 @@ module Caboose
|
|
143
143
|
'parent_id' => b2.parent_id,
|
144
144
|
'page_id' => b2.page_id,
|
145
145
|
'post_id' => b2.post_id,
|
146
|
-
'
|
147
|
-
'block_type_id' => bt.id,
|
148
|
-
'children' => admin_tree_helper(b2),
|
149
|
-
'field_type' => bt.field_type,
|
150
|
-
'allow_child_blocks' => bt.allow_child_blocks,
|
151
|
-
'use_js_for_modal' => bt.use_js_for_modal,
|
152
|
-
'name' => b2.name ? b2.name : bt.name,
|
146
|
+
'name' => b2.name,
|
153
147
|
'value' => b2.value,
|
154
148
|
'constrain' => b2.constrain,
|
155
|
-
'full_width' => b2.full_width
|
149
|
+
'full_width' => b2.full_width,
|
150
|
+
'block_type' => bt,
|
151
|
+
'children' => admin_tree_helper(b2)
|
152
|
+
#'block_type_id' => bt.id,
|
153
|
+
#'field_type' => bt.field_type,
|
154
|
+
#'allow_child_blocks' => bt.allow_child_blocks,
|
155
|
+
#'use_js_for_modal' => bt.use_js_for_modal,
|
156
156
|
}
|
157
157
|
end
|
158
158
|
return arr
|
@@ -306,10 +306,7 @@ module Caboose
|
|
306
306
|
def admin_create
|
307
307
|
return unless user_is_allowed('pages', 'add')
|
308
308
|
|
309
|
-
resp = Caboose::StdClass.new
|
310
|
-
'error' => nil,
|
311
|
-
'redirect' => nil
|
312
|
-
})
|
309
|
+
resp = Caboose::StdClass.new
|
313
310
|
|
314
311
|
b = Block.new
|
315
312
|
if params[:page_id]
|
@@ -369,11 +366,9 @@ module Caboose
|
|
369
366
|
|
370
367
|
# Send back the response
|
371
368
|
#resp.block = b
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
resp.redirect = "/admin/posts/#{b.post_id}/blocks/#{b.id}/edit"
|
376
|
-
end
|
369
|
+
resp.success = true
|
370
|
+
resp.new_id = b.id
|
371
|
+
resp.redirect = params[:page_id] ? "/admin/pages/#{b.page_id}/blocks/#{b.id}" : "/admin/posts/#{b.post_id}/blocks/#{b.id}"
|
377
372
|
render :json => resp
|
378
373
|
end
|
379
374
|
|