caboose-cms 0.9.55 → 0.9.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/block_content_controller.js +1 -1
- data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +462 -0
- data/app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js +3 -3
- data/app/assets/javascripts/caboose/model/bound_text.js +16 -0
- data/app/assets/stylesheets/caboose/admin_edit_page_content.scss +66 -0
- data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +288 -0
- data/app/assets/stylesheets/caboose/icomoon_fonts.css +5 -3
- data/app/assets/stylesheets/caboose/modal_inline.css +4 -2
- data/app/controllers/caboose/blocks_controller.rb +60 -6
- data/app/controllers/caboose/sites_controller.rb +1 -0
- data/app/models/caboose/schema.rb +1 -0
- data/app/models/caboose/site.rb +1 -0
- data/app/views/caboose/pages/_new_block_header.html.erb +32 -11
- data/app/views/caboose/pages/admin_edit_content.html.erb +29 -57
- data/app/views/caboose/posts/admin_edit_content.html.erb +24 -54
- data/app/views/caboose/sites/admin_edit.html.erb +2 -0
- data/lib/caboose/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04f25327235babdb19541cc6040f271e93952f6e
|
4
|
+
data.tar.gz: a6c72aba003c8a77cf5c2c14aa31d389027b764d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6caf6bd85e4fd0b8373e63c4a7ba378f43bf5d43d50d2cde1cb8472c305effb528ac9ffff54fe09a67f2b947a7b276d835458bef2d3f4095b616859eba0768cb
|
7
|
+
data.tar.gz: ea63c71815f3196d2067aaeaa08288f59462c74bb404045ac0c4d05f0319e8c7d103748701a642b1e15246a732363b2173ceb2600064a725dc2b3505ca180ca2
|
@@ -0,0 +1,462 @@
|
|
1
|
+
|
2
|
+
var BlockContentController = function(params) { this.init(params); };
|
3
|
+
|
4
|
+
BlockContentController.prototype = {
|
5
|
+
|
6
|
+
post_id: false,
|
7
|
+
page_id: false,
|
8
|
+
new_block_type_id: false,
|
9
|
+
selected_block_ids: [],
|
10
|
+
blocks: false,
|
11
|
+
assets_path: false,
|
12
|
+
included_assets: false,
|
13
|
+
mc: false,
|
14
|
+
|
15
|
+
init: function(params)
|
16
|
+
{
|
17
|
+
var that = this;
|
18
|
+
for (var i in params)
|
19
|
+
that[i] = params[i];
|
20
|
+
that.refresh_blocks(function() {
|
21
|
+
that.set_clickable();
|
22
|
+
});
|
23
|
+
that.mc = new ModalController({ parent_controller: this, assets_path: that.assets_path });
|
24
|
+
},
|
25
|
+
|
26
|
+
refresh_blocks: function(callback)
|
27
|
+
{
|
28
|
+
var that = this;
|
29
|
+
$.ajax({
|
30
|
+
url: that.base_url() + '/tree',
|
31
|
+
type: 'get',
|
32
|
+
success: function(resp) {
|
33
|
+
that.blocks = resp;
|
34
|
+
if (callback) callback();
|
35
|
+
}
|
36
|
+
});
|
37
|
+
},
|
38
|
+
|
39
|
+
edit_block: function(block_id)
|
40
|
+
{
|
41
|
+
var that = this;
|
42
|
+
var b = that.block_with_id(block_id);
|
43
|
+
var bt = b.block_type;
|
44
|
+
var ft = bt.field_type; // == 'image' || bt.field_type == 'file' ? 'media' : bt.field_type;
|
45
|
+
|
46
|
+
var modal_controller = '';
|
47
|
+
if (bt.use_js_for_modal == true) { modal_controller = b.name ? b.name : bt.name; }
|
48
|
+
else if (ft == 'image') { modal_controller = 'media'; }
|
49
|
+
else if (ft == 'file') { modal_controller = 'media'; }
|
50
|
+
else if (ft == 'richtext') { modal_controller = 'richtext'; }
|
51
|
+
else { modal_controller = 'block'; }
|
52
|
+
|
53
|
+
var new_modal_eval_string = "new " + that.underscores_to_camelcase(modal_controller) + "ModalController({ " +
|
54
|
+
" " + (that.page_id && that.page_id != null ? "page_id: " + that.page_id : "post_id: " + that.post_id) + ", " +
|
55
|
+
" block_id: " + block_id + ", " +
|
56
|
+
" authenticity_token: '" + that.authenticity_token + "', " +
|
57
|
+
" parent_controller: that, " +
|
58
|
+
" assets_path: '" + that.assets_path + "'" +
|
59
|
+
"})";
|
60
|
+
|
61
|
+
var js_file = 'caboose/block_modal_controllers/' + modal_controller + '_modal_controller.js';
|
62
|
+
if (!that.mc.asset_included(js_file))
|
63
|
+
{
|
64
|
+
// Include the file before instantiating the controller
|
65
|
+
$(document).on(modal_controller + '_modal_controller_loaded', function() { that.modal = eval(new_modal_eval_string); });
|
66
|
+
that.mc.include_assets(js_file);
|
67
|
+
}
|
68
|
+
else // We're good, go ahead and instantiate
|
69
|
+
{
|
70
|
+
that.modal = eval(new_modal_eval_string);
|
71
|
+
}
|
72
|
+
},
|
73
|
+
|
74
|
+
underscores_to_camelcase: function(str)
|
75
|
+
{
|
76
|
+
var str2 = '';
|
77
|
+
$.each(str.split('_'), function(j, word) { str2 += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
|
78
|
+
return str2;
|
79
|
+
},
|
80
|
+
|
81
|
+
new_block: function(parent_id, before_block_id, after_block_id)
|
82
|
+
{
|
83
|
+
var that = this;
|
84
|
+
var options = {
|
85
|
+
block_id: parent_id,
|
86
|
+
authenticity_token: that.authenticity_token,
|
87
|
+
parent_controller: this,
|
88
|
+
assets_path: that.assets_path,
|
89
|
+
new_block_on_init: true,
|
90
|
+
before_id: before_block_id,
|
91
|
+
after_id: after_block_id
|
92
|
+
}
|
93
|
+
if (that.page_id && that.page_id != null) options['page_id'] = that.page_id;
|
94
|
+
else options['post_id'] = that.post_id;
|
95
|
+
that.modal = new BlockModalController(options)
|
96
|
+
},
|
97
|
+
|
98
|
+
block_url: function(parent_id, b)
|
99
|
+
{
|
100
|
+
var that = this;
|
101
|
+
if (!b) return that.base_url() + '/' + parent_id;
|
102
|
+
return that.base_url(b) + '/' + b.id;
|
103
|
+
},
|
104
|
+
|
105
|
+
create_block: function(block_type_id, parent_id, before_block_id, after_block_id, child_block_count) {
|
106
|
+
var that = this;
|
107
|
+
that.is_loading(true, 'Creating block...');
|
108
|
+
var h = {
|
109
|
+
authenticity_token: that.authenticity_token,
|
110
|
+
block_type_id: block_type_id,
|
111
|
+
before_id: before_block_id,
|
112
|
+
after_id: after_block_id,
|
113
|
+
child_count: child_block_count
|
114
|
+
};
|
115
|
+
$.ajax({
|
116
|
+
url: that.block_url(parent_id, null),
|
117
|
+
type: 'post',
|
118
|
+
data: h,
|
119
|
+
success: function(resp) {
|
120
|
+
if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
|
121
|
+
if (resp.success)
|
122
|
+
{
|
123
|
+
that.refresh_blocks(function() {
|
124
|
+
// that.edit_block(resp.new_id);
|
125
|
+
that.render_blocks();
|
126
|
+
});
|
127
|
+
}
|
128
|
+
}
|
129
|
+
});
|
130
|
+
},
|
131
|
+
|
132
|
+
is_loading: function(loading, message = 'Loading...') {
|
133
|
+
var that = this;
|
134
|
+
if ( loading == true )
|
135
|
+
$("#caboose-loading").fadeIn().find('h4').text(message);
|
136
|
+
else
|
137
|
+
$("#caboose-loading").fadeOut();
|
138
|
+
},
|
139
|
+
|
140
|
+
|
141
|
+
move_block: function(block_id, parent_id, before_block_id, after_block_id) {
|
142
|
+
var that = this;
|
143
|
+
that.is_loading(true, 'Moving block...');
|
144
|
+
var block_id = block_id.replace('block_','');
|
145
|
+
var h = {
|
146
|
+
authenticity_token: that.authenticity_token,
|
147
|
+
parent_id: parent_id,
|
148
|
+
before_id: before_block_id,
|
149
|
+
after_id: after_block_id
|
150
|
+
};
|
151
|
+
// console.dir(h);
|
152
|
+
$.ajax({
|
153
|
+
url: that.base_url() + '/' + block_id + '/move',
|
154
|
+
type: 'post',
|
155
|
+
data: h,
|
156
|
+
success: function(resp) {
|
157
|
+
if (resp.success)
|
158
|
+
{
|
159
|
+
that.refresh_blocks(function() {
|
160
|
+
that.render_blocks();
|
161
|
+
});
|
162
|
+
}
|
163
|
+
}
|
164
|
+
});
|
165
|
+
},
|
166
|
+
|
167
|
+
select_block: function(block_id)
|
168
|
+
{
|
169
|
+
i = this.selected_block_ids.indexOf(block_id);
|
170
|
+
if (i == -1) // Not there
|
171
|
+
{
|
172
|
+
this.selected_block_ids.push(block_id);
|
173
|
+
$('#block_' + block_id).addClass('selected');
|
174
|
+
}
|
175
|
+
else
|
176
|
+
{
|
177
|
+
this.selected_block_ids.splice(i, 1);
|
178
|
+
$('#block_' + block_id).removeClass('selected');
|
179
|
+
}
|
180
|
+
},
|
181
|
+
|
182
|
+
delete_block: function(block_id, confirm)
|
183
|
+
{
|
184
|
+
var that = this;
|
185
|
+
if (!confirm)
|
186
|
+
{
|
187
|
+
if (this.selected_block_ids.indexOf(block_id) == -1)
|
188
|
+
this.selected_block_ids.push(block_id);
|
189
|
+
var other_count = this.selected_block_ids.length - 1;
|
190
|
+
|
191
|
+
var message = "Are you sure you want to delete this block";
|
192
|
+
if (other_count > 0)
|
193
|
+
message += " and the " + other_count + " other selected block" + (other_count == 1 ? '' : 's');
|
194
|
+
message += "?<br />";
|
195
|
+
|
196
|
+
var p = $('<p/>')
|
197
|
+
.addClass('caboose_note delete')
|
198
|
+
.append(message)
|
199
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function(e) { e.preventDefault(); e.stopPropagation(); that.delete_block(block_id, true); })).append(" ")
|
200
|
+
.append($('<input/>').attr('type', 'button').val('No').click(function(e) { e.preventDefault(); e.stopPropagation(); that.render_blocks(); }));
|
201
|
+
$('#block_' + block_id).attr('onclick','').unbind('click');
|
202
|
+
$('#block_' + block_id).empty().append(p);
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
else {
|
206
|
+
if ( this.selected_block_ids.length == 1 )
|
207
|
+
that.is_loading(true, 'Deleting block...');
|
208
|
+
else if (this.selected_block_ids.length > 1)
|
209
|
+
that.is_loading(true, 'Deleting blocks...');
|
210
|
+
}
|
211
|
+
for (var i in this.selected_block_ids)
|
212
|
+
{
|
213
|
+
$.ajax({
|
214
|
+
url: that.base_url() + '/' + this.selected_block_ids[i],
|
215
|
+
type: 'delete',
|
216
|
+
async: false,
|
217
|
+
success: function(resp) {}
|
218
|
+
});
|
219
|
+
}
|
220
|
+
that.render_blocks();
|
221
|
+
},
|
222
|
+
|
223
|
+
// move_block_up: function(block_id)
|
224
|
+
// {
|
225
|
+
// var that = this;
|
226
|
+
// this.loadify($('#block_' + block_id + '_move_up_handle span'));
|
227
|
+
// $.ajax({
|
228
|
+
// url: that.base_url() + '/' + block_id + '/move-up',
|
229
|
+
// type: 'put',
|
230
|
+
// success: function(resp) {
|
231
|
+
// if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
|
232
|
+
// }
|
233
|
+
// });
|
234
|
+
// },
|
235
|
+
|
236
|
+
// move_block_down: function(block_id)
|
237
|
+
// {
|
238
|
+
// var that = this;
|
239
|
+
// this.loadify($('#block_' + block_id + '_move_down_handle span'));
|
240
|
+
// $.ajax({
|
241
|
+
// url: that.base_url() + '/' + block_id + '/move-down',
|
242
|
+
// type: 'put',
|
243
|
+
// success: function(resp) {
|
244
|
+
// if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
|
245
|
+
// }
|
246
|
+
// });
|
247
|
+
// },
|
248
|
+
|
249
|
+
duplicate_block: function(block_id)
|
250
|
+
{
|
251
|
+
var that = this;
|
252
|
+
that.is_loading(true, 'Duplicating block...');
|
253
|
+
that.loadify($('#block_' + block_id + '_duplicate_handle span'));
|
254
|
+
$.ajax({
|
255
|
+
url: that.base_url() + '/' + block_id + '/duplicate',
|
256
|
+
type: 'put',
|
257
|
+
success: function(resp) {
|
258
|
+
if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
|
259
|
+
}
|
260
|
+
});
|
261
|
+
},
|
262
|
+
|
263
|
+
loadify: function(el)
|
264
|
+
{
|
265
|
+
var that = this;
|
266
|
+
if (el.hasClass('ui-icon-arrowrefresh-1-e')) el.removeClass('ui-icon-arrowrefresh-1-e').addClass('ui-icon-arrowrefresh-1-s');
|
267
|
+
else if (el.hasClass('ui-icon-arrowrefresh-1-s')) el.removeClass('ui-icon-arrowrefresh-1-s').addClass('ui-icon-arrowrefresh-1-w');
|
268
|
+
else if (el.hasClass('ui-icon-arrowrefresh-1-w')) el.removeClass('ui-icon-arrowrefresh-1-w').addClass('ui-icon-arrowrefresh-1-n');
|
269
|
+
else if (el.hasClass('ui-icon-arrowrefresh-1-n')) el.removeClass('ui-icon-arrowrefresh-1-n').addClass('ui-icon-arrowrefresh-1-e');
|
270
|
+
else el.addClass('ui-icon-arrowrefresh-1-e');
|
271
|
+
this.loadify_el = el;
|
272
|
+
this.loadify_timer = setTimeout(function() { that.loadify(el); }, 200);
|
273
|
+
},
|
274
|
+
|
275
|
+
stop_loadify: function()
|
276
|
+
{
|
277
|
+
if (this.loadify_el)
|
278
|
+
{
|
279
|
+
this.loadify_el.removeClass('ui-icon-arrowrefresh-1-e')
|
280
|
+
.removeClass('ui-icon-arrowrefresh-1-s')
|
281
|
+
.removeClass('ui-icon-arrowrefresh-1-w')
|
282
|
+
.removeClass('ui-icon-arrowrefresh-1-n');
|
283
|
+
}
|
284
|
+
if (this.loadify_timer)
|
285
|
+
clearTimeout(this.loadify_timer);
|
286
|
+
},
|
287
|
+
|
288
|
+
/*****************************************************************************
|
289
|
+
Block Rendering
|
290
|
+
*****************************************************************************/
|
291
|
+
|
292
|
+
render_blocks: function(before_render)
|
293
|
+
{
|
294
|
+
var that = this;
|
295
|
+
$('.sortable').sortable('destroy');
|
296
|
+
var that = this;
|
297
|
+
$.ajax({
|
298
|
+
url: that.base_url() + '/render-second-level',
|
299
|
+
success: function(blocks) {
|
300
|
+
if (before_render) before_render();
|
301
|
+
$(blocks).each(function(i, b) {
|
302
|
+
$('#block_' + b.id).replaceWith(b.html);
|
303
|
+
});
|
304
|
+
that.refresh_blocks(function() { that.set_clickable(); });
|
305
|
+
that.selected_block_ids = [];
|
306
|
+
}
|
307
|
+
});
|
308
|
+
},
|
309
|
+
|
310
|
+
set_clickable: function()
|
311
|
+
{
|
312
|
+
var that = this;
|
313
|
+
var count = that.blocks.length;
|
314
|
+
$(that.blocks).each(function(i,b) {
|
315
|
+
that.set_clickable_helper(b, false, false, (i == count-1));
|
316
|
+
});
|
317
|
+
that.is_loading(false);
|
318
|
+
},
|
319
|
+
|
320
|
+
set_clickable_helper: function(b, parent_id, parent_allows_child_blocks, is_last_child)
|
321
|
+
{
|
322
|
+
var that = this;
|
323
|
+
$('#block_' + b.id + ' *').attr('onclick', '').unbind('click');
|
324
|
+
$('#block_' + b.id)
|
325
|
+
.prepend($('<a/>').attr('id', 'block_' + b.id + '_drag_handle' ).addClass('drag_handle' ).append($('<span/>').addClass('ui-icon ui-icon-arrow-4' )).click(function(e) { e.preventDefault(); e.stopPropagation(); }))
|
326
|
+
.prepend($('<a/>').attr('id', 'block_' + b.id + '_select_handle' ).addClass('select_handle' ).append($('<span/>').addClass('ui-icon ui-icon-check' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.select_block(b.id); }))
|
327
|
+
.prepend($('<a/>').attr('id', 'block_' + b.id + '_duplicate_handle' ).addClass('duplicate_handle' ).append($('<span/>').addClass('ui-icon ui-icon-copy' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.duplicate_block(b.id); }))
|
328
|
+
.prepend($('<a/>').attr('id', 'block_' + b.id + '_delete_handle' ).addClass('delete_handle' ).append($('<span/>').addClass('ui-icon ui-icon-close' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.delete_block(b.id); }));
|
329
|
+
|
330
|
+
|
331
|
+
// empty post
|
332
|
+
if ( $('.post-details-wrapper').length > 0 && b.block_type.allow_child_blocks == true && ((b.name == "content" && b.children.length == 0))) { // empty content area
|
333
|
+
var text = 'post content area'
|
334
|
+
$('#block_' + b.id).find('#empty_post_content').html($('<div/>')
|
335
|
+
.addClass('new_block_link np')
|
336
|
+
.append($('<div/>').addClass('new-page line').html('<p>Empty ' + text + '. Drag blocks here.</p>').droppable({
|
337
|
+
hoverClass: "highlight",
|
338
|
+
tolerance: "pointer",
|
339
|
+
drop: function(event, ui) {
|
340
|
+
if ( ui.draggable.attr('id') && ui.draggable.attr('id').indexOf('block_') == 0 )
|
341
|
+
that.move_block(ui.draggable.attr('id'), b.id, null, null);
|
342
|
+
else
|
343
|
+
that.create_block(ui.draggable.data('btid'), b.id, null, null, ui.draggable.data('children'));
|
344
|
+
}
|
345
|
+
}))
|
346
|
+
);
|
347
|
+
}
|
348
|
+
|
349
|
+
// empty page, grid, or text area
|
350
|
+
else if (b.block_type.allow_child_blocks == true && ((b.name == "content" && b.children.length == 0) || (b.block_type.id == 3160 && b.children.length == 9 ) || (b.block_type.id == 422 && b.children.length == 6 ))) { // empty content area
|
351
|
+
var text = b.name == 'content' ? 'content area' : (b.block_type.id == 422 ? 'text area' : 'column')
|
352
|
+
$('#block_' + b.id).find('.content_body').html($('<div/>')
|
353
|
+
.addClass('new_block_link np')
|
354
|
+
.append($('<div/>').addClass('new-page line').html('<p>Empty ' + text + '. Drag blocks here.</p>').droppable({
|
355
|
+
hoverClass: "highlight",
|
356
|
+
tolerance: "pointer",
|
357
|
+
drop: function(event, ui) {
|
358
|
+
if ( ui.draggable.attr('id') && ui.draggable.attr('id').indexOf('block_') == 0 )
|
359
|
+
that.move_block(ui.draggable.attr('id'), b.id, null, null);
|
360
|
+
else
|
361
|
+
that.create_block(ui.draggable.data('btid'), b.id, null, null, ui.draggable.data('children'));
|
362
|
+
}
|
363
|
+
}))
|
364
|
+
);
|
365
|
+
}
|
366
|
+
|
367
|
+
$("#block_" + b.id).draggable( {
|
368
|
+
handle: ".drag_handle",
|
369
|
+
revert: "invalid",
|
370
|
+
scroll: false,
|
371
|
+
zIndex: 999,
|
372
|
+
start: function(event, ui) { $(".line.ui-droppable").addClass('dropzone'); },
|
373
|
+
stop: function(event, ui) { $(".line.ui-droppable").removeClass('dropzone'); }
|
374
|
+
});
|
375
|
+
|
376
|
+
if (parent_allows_child_blocks && (!b.name || b.name.length == 0) )
|
377
|
+
{
|
378
|
+
$('#block_' + b.id).before($('<div/>')
|
379
|
+
.addClass('new_block_link')
|
380
|
+
.append($('<div/>').addClass('line').droppable({
|
381
|
+
hoverClass: "highlight",
|
382
|
+
tolerance: "pointer",
|
383
|
+
drop: function(event, ui) {
|
384
|
+
if ( ui.draggable.attr('id') && ui.draggable.attr('id').indexOf('block_') == 0 )
|
385
|
+
that.move_block(ui.draggable.attr('id'), parent_id, b.id, null);
|
386
|
+
else
|
387
|
+
that.create_block(ui.draggable.data('btid'), parent_id, b.id, null, ui.draggable.data('children'));
|
388
|
+
}
|
389
|
+
}))
|
390
|
+
);
|
391
|
+
if (is_last_child && is_last_child == true)
|
392
|
+
{
|
393
|
+
$('#block_' + b.id).after($('<div/>')
|
394
|
+
.addClass('new_block_link')
|
395
|
+
.append($('<div/>').addClass('line').droppable({
|
396
|
+
hoverClass: "highlight",
|
397
|
+
tolerance: "pointer",
|
398
|
+
drop: function(event, ui) {
|
399
|
+
if ( ui.draggable.attr('id') && ui.draggable.attr('id').indexOf('block_') == 0 )
|
400
|
+
that.move_block(ui.draggable.attr('id'), parent_id, null, b.id);
|
401
|
+
else
|
402
|
+
that.create_block(ui.draggable.data('btid'), parent_id, null, b.id, ui.draggable.data('children'));
|
403
|
+
}
|
404
|
+
}))
|
405
|
+
);
|
406
|
+
}
|
407
|
+
}
|
408
|
+
$('#block_' + b.id).attr('onclick','').unbind('click');
|
409
|
+
$('#block_' + b.id).click(function(e) {
|
410
|
+
e.preventDefault();
|
411
|
+
e.stopPropagation();
|
412
|
+
that.edit_block(b.id);
|
413
|
+
});
|
414
|
+
var show_mouseover = true;
|
415
|
+
if (b.children && b.children.length > 0)
|
416
|
+
{
|
417
|
+
var count = b.children.length;
|
418
|
+
$.each(b.children, function(i, b2) {
|
419
|
+
if (b2.block_type.field_type == 'block' && b2.name != 'advanced_options' && b2.name != 'slide2' && b2.block_type.id != 3160 && b.block_type.id != 3159)
|
420
|
+
show_mouseover = false;
|
421
|
+
that.set_clickable_helper(b2, b.id, b.block_type.allow_child_blocks, i == (count-1));
|
422
|
+
});
|
423
|
+
}
|
424
|
+
if (show_mouseover)
|
425
|
+
{
|
426
|
+
$('#block_' + b.id).mouseover(function(el) { $('#block_' + b.id).addClass( 'block_over'); });
|
427
|
+
$('#block_' + b.id).mouseout(function(el) { $('#block_' + b.id).removeClass('block_over'); });
|
428
|
+
}
|
429
|
+
},
|
430
|
+
|
431
|
+
/*****************************************************************************
|
432
|
+
Helper methods
|
433
|
+
*****************************************************************************/
|
434
|
+
|
435
|
+
block_with_id: function(block_id, b)
|
436
|
+
{
|
437
|
+
var that = this;
|
438
|
+
if (b && b.id == block_id)
|
439
|
+
return b;
|
440
|
+
var the_block = false;
|
441
|
+
if ((!b && that.blocks) || (b && b.children))
|
442
|
+
{
|
443
|
+
$.each(b ? b.children : that.blocks, function(i, b2) {
|
444
|
+
the_block = that.block_with_id(block_id, b2);
|
445
|
+
if (the_block)
|
446
|
+
return false;
|
447
|
+
});
|
448
|
+
}
|
449
|
+
return the_block;
|
450
|
+
},
|
451
|
+
|
452
|
+
base_url: function()
|
453
|
+
{
|
454
|
+
var that = this;
|
455
|
+
return '/admin/' + (that.page_id && that.page_id != null ? 'pages/' + that.page_id : 'posts/' + that.post_id) + '/blocks';
|
456
|
+
}
|
457
|
+
};
|
458
|
+
|
459
|
+
function toggle_blocks()
|
460
|
+
{
|
461
|
+
$('#new_blocks_container2').slideToggle();
|
462
|
+
}
|