caboose-cms 0.9.133 → 0.9.134

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/admin_block_edit.js +1 -1
  3. data/app/assets/javascripts/caboose/block_content_controller.js +11 -3
  4. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +126 -6
  5. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +5 -5
  6. data/app/assets/javascripts/caboose/block_modal_controllers/block_modal_controller.js +9 -4
  7. data/app/assets/javascripts/caboose/model/attribute.js +1 -1
  8. data/app/assets/javascripts/caboose/model/model_binder.js +3 -1
  9. data/app/assets/stylesheets/caboose/admin_edit_page_content.scss +69 -14
  10. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +101 -11
  11. data/app/controllers/caboose/application_controller.rb +1 -1
  12. data/app/controllers/caboose/blocks_controller.rb +209 -74
  13. data/app/controllers/caboose/pages_controller.rb +34 -0
  14. data/app/controllers/caboose/posts_controller.rb +27 -0
  15. data/app/models/caboose/block.rb +134 -30
  16. data/app/models/caboose/page.rb +42 -1
  17. data/app/models/caboose/post.rb +42 -1
  18. data/app/models/caboose/schema.rb +10 -3
  19. data/app/views/caboose/admin/index.html.erb +0 -1
  20. data/app/views/caboose/pages/admin_edit_content.html.erb +19 -2
  21. data/app/views/caboose/pages/admin_preview.html.erb +1 -0
  22. data/app/views/caboose/posts/admin_edit_content.html.erb +18 -3
  23. data/app/views/caboose/posts/admin_preview_post.html.erb +1 -0
  24. data/app/views/layouts/caboose/admin.html.erb +1 -1
  25. data/lib/caboose/version.rb +1 -1
  26. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c49393255c99312890af6baa442e9307cbf5584
4
- data.tar.gz: 37cbad54d4235c51cbb2e568b55d9c1f25f81310
3
+ metadata.gz: fcfbf246d2536f0c9e4403a909f7555bc07c6cd7
4
+ data.tar.gz: 9c92cffdf2508586d117a4c9e7d3030739c81f77
5
5
  SHA512:
6
- metadata.gz: 4c0376086673884780f837058ff6dfa6e055b860bb3e1b8304595b520a64139518f3d7a6d09d448714d6368d6347a907badb9dd9c48b2c4122d779269c5aadf9
7
- data.tar.gz: 84e926333becfc8207b32d004092ca91a779110941a41cab87ff51176cba48c97f81b1415474eb4f3a9cf30fb91d29f81cac1b7dafee10fcd3fa488b837a5b7e
6
+ metadata.gz: ef97678358c46a955e4e1fe41dee59189ec855db8d84be5b3d56b32893a3515988583358c7d18a18e063087a3538c4abfd6fdb1b2e9e46ddbda7d76c2a569e6f
7
+ data.tar.gz: cbb48655938c647fbc0495d64ef73ef95e1570448d3359523c0753222cb22279b1ae30c3baca83516b73ac1f96fb3a7b42be776f4c82a56b7f7ce032549c4064
@@ -143,7 +143,7 @@ BlockController.prototype = {
143
143
  h['value'] = b.value
144
144
  if (bt.field_type == 'checkbox') h['value'] = b.value ? 'true' : 'false';
145
145
  if (bt.field_type == 'image') h['value'] = b.image.tiny_url;
146
- if (bt.field_type == 'file') h['value'] = b.image.url;
146
+ if (bt.field_type == 'file') h['value'] = b.image.url;
147
147
  if (bt.field_type == 'select') h['text'] = b.value;
148
148
  if (bt.height) h['height'] = bt.height;
149
149
  if (bt.fixed_placeholder) h['fixed_placeholder'] = bt.fixed_placeholder;
@@ -35,6 +35,10 @@ BlockContentController.prototype = {
35
35
  }
36
36
  });
37
37
  },
38
+
39
+ is_modified: function() {
40
+ $("#tiny_header").removeClass('published').addClass('unpublished');
41
+ },
38
42
 
39
43
  edit_block: function(block_id)
40
44
  {
@@ -142,6 +146,7 @@ BlockContentController.prototype = {
142
146
  success: function(resp) {}
143
147
  });
144
148
  }
149
+ that.is_modified();
145
150
  that.render_blocks();
146
151
  },
147
152
 
@@ -153,7 +158,8 @@ BlockContentController.prototype = {
153
158
  url: that.base_url() + '/' + block_id + '/move-up',
154
159
  type: 'put',
155
160
  success: function(resp) {
156
- if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
161
+ if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
162
+ that.is_modified();
157
163
  }
158
164
  });
159
165
  },
@@ -166,7 +172,8 @@ BlockContentController.prototype = {
166
172
  url: that.base_url() + '/' + block_id + '/move-down',
167
173
  type: 'put',
168
174
  success: function(resp) {
169
- if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
175
+ if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
176
+ that.is_modified();
170
177
  }
171
178
  });
172
179
  },
@@ -179,7 +186,8 @@ BlockContentController.prototype = {
179
186
  url: that.base_url() + '/' + block_id + '/duplicate',
180
187
  type: 'put',
181
188
  success: function(resp) {
182
- if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
189
+ if (resp.success) that.render_blocks(function() { that.stop_loadify(); });
190
+ that.is_modified();
183
191
  }
184
192
  });
185
193
  },
@@ -12,6 +12,7 @@ BlockContentController.prototype = {
12
12
  included_assets: false,
13
13
  mc: false,
14
14
  editing_block: false,
15
+ inline_classes: ['rtedit'],
15
16
 
16
17
  init: function(params)
17
18
  {
@@ -20,6 +21,9 @@ BlockContentController.prototype = {
20
21
  that[i] = params[i];
21
22
  that.add_dropzones();
22
23
  that.mc = new ModalController({ parent_controller: this, assets_path: that.assets_path });
24
+ CKEDITOR.disableAutoInline = true;
25
+ that.init_inline_editor();
26
+ // that.add_all_new_child_blocks();
23
27
  },
24
28
 
25
29
  edit_block: function(block_id) {
@@ -35,6 +39,35 @@ BlockContentController.prototype = {
35
39
  });
36
40
  },
37
41
 
42
+ is_modified: function() {
43
+ $("#tiny_header").removeClass('published').addClass('unpublished');
44
+ },
45
+
46
+ init_inline_editor: function() {
47
+ var that = this;
48
+ $.each(that.inline_classes, function(k1, c) {
49
+ $.each($('.' + c), function(k2, b) {
50
+ // var el = $(b).find('.value').first();
51
+ if ( !$(b).hasClass('cke_editable') ) {
52
+ $(b).attr('contenteditable','true');
53
+ var target_id = $(b).data('rtid');
54
+ // var block_id = $(b).attr('id').replace('block_','');
55
+ var editor = CKEDITOR.inline( $(b).attr('id') );
56
+ editor.on('change', function(ev) {
57
+ that.is_modified();
58
+ var html = $(b).html();
59
+ $.ajax({
60
+ url: that.base_url() + '/' + target_id + '/value',
61
+ type: 'put',
62
+ data: { value: html },
63
+ success: function(resp) { }
64
+ });
65
+ });
66
+ }
67
+ });
68
+ });
69
+ },
70
+
38
71
  show_edit_modal: function(block_id, use_js_for_modal, field_type, bname, btname) {
39
72
  var that = this;
40
73
  var ft = field_type;
@@ -80,7 +113,9 @@ BlockContentController.prototype = {
80
113
 
81
114
  render_block: function(block_id) {
82
115
  var that = this;
116
+ // console.log("rendering block " + block_id + "...");
83
117
  var url = that.base_url() + '/' + block_id + '/render';
118
+ that.is_modified();
84
119
  $.ajax({
85
120
  url: url,
86
121
  type: 'get',
@@ -88,6 +123,7 @@ BlockContentController.prototype = {
88
123
  $('#block_' + block_id).replaceWith(html);
89
124
  that.is_loading(false, 'Loading...');
90
125
  that.add_dropzones();
126
+ that.init_inline_editor();
91
127
  }
92
128
  });
93
129
  },
@@ -115,6 +151,7 @@ BlockContentController.prototype = {
115
151
  create_block: function(block_type_id, parent_id, before_block_id, after_block_id, child_block_count) {
116
152
  var that = this;
117
153
  that.is_loading(true, 'Creating block...');
154
+ that.is_modified();
118
155
  var h = {
119
156
  authenticity_token: that.authenticity_token,
120
157
  block_type_id: block_type_id,
@@ -143,6 +180,7 @@ BlockContentController.prototype = {
143
180
  move_block: function(block_id, parent_id, before_block_id, after_block_id) {
144
181
  var that = this;
145
182
  var block_id = block_id.replace('block_','');
183
+ that.is_modified();
146
184
  if ( before_block_id != block_id && after_block_id != block_id && parent_id != block_id ) {
147
185
  var original = $('#block_' + block_id);
148
186
  original.draggable('destroy');
@@ -228,6 +266,7 @@ BlockContentController.prototype = {
228
266
  }
229
267
  that.selected_block_ids = [];
230
268
  that.add_dropzones();
269
+ that.is_modified();
231
270
  }
232
271
  },
233
272
 
@@ -249,6 +288,7 @@ BlockContentController.prototype = {
249
288
  var fake_id = 'db' + Math.floor((Math.random() * 1000) + 1);
250
289
  el.attr('id','new_block_' + fake_id).addClass('duplicated-block');
251
290
  $('#block_' + block_id).after(el);
291
+ that.is_modified();
252
292
  that.duplicate_block_save(block_id, fake_id);
253
293
  },
254
294
 
@@ -271,10 +311,12 @@ BlockContentController.prototype = {
271
311
 
272
312
  render_parent_blocks: function(block_id) {
273
313
  var that = this;
314
+ // console.log("rendering parent blocks for " + block_id + "...");
274
315
  $.ajax({
275
316
  url: that.base_url() + '/' + block_id + '/parent-block',
276
317
  type: 'get',
277
- success: function(resp) {
318
+ success: function(resp) {
319
+ // console.log(resp);
278
320
  if ( resp && resp.parent_id ) { that.render_block(resp.parent_id) };
279
321
  if ( resp && resp.grandparent_id ) { that.render_block(resp.grandparent_id) };
280
322
  }
@@ -285,6 +327,7 @@ BlockContentController.prototype = {
285
327
  {
286
328
  var that = this;
287
329
  if ( that.editing_block ) {
330
+ // console.log("rendering blocks for " + that.editing_block + "...");
288
331
  that.render_block( that.editing_block );
289
332
  that.render_parent_blocks( that.editing_block );
290
333
  }
@@ -383,6 +426,59 @@ BlockContentController.prototype = {
383
426
 
384
427
  },
385
428
 
429
+ // add_all_new_child_blocks: function() {
430
+ // var that = this;
431
+ // $.each( $('.content_body'), function(k,v) {
432
+ // var el = $(v).parents("[id^='block_']").first();
433
+ // that.add_new_child_blocks(el.attr('id').replace('block_',''));
434
+ // });
435
+ // },
436
+
437
+ // get NEW child blocks of this block
438
+ // add_new_child_blocks: function(block_id) {
439
+ // // console.log('adding new child blocks for ' + block_id);
440
+ // var that = this;
441
+ // $.ajax({
442
+ // url: that.base_url() + '/' + block_id + '/new-child-blocks',
443
+ // type: 'get',
444
+ // success: function(resp) {
445
+ // if ( resp && resp.blocks && resp.blocks.length > 0 ) {
446
+
447
+ // $.each(resp.blocks, function(k,v) {
448
+
449
+ // // console.dir(v);
450
+
451
+ // // render each of them
452
+ // var url = that.base_url() + '/' + v.id + '/render';
453
+ // $.ajax({
454
+ // url: url,
455
+ // data: {
456
+ // is_new: 'yes'
457
+ // },
458
+ // type: 'get',
459
+ // success: function(html) {
460
+ // // console.log(html);
461
+
462
+ // if ( $('#block_' + block_id).find('.content_body').first().find('.new_block_link.np').length > 0 ) {
463
+ // $('#block_' + block_id).find('.content_body').first().html('');
464
+ // }
465
+
466
+ // $('#block_' + block_id).find('.content_body').first().append(html);
467
+
468
+ // that.add_handles_to_block(v.id);
469
+ // }
470
+ // });
471
+
472
+ // });
473
+
474
+ // that.add_dropzones();
475
+ // that.init_inline_editor();
476
+
477
+ // }
478
+ // }
479
+ // });
480
+ // },
481
+
386
482
  add_handles_to_block: function(block_id) {
387
483
  var that = this;
388
484
  var el = $('#block_' + block_id);
@@ -397,14 +493,38 @@ BlockContentController.prototype = {
397
493
  .prepend($('<a/>').attr('id', 'handle_block_' + block_id + '_delete' ).addClass('delete_handle' ).append($('<span/>').addClass('ui-icon ui-icon-close' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.delete_block(block_id); }));
398
494
  el.mouseover(function(el) { $('#block_' + block_id).addClass( 'block_over'); });
399
495
  el.mouseout(function(el) { $('#block_' + block_id).removeClass('block_over'); });
496
+ if ( el.hasClass('hasrt') )
497
+ el.prepend($('<a/>').attr('id', 'handle_block_' + block_id + '_settings' ).addClass('settings_handle' ).append($('<span/>').addClass('ui-icon ui-icon-gear' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.edit_block(block_id); }));
400
498
  }
401
499
  el.attr('onclick','').unbind('click');
402
- el.click(function(e) {
403
- e.preventDefault();
404
- e.stopPropagation();
405
- that.edit_block(block_id);
406
- });
500
+ if ( el.hasClass('footer-wrapper') && el.prev('.content_wrapper.subpage').length > 0 ) {
501
+ el.css('position','relative');
502
+ var over = $('<div />').attr('id','footer-msg').text('The footer must be edited on the homepage.').css('position','absolute').css('left','0').css('top','0').css('background','rgba(43, 43, 43, 0.9)').css('color','white').css('width','100%').css('height','100%').css('z-index','14').css('padding','40px 3% 40px 3%').css('text-align','center');
503
+ if ( el.find('#footer-msg').length == 0 ) { el.append(over); }
504
+ }
505
+ else if ( !el.hasClass('container') ) {
506
+ el.click(function(e) {
507
+ e.preventDefault();
508
+ e.stopPropagation();
509
+ if ( el.hasClass('rtedit') || $(e.target).closest(".rtedit").length > 0 || el.hasClass('content_wrapper') )
510
+ return;
511
+ else
512
+ that.edit_block(block_id);
513
+ });
514
+ }
407
515
  }
516
+
517
+
518
+ // el.attr('onclick','').unbind('click');
519
+ // el.click(function(e) {
520
+ // e.preventDefault();
521
+ // e.stopPropagation();
522
+ // if ( el.hasClass('rtedit') )
523
+ // return;
524
+ // else
525
+ // that.edit_block(block_id);
526
+ // });
527
+
408
528
  },
409
529
 
410
530
  /*****************************************************************************
@@ -247,11 +247,11 @@ var BlockModalController = ModalController.extend({
247
247
  type: bt.field_type,
248
248
  nice_name: bt.description ? bt.description : bt.name,
249
249
  width: bt.width ? bt.width : 780,
250
- after_update: function() { that.parent_controller.render_blocks(); },
251
- after_cancel: function() { that.parent_controller.render_blocks(); }
252
- };
253
- h['value'] = b.value
254
- if (bt.field_type == 'checkbox') h['value'] = b.value ? 'true' : 'false';
250
+ after_update: function() { setTimeout(function(){ that.parent_controller.render_blocks(); }, 800); },
251
+ after_cancel: function() { setTimeout(function(){ that.parent_controller.render_blocks(); }, 800); }
252
+ };
253
+ h['value'] = b.value;
254
+ if (bt.field_type == 'checkbox') h['value'] = (b.value == '1' || b.value == 1 || b.value == true || b.value == 'true') ? 'true' : 'false';
255
255
  //if (bt.field_type == 'image') h['value'] = b.image.tiny_url;
256
256
  //if (bt.field_type == 'file') h['value'] = b.file.url;
257
257
  if (bt.field_type == 'select') h['text'] = b.value;
@@ -256,8 +256,8 @@ var BlockModalController = ModalController.extend({
256
256
  type: bt.field_type,
257
257
  nice_name: bt.description ? bt.description : bt.name,
258
258
  width: bt.width ? bt.width : 780,
259
- after_update: function() { that.parent_controller.render_blocks(); },
260
- after_cancel: function() { that.parent_controller.render_blocks(); }
259
+ after_update: function() { that.parent_controller.render_blocks(); that.parent_controller.is_modified(); },
260
+ after_cancel: function() { that.parent_controller.render_blocks(); that.parent_controller.is_modified(); }
261
261
  };
262
262
  h['value'] = b.value
263
263
  if (bt.field_type == 'checkbox') h['value'] = b.value ? 'true' : 'false';
@@ -408,7 +408,8 @@ var BlockModalController = ModalController.extend({
408
408
  {
409
409
  that.parent_controller.refresh_blocks(function() {
410
410
  that.parent_controller.edit_block(resp.new_id);
411
- that.parent_controller.render_blocks();
411
+ that.parent_controller.render_blocks();
412
+ that.parent_controller.is_modified();
412
413
  });
413
414
  }
414
415
  }
@@ -437,7 +438,8 @@ var BlockModalController = ModalController.extend({
437
438
  if (resp.redirect)
438
439
  {
439
440
  that.close();
440
- that.parent_controller.render_blocks();
441
+ that.parent_controller.render_blocks();
442
+ that.parent_controller.is_modified();
441
443
  }
442
444
  }
443
445
  });
@@ -454,6 +456,7 @@ var BlockModalController = ModalController.extend({
454
456
  if (resp.success) {
455
457
  that.autosize("<p class='note success'>Duplicated block.</p>");
456
458
  that.parent_controller.render_blocks();
459
+ that.parent_controller.is_modified();
457
460
  }
458
461
  }
459
462
  });
@@ -472,6 +475,7 @@ var BlockModalController = ModalController.extend({
472
475
  {
473
476
  that.autosize("<p class='note success'>" + resp.success + "</p>");
474
477
  that.parent_controller.render_blocks();
478
+ that.parent_controller.is_modified();
475
479
  }
476
480
  }
477
481
  });
@@ -490,6 +494,7 @@ var BlockModalController = ModalController.extend({
490
494
  {
491
495
  that.autosize("<p class='note success'>" + resp.success + "</p>");
492
496
  that.parent_controller.render_blocks();
497
+ that.parent_controller.is_modified();
493
498
  }
494
499
  }
495
500
  });
@@ -54,7 +54,7 @@ Attribute.prototype = {
54
54
  this2.value_clean = this2.value;
55
55
  }
56
56
  if (after) after(resp);
57
- //if (this2.after_update) this2.after_update(this2);
57
+ // if (this2.after_update) this2.after_update(this2);
58
58
  },
59
59
  error: function() {
60
60
  if (after) after(false);
@@ -222,7 +222,9 @@ ModelBinder.prototype = {
222
222
  attrib.update_url = this.model.update_url;
223
223
  if (attrib.before_update) attrib.before_update(this);
224
224
  attrib.save(after);
225
- if (attrib.after_update) attrib.after_update(this);
225
+ if (attrib.after_update) {
226
+ attrib.after_update(this);
227
+ }
226
228
  },
227
229
 
228
230
  repopulate_options_for_control: function(attribute_name)
@@ -2,23 +2,78 @@
2
2
  #tiny_header {
3
3
  display: block;
4
4
  color: #fff;
5
- background-image: url(/assets/caboose/caboose_logo_small.png);
6
- background-color: #000;
7
- background-repeat: no-repeat;
8
- background-position: right 0;
9
- padding: 0 50px 0 10px;
10
- position: absolute;
11
- top: 0px;
12
- right: 0px;
5
+ background-color: #353535;
6
+ position: fixed;
7
+ top: 0;
8
+ right: 0;
13
9
  z-index: 100000;
14
- border-left: #fff 1px solid;
15
- border-bottom: #fff 1px solid;
10
+ width: 100%;
11
+ height: 40px;
12
+ padding: 0 2%;
13
+ line-height: 37px;
14
+ text-align: right;
15
+ transition: background-color 300ms ease;
16
+ #m-pub, #m-unpub {
17
+ float: left;
18
+ font-family: 'Roboto';
19
+ font-weight: 300;
20
+ font-size: 13px;
21
+ position: relative;
22
+ top: 1px;
23
+ font-style: italic;
24
+ color: #9e9e9e;
25
+ }
26
+ #m-unpub {
27
+ color: #fff;
28
+ }
29
+ a {
30
+ display: inline-block;
31
+ color: #fff;
32
+ padding: 0 10px;
33
+ font-family: 'Roboto';
34
+ font-weight: 300;
35
+ font-size: 12px;
36
+ text-decoration: none;
37
+ background: #5a5a5a;
38
+ margin-left: 8px;
39
+ text-transform: uppercase;
40
+ border-radius: 3px;
41
+ line-height: 24px;
42
+ &[href*="revert"] {
43
+ background: #903b3b;
44
+ }
45
+ &[href*="preview"] {
46
+ background: #404088;
47
+ }
48
+ &[href*="publish"] {
49
+ background: #3b753b;
50
+ }
51
+ &:hover {
52
+ background: #c3c3c3;
53
+ color: #353535;
54
+ }
55
+ &:focus {
56
+ outline-width: 0;
57
+ }
58
+ }
59
+ &.published {
60
+ background-color: #353535;
61
+ #m-unpub { display: none; }
62
+ a[href*="revert"], a[href*="publish"] {
63
+ display: none;
64
+ }
65
+ }
66
+ &.unpublished {
67
+ background-color: #7da4a9;
68
+ #m-pub { display: none; }
69
+ }
16
70
  }
17
- #tiny_header a {
18
- display: inline-block;
19
- color: #fff;
20
- padding: 16px 10px;
71
+
72
+ body > .container, body > .mm-page > .container {
73
+ position: relative;
74
+ top: 40px;
21
75
  }
76
+
22
77
  .block_over { background: #e3e3e3; }
23
78
  .select_handle { display: none; }
24
79
  .move_up_handle { display: none; }