caboose-cms 0.3.129 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_block_edit.js +267 -0
- data/app/assets/javascripts/caboose/admin_page_edit_content.js +71 -45
- data/app/assets/javascripts/caboose/admin_page_edit_content_bak.js +164 -0
- data/app/assets/javascripts/caboose/admin_page_new_blocks.js +4 -4
- data/app/assets/stylesheets/caboose/admin_page_edit_content.css +37 -16
- data/app/controllers/caboose/block_types_controller.rb +162 -0
- data/app/controllers/caboose/blocks_controller.rb +293 -0
- data/app/controllers/caboose/edit_controller.rb +33 -0
- data/app/controllers/caboose/pages_controller.rb +4 -3
- data/app/controllers/caboose/posts_controller.rb +1 -1
- data/app/models/caboose/block.rb +222 -0
- data/app/models/caboose/block_type.rb +28 -0
- data/app/models/caboose/core_plugin.rb +6 -6
- data/app/models/caboose/page.rb +8 -4
- data/app/models/caboose/schema.rb +90 -59
- data/app/models/caboose/utilities/schema.rb +3 -3
- data/app/views/caboose/block_types/admin_edit.html.erb +111 -0
- data/app/views/caboose/{page_block_types → block_types}/admin_index.html.erb +2 -2
- data/app/views/caboose/{page_block_types → block_types}/admin_new.html.erb +9 -6
- data/app/views/caboose/blocks/_block.html.erb +8 -0
- data/app/views/caboose/blocks/_heading.html.erb +7 -0
- data/app/views/caboose/blocks/_html.html.erb +7 -0
- data/app/views/caboose/blocks/_image.html.erb +0 -0
- data/app/views/caboose/blocks/_layout_default.html.erb +33 -0
- data/app/views/caboose/blocks/_layout_default_content.html.erb +16 -0
- data/app/views/caboose/blocks/_layout_default_footer.html.erb +20 -0
- data/app/views/caboose/blocks/_layout_default_header.html.erb +32 -0
- data/app/views/caboose/blocks/_richtext.html.erb +7 -0
- data/app/views/caboose/{page_blocks/_richtext.html.erb → blocks/_text.html.erb} +1 -2
- data/app/views/caboose/blocks/admin_edit.html.erb +106 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_custom.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h1.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h2.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h3.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h4.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h5.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_h6.html.erb +0 -0
- data/app/views/caboose/{page_blocks → blocks}/admin_edit_richtext.html.erb +0 -0
- data/app/views/caboose/blocks/admin_new.html.erb +55 -0
- data/app/views/caboose/pages/_admin_header.html.erb +1 -1
- data/app/views/caboose/pages/_content.html.erb +1 -1
- data/app/views/caboose/pages/_new_block_header.html.erb +13 -0
- data/app/views/caboose/pages/admin_edit_content.html.erb +24 -20
- data/app/views/caboose/pages/show.html.erb +13 -30
- data/app/views/layouts/caboose/application.html.erb +26 -14
- data/config/routes.rb +38 -30
- data/lib/caboose/engine.rb +2 -2
- data/lib/caboose/version.rb +1 -1
- metadata +33 -35
- data/app/controllers/caboose/page_block_field_values_controller.rb +0 -55
- data/app/controllers/caboose/page_block_fields_controller.rb +0 -123
- data/app/controllers/caboose/page_block_types_controller.rb +0 -100
- data/app/controllers/caboose/page_blocks_controller.rb +0 -165
- data/app/models/caboose/page_block.rb +0 -49
- data/app/models/caboose/page_block_field.rb +0 -21
- data/app/models/caboose/page_block_field_value.rb +0 -39
- data/app/models/caboose/page_block_renderers/h1.rb +0 -5
- data/app/models/caboose/page_block_renderers/h2.rb +0 -5
- data/app/models/caboose/page_block_renderers/h3.rb +0 -5
- data/app/models/caboose/page_block_renderers/h4.rb +0 -5
- data/app/models/caboose/page_block_renderers/h5.rb +0 -5
- data/app/models/caboose/page_block_renderers/h6.rb +0 -5
- data/app/models/caboose/page_block_renderers/p.rb +0 -5
- data/app/models/caboose/page_block_renderers/richtext.rb +0 -5
- data/app/models/caboose/page_block_type.rb +0 -12
- data/app/views/caboose/page_block_fields/admin_edit.html.erb +0 -77
- data/app/views/caboose/page_block_fields/admin_new.html.erb +0 -30
- data/app/views/caboose/page_block_types/admin_edit.html.erb +0 -82
- data/app/views/caboose/page_blocks/_heading.html.erb +0 -7
- data/app/views/caboose/page_blocks/_partial.html.erb +0 -11
- data/app/views/caboose/page_blocks/admin_edit.html.erb +0 -69
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDYwMjExOGUxOTgxZGM1ZWI4ZDkxNTBmZTg2NzEyN2MwODRhMGU2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWVkZDNiNDdmZGI5ZjZmMzEyZjE4MmM2NWNhZWM2NTc1MWM1YWZiNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTE1OTdkZTA4YTFkMDE5NWJmNDIxODUwZjM3ZDM4NDQ0ZTZjMWFlMmY1NTFi
|
10
|
+
Yjc2Y2ViNzY2MWQwZGNlMmM3YjA3NjEwZGQ5YmQ3MzUwMGJlM2Y3MTVhNzk0
|
11
|
+
OWIwODkwNmQzY2YzZjlhNzUzYTJiNTlhOWIxNTA1ZTZhMjdhMjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Yjg1YWUxMzNlYWFmMWYzYzdiYmIyN2NkZmEyYWE3YWM0MDk3NWViYjQwYzUx
|
14
|
+
MmE3ODA3N2Y0NDllMjEzYTgwZjNjMzQ2NzJjOWFmYWUyMTBhOThhNTNlYjc2
|
15
|
+
MzliN2RiM2UxYWM2NjBmNzFhNDA1ZGQ3MjQ0ZmVhNGQ4ODNhY2U=
|
@@ -0,0 +1,267 @@
|
|
1
|
+
|
2
|
+
var BlockController = function(options) { this.init(options) };
|
3
|
+
|
4
|
+
BlockController.prototype = {
|
5
|
+
|
6
|
+
block: false,
|
7
|
+
authenticity_token: false,
|
8
|
+
//new_block_type_id: false,
|
9
|
+
block_types: false,
|
10
|
+
|
11
|
+
init: function(options)
|
12
|
+
{
|
13
|
+
for (var thing in options)
|
14
|
+
this[thing] = options[thing];
|
15
|
+
|
16
|
+
this.set_block_type_editable();
|
17
|
+
this.set_block_value_editable(this.block);
|
18
|
+
this.set_child_blocks_editable();
|
19
|
+
this.set_clickable();
|
20
|
+
},
|
21
|
+
|
22
|
+
edit_block: function(block_id)
|
23
|
+
{
|
24
|
+
window.location = '/admin/pages/' + this.block.page_id + '/blocks/' + block_id + '/edit';
|
25
|
+
},
|
26
|
+
|
27
|
+
/*****************************************************************************
|
28
|
+
Block Rendering
|
29
|
+
*****************************************************************************/
|
30
|
+
|
31
|
+
set_clickable: function()
|
32
|
+
{
|
33
|
+
var that = this;
|
34
|
+
$.ajax({
|
35
|
+
url: '/admin/pages/' + this.block.page_id + '/blocks/tree',
|
36
|
+
success: function(blocks) {
|
37
|
+
$(blocks).each(function(i,b) {
|
38
|
+
that.set_clickable_helper(b);
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
},
|
43
|
+
|
44
|
+
set_clickable_helper: function(b)
|
45
|
+
{
|
46
|
+
var that = this;
|
47
|
+
$('#block_' + b.id).attr('onclick','').unbind('click');
|
48
|
+
$('#block_' + b.id).click(function(e) {
|
49
|
+
e.stopPropagation();
|
50
|
+
that.edit_block(b.id);
|
51
|
+
});
|
52
|
+
if (b.allow_child_blocks == true)
|
53
|
+
{
|
54
|
+
$('#new_block_' + b.id).replaceWith($('<input/>')
|
55
|
+
.attr('type', 'button')
|
56
|
+
.val('New Block')
|
57
|
+
.click(function(e) { e.stopPropagation(); that.new_block(b.id);
|
58
|
+
})
|
59
|
+
);
|
60
|
+
}
|
61
|
+
var show_mouseover = true;
|
62
|
+
if (b.children && b.children.length > 0)
|
63
|
+
{
|
64
|
+
$.each(b.children, function(i, b2) {
|
65
|
+
if (b2.block_type_id = 34)
|
66
|
+
show_mouseover = false;
|
67
|
+
that.set_clickable_helper(b2);
|
68
|
+
});
|
69
|
+
}
|
70
|
+
if (show_mouseover)
|
71
|
+
{
|
72
|
+
$('#block_' + b.id).mouseover(function(el) { $('#block_' + b.id).addClass( 'block_over'); });
|
73
|
+
$('#block_' + b.id).mouseout(function(el) { $('#block_' + b.id).removeClass('block_over'); });
|
74
|
+
}
|
75
|
+
},
|
76
|
+
|
77
|
+
/****************************************************************************/
|
78
|
+
|
79
|
+
set_block_type_editable: function()
|
80
|
+
{
|
81
|
+
var that = this;
|
82
|
+
var b = this.block;
|
83
|
+
m = new ModelBinder({
|
84
|
+
name: 'Block',
|
85
|
+
id: b.id,
|
86
|
+
update_url: '/admin/pages/' + b.page_id + '/blocks/' + b.id,
|
87
|
+
authenticity_token: that.authenticity_token,
|
88
|
+
attributes: [{
|
89
|
+
name: 'block_type_id',
|
90
|
+
nice_name: 'Block type',
|
91
|
+
type: 'select',
|
92
|
+
value: b.block_type_id,
|
93
|
+
text: b.block_type.name,
|
94
|
+
width: 200,
|
95
|
+
fixed_placeholder: true,
|
96
|
+
options_url: '/admin/block-types/options',
|
97
|
+
after_update: function() { parent.controller.render_blocks(); window.location.reload(true); },
|
98
|
+
after_cancel: function() { parent.controller.render_blocks(); window.location.reload(true); }
|
99
|
+
}]
|
100
|
+
});
|
101
|
+
$('#block_' + b.id + '_block_type_id_container').hide();
|
102
|
+
},
|
103
|
+
|
104
|
+
set_block_value_editable: function(b)
|
105
|
+
{
|
106
|
+
var that = this;
|
107
|
+
var bt = b.block_type;
|
108
|
+
if (b.block_type.field_type == 'block')
|
109
|
+
return;
|
110
|
+
|
111
|
+
var h = {
|
112
|
+
name: 'value',
|
113
|
+
type: bt.field_type,
|
114
|
+
nice_name: bt.description ? bt.description : bt.name,
|
115
|
+
width: bt.width ? bt.width : 780,
|
116
|
+
after_update: function() { parent.controller.render_blocks(); },
|
117
|
+
after_cancel: function() { parent.controller.render_blocks(); }
|
118
|
+
};
|
119
|
+
h['value'] = b.value
|
120
|
+
if (bt.field_type == 'checkbox') h['value'] = b.value ? 'true' : 'false';
|
121
|
+
if (bt.field_type == 'image') h['value'] = b.image.tiny_url;
|
122
|
+
if (bt.field_type == 'file') h['value'] = b.image.url;
|
123
|
+
if (bt.field_type == 'select') h['text'] = b.value;
|
124
|
+
if (bt.height) h['height'] = bt.height;
|
125
|
+
if (bt.fixed_placeholder) h['fixed_placeholder'] = bt.fixed_placeholder;
|
126
|
+
if (bt.options || bt.options_function) h['options_url'] = '/admin/block-types/' + bt.id + '/options';
|
127
|
+
else if (bt.options_url) h['options_url'] = bt.options_url;
|
128
|
+
if (bt.field_type == 'file') h['update_url'] = '/admin/pages/' + b.page_id + '/blocks/' + b.id + '/file';
|
129
|
+
if (bt.field_type == 'image')
|
130
|
+
{
|
131
|
+
h['update_url'] = '/admin/pages/' + b.page_id + '/blocks/' + b.id + '/image'
|
132
|
+
h['image_refresh_delay'] = 100;
|
133
|
+
}
|
134
|
+
|
135
|
+
m = new ModelBinder({
|
136
|
+
name: 'Block',
|
137
|
+
id: b.id,
|
138
|
+
update_url: '/admin/pages/' + b.page_id + '/blocks/' + b.id,
|
139
|
+
authenticity_token: that.authenticity_token,
|
140
|
+
attributes: [h]
|
141
|
+
});
|
142
|
+
},
|
143
|
+
|
144
|
+
set_child_blocks_editable: function()
|
145
|
+
{
|
146
|
+
var that = this;
|
147
|
+
$.each(this.block.children, function(i, b) {
|
148
|
+
var bt = b.block_type;
|
149
|
+
if (bt.field_type == 'block' || bt.field_type == 'richtext')
|
150
|
+
{
|
151
|
+
//$('#block_' + b.id).attr('onclick','').unbind('click');
|
152
|
+
//$('#block_' + b.id).click(function(e) {
|
153
|
+
// window.location = '/admin/pages/' + b.page_id + '/blocks/' + b.id + '/edit';
|
154
|
+
//});
|
155
|
+
}
|
156
|
+
else
|
157
|
+
that.set_block_value_editable(b);
|
158
|
+
});
|
159
|
+
},
|
160
|
+
|
161
|
+
add_child_block: function(block_type_id)
|
162
|
+
{
|
163
|
+
var that = this;
|
164
|
+
if (!this.block_types)
|
165
|
+
{
|
166
|
+
modal.autosize("<p class='loading'>Getting block types...</p>");
|
167
|
+
$.ajax({
|
168
|
+
url: '/admin/block-types/options',
|
169
|
+
type: 'get',
|
170
|
+
success: function(resp) {
|
171
|
+
that.block_types = resp;
|
172
|
+
that.add_child_block();
|
173
|
+
}
|
174
|
+
});
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
if (!block_type_id)
|
178
|
+
{
|
179
|
+
var select = $('<select/>').attr('id', 'new_block_type_id');
|
180
|
+
$.each(this.block_types, function(i, bt) {
|
181
|
+
var opt = $('<option/>').val(bt.value).html(bt.text);
|
182
|
+
select.append(opt);
|
183
|
+
});
|
184
|
+
var p = $('<p/>').addClass('note warning')
|
185
|
+
.append("Select a type of page block: ")
|
186
|
+
.append(select)
|
187
|
+
.append("<br/>")
|
188
|
+
.append($('<input/>').attr('type','button').val('Confirm Add Block').click(function() { that.add_child_block($('#new_block_type_id').val()) })).append(' ')
|
189
|
+
.append($('<input/>').attr('type','button').val('Cancel').click(function() { $('#message').empty(); modal.autosize(); }));
|
190
|
+
modal.autosize(p);
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
modal.autosize("<p class='loading'>Adding block...</p>");
|
194
|
+
$.ajax({
|
195
|
+
url: '/admin/pages/' + that.block.page_id + '/blocks/' + that.block.id,
|
196
|
+
type: 'post',
|
197
|
+
data: { block_type_id: block_type_id },
|
198
|
+
success: function(resp) {
|
199
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
200
|
+
if (resp.block) window.location.reload(true);
|
201
|
+
}
|
202
|
+
});
|
203
|
+
},
|
204
|
+
|
205
|
+
delete_block: function(confirm)
|
206
|
+
{
|
207
|
+
var that = this;
|
208
|
+
if (!confirm)
|
209
|
+
{
|
210
|
+
var p = $('<p/>').addClass('note warning')
|
211
|
+
.append("Are you sure you want to delete the block? This can't be undone.<br />")
|
212
|
+
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.delete_block(true); })).append(' ')
|
213
|
+
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
214
|
+
modal.autosize(p);
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
modal.autosize("<p class='loading'>Deleting block...</p>");
|
218
|
+
$.ajax({
|
219
|
+
url: '/admin/pages/' + that.block.page_id + '/blocks/' + that.block.id,
|
220
|
+
type: 'delete',
|
221
|
+
success: function(resp) {
|
222
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
223
|
+
if (resp.redirect)
|
224
|
+
{
|
225
|
+
parent.controller.render_blocks();
|
226
|
+
modal.close();
|
227
|
+
}
|
228
|
+
}
|
229
|
+
});
|
230
|
+
},
|
231
|
+
|
232
|
+
move_up: function()
|
233
|
+
{
|
234
|
+
var that = this;
|
235
|
+
modal.autosize("<p class='loading'>Moving up...</p>");
|
236
|
+
$.ajax({
|
237
|
+
url: '/admin/pages/' + that.block.page_id + '/blocks/' + that.block.id + '/move-up',
|
238
|
+
type: 'put',
|
239
|
+
success: function(resp) {
|
240
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
241
|
+
if (resp.success)
|
242
|
+
{
|
243
|
+
modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
244
|
+
parent.controller.render_blocks();
|
245
|
+
}
|
246
|
+
}
|
247
|
+
});
|
248
|
+
},
|
249
|
+
|
250
|
+
move_down: function()
|
251
|
+
{
|
252
|
+
var that = this;
|
253
|
+
modal.autosize("<p class='loading'>Moving down...</p>");
|
254
|
+
$.ajax({
|
255
|
+
url: '/admin/pages/' + that.block.page_id + '/blocks/' + that.block.id + '/move-down',
|
256
|
+
type: 'put',
|
257
|
+
success: function(resp) {
|
258
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
259
|
+
if (resp.success)
|
260
|
+
{
|
261
|
+
modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
262
|
+
parent.controller.render_blocks();
|
263
|
+
}
|
264
|
+
}
|
265
|
+
});
|
266
|
+
}
|
267
|
+
};
|
@@ -10,16 +10,17 @@ PageContentController.prototype = {
|
|
10
10
|
{
|
11
11
|
this.page_id = page_id;
|
12
12
|
var that = this;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
that.set_clickable();
|
14
|
+
//this.render_blocks(function() {
|
15
|
+
// that.sortable_blocks();
|
16
|
+
// that.draggable_blocks();
|
17
|
+
//});
|
17
18
|
},
|
18
19
|
|
19
20
|
sortable_blocks: function()
|
20
21
|
{
|
21
22
|
var that = this;
|
22
|
-
$('#
|
23
|
+
$('#blocks').sortable({
|
23
24
|
//hoverClass: "ui-state-active",
|
24
25
|
placeholder: 'sortable-placeholder',
|
25
26
|
forcePlaceholderSize: true,
|
@@ -33,7 +34,7 @@ PageContentController.prototype = {
|
|
33
34
|
$.ajax({
|
34
35
|
url: '/admin/pages/' + that.page_id + '/blocks',
|
35
36
|
type: 'post',
|
36
|
-
data: {
|
37
|
+
data: { block_type_id: that.new_block_type_id, index: ui.item.index() },
|
37
38
|
success: function(resp) { that.render_blocks(function() { that.edit_block(resp.block.id); }); }
|
38
39
|
});
|
39
40
|
that.new_block_type_id = false;
|
@@ -43,7 +44,7 @@ PageContentController.prototype = {
|
|
43
44
|
$.ajax({
|
44
45
|
url: '/admin/pages/' + that.page_id + '/block-order',
|
45
46
|
type: 'put',
|
46
|
-
data: $('#
|
47
|
+
data: $('#blocks').sortable('serialize', { key: "block_ids[]" }),
|
47
48
|
success: function(resp) {}
|
48
49
|
});
|
49
50
|
}
|
@@ -55,7 +56,7 @@ PageContentController.prototype = {
|
|
55
56
|
{
|
56
57
|
$('#new_blocks li').draggable({
|
57
58
|
dropOnEmpty: true,
|
58
|
-
connectToSortable: "#
|
59
|
+
connectToSortable: "#blocks",
|
59
60
|
helper: "clone",
|
60
61
|
revert: "invalid"
|
61
62
|
});
|
@@ -66,6 +67,11 @@ PageContentController.prototype = {
|
|
66
67
|
caboose_modal_url('/admin/pages/' + this.page_id + '/blocks/' + block_id + '/edit');
|
67
68
|
},
|
68
69
|
|
70
|
+
new_block: function(block_id)
|
71
|
+
{
|
72
|
+
caboose_modal_url('/admin/pages/' + this.page_id + '/blocks/' + block_id + '/new');
|
73
|
+
},
|
74
|
+
|
69
75
|
delete_block: function(block_id, confirm)
|
70
76
|
{
|
71
77
|
var that = this;
|
@@ -76,8 +82,8 @@ PageContentController.prototype = {
|
|
76
82
|
.append("Are you sure you want to delete the block? ")
|
77
83
|
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_block(block_id, true); })).append(" ")
|
78
84
|
.append($('<input/>').attr('type', 'button').val('No').click(function() { that.render_block(block_id); }));
|
79
|
-
$('#
|
80
|
-
$('#
|
85
|
+
$('#block_container_' + block_id).attr('onclick','').unbind('click');
|
86
|
+
$('#block_container_' + block_id).empty().append(p);
|
81
87
|
return;
|
82
88
|
}
|
83
89
|
$.ajax({
|
@@ -92,51 +98,71 @@ PageContentController.prototype = {
|
|
92
98
|
/*****************************************************************************
|
93
99
|
Block Rendering
|
94
100
|
*****************************************************************************/
|
95
|
-
|
96
|
-
render_blocks: function(
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
$.ajax({
|
101
|
-
url: '/admin/pages/' + this.page_id + '/blocks/render?empty_text=[Empty, click to edit]',
|
101
|
+
|
102
|
+
render_blocks: function() {
|
103
|
+
var that = this;
|
104
|
+
$.ajax({
|
105
|
+
url: '/admin/pages/' + this.page_id + '/blocks/render-second-level',
|
102
106
|
success: function(blocks) {
|
107
|
+
$(blocks).each(function(i, b) {
|
108
|
+
$('#block_' + b.id).replaceWith(b.html);
|
109
|
+
});
|
110
|
+
that.set_clickable();
|
111
|
+
}
|
112
|
+
});
|
113
|
+
},
|
114
|
+
|
115
|
+
set_clickable: function()
|
116
|
+
{
|
117
|
+
var that = this;
|
118
|
+
$.ajax({
|
119
|
+
url: '/admin/pages/' + this.page_id + '/blocks/tree',
|
120
|
+
success: function(blocks) {
|
103
121
|
$(blocks).each(function(i,b) {
|
104
|
-
|
105
|
-
|
106
|
-
.attr('id', 'pageblock_container_' + b.id)
|
107
|
-
.append($('<a/>').attr('id', 'pageblock_' + b.id + '_sort_handle' ).addClass('sort_handle' ).append($('<span/>').addClass('ui-icon ui-icon-arrow-2-n-s')))
|
108
|
-
.append($('<a/>').attr('id', 'pageblock_' + b.id + '_delete_handle').addClass('delete_handle').append($('<span/>').addClass('ui-icon ui-icon-close')).click(function(e) { e.preventDefault(); that.delete_block(b.id); }))
|
109
|
-
.append($('<div/>').attr('id', 'pageblock_' + b.id).addClass('page_block'))
|
110
|
-
);
|
111
|
-
});
|
112
|
-
$(blocks).each(function(i,b) { that.render_block_html(b.id, b.html); });
|
113
|
-
if (after) after();
|
122
|
+
that.set_clickable_helper(b);
|
123
|
+
});
|
114
124
|
}
|
115
125
|
});
|
116
126
|
},
|
117
127
|
|
118
|
-
|
128
|
+
set_clickable_helper: function(b)
|
119
129
|
{
|
120
|
-
var that = this;
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
if (after) after();
|
126
|
-
}
|
130
|
+
var that = this;
|
131
|
+
$('#block_' + b.id).attr('onclick','').unbind('click');
|
132
|
+
$('#block_' + b.id).click(function(e) {
|
133
|
+
e.stopPropagation();
|
134
|
+
that.edit_block(b.id);
|
127
135
|
});
|
128
|
-
|
136
|
+
if (b.allow_child_blocks == true)
|
137
|
+
{
|
138
|
+
$('#new_block_' + b.id).replaceWith($('<input/>')
|
139
|
+
.attr('type', 'button')
|
140
|
+
.val('New Block')
|
141
|
+
.click(function(e) { e.stopPropagation(); that.new_block(b.id);
|
142
|
+
})
|
143
|
+
);
|
144
|
+
}
|
145
|
+
var show_mouseover = true;
|
146
|
+
if (b.children && b.children.length > 0)
|
147
|
+
{
|
148
|
+
$.each(b.children, function(i, b2) {
|
149
|
+
if (b2.block_type_id = 34)
|
150
|
+
show_mouseover = false;
|
151
|
+
that.set_clickable_helper(b2);
|
152
|
+
});
|
153
|
+
}
|
154
|
+
if (show_mouseover)
|
155
|
+
{
|
156
|
+
$('#block_' + b.id).mouseover(function(el) { $('#block_' + b.id).addClass( 'block_over'); });
|
157
|
+
$('#block_' + b.id).mouseout(function(el) { $('#block_' + b.id).removeClass('block_over'); });
|
158
|
+
}
|
159
|
+
}
|
129
160
|
|
130
|
-
render_block_html: function(block_id, html)
|
131
|
-
{
|
132
|
-
var that = this;
|
133
|
-
$('#pageblock_' + block_id).empty().html(html);
|
134
|
-
$('#pageblock_' + block_id).attr('onclick','').unbind('click');
|
135
|
-
$('#pageblock_' + block_id).click(function(e) { that.edit_block(block_id); });
|
136
|
-
}
|
137
161
|
};
|
138
162
|
|
139
|
-
function
|
163
|
+
function toggle_blocks()
|
140
164
|
{
|
141
165
|
$('#new_blocks_container2').slideToggle();
|
142
|
-
}
|
166
|
+
}
|
167
|
+
|
168
|
+
|