caboose-cms 0.9.228 → 0.9.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin_main.js +1 -13
  4. data/app/assets/javascripts/caboose/admin_media_index.js +161 -158
  5. data/app/assets/javascripts/caboose/application.js +8 -7
  6. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +60 -4
  7. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +3 -2
  8. data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +17 -6
  9. data/app/assets/javascripts/caboose/model/all.js +5 -1
  10. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +2 -1
  11. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +71 -15
  12. data/app/assets/stylesheets/caboose/admin_main.css.scss +25 -29
  13. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +26 -5
  14. data/app/assets/stylesheets/caboose/application.css +11 -5
  15. data/app/assets/stylesheets/caboose/login.scss +1 -0
  16. data/app/assets/stylesheets/caboose/model_binder.css +13 -4
  17. data/app/assets/stylesheets/caboose/page_bar_generator.css +2 -1
  18. data/app/controllers/caboose/admin_controller.rb +3 -4
  19. data/app/controllers/caboose/application_controller.rb +16 -19
  20. data/app/controllers/caboose/block_types_controller.rb +8 -6
  21. data/app/controllers/caboose/cart_controller.rb +2 -2
  22. data/app/controllers/caboose/change_logs_controller.rb +13 -0
  23. data/app/controllers/caboose/fonts_controller.rb +139 -2
  24. data/app/controllers/caboose/invoices_controller.rb +5 -4
  25. data/app/controllers/caboose/login_logs_controller.rb +5 -7
  26. data/app/controllers/caboose/media_categories_controller.rb +16 -2
  27. data/app/controllers/caboose/media_controller.rb +14 -11
  28. data/app/controllers/caboose/pages_controller.rb +104 -42
  29. data/app/controllers/caboose/posts_controller.rb +53 -7
  30. data/app/controllers/caboose/products_controller.rb +1 -1
  31. data/app/controllers/caboose/sites_controller.rb +25 -6
  32. data/app/controllers/caboose/sns_controller.rb +3 -3
  33. data/app/controllers/caboose/themes_controller.rb +30 -0
  34. data/app/controllers/caboose/users_controller.rb +17 -10
  35. data/app/controllers/caboose/variants_controller.rb +9 -9
  36. data/app/models/caboose/block.rb +98 -22
  37. data/app/models/caboose/block_type.rb +2 -1
  38. data/app/models/caboose/block_type_parser.rb +1 -1
  39. data/app/models/caboose/calendar_event_group.rb +2 -2
  40. data/app/models/caboose/change_log.rb +97 -0
  41. data/app/models/caboose/core_plugin.rb +4 -3
  42. data/app/models/caboose/font.rb +7 -2
  43. data/app/models/caboose/font_variant.rb +12 -0
  44. data/app/models/caboose/media.rb +15 -4
  45. data/app/models/caboose/media_category.rb +2 -4
  46. data/app/models/caboose/page.rb +316 -45
  47. data/app/models/caboose/page_bar_generator.rb +20 -10
  48. data/app/models/caboose/post.rb +108 -8
  49. data/app/models/caboose/product.rb +1 -1
  50. data/app/models/caboose/role.rb +2 -2
  51. data/app/models/caboose/schema.rb +73 -72
  52. data/app/models/caboose/site.rb +203 -1
  53. data/app/models/caboose/theme.rb +70 -5
  54. data/app/views/caboose/block_types/admin_edit.html.erb +6 -8
  55. data/app/views/caboose/blocks/_cached_block.html.erb +28 -0
  56. data/app/views/caboose/blocks/_file.html.erb +2 -2
  57. data/app/views/caboose/blocks/_ga.html.erb +1 -2
  58. data/app/views/caboose/blocks/_image.html.erb +4 -0
  59. data/app/views/caboose/blocks/_render_function.html.erb +9 -4
  60. data/app/views/caboose/change_logs/admin_index.html.erb +65 -0
  61. data/app/views/caboose/fonts/admin_family_edit.html.erb +63 -0
  62. data/app/views/caboose/fonts/admin_family_index.html.erb +42 -0
  63. data/app/views/caboose/fonts/admin_index.html.erb +55 -10
  64. data/app/views/caboose/fonts/admin_variant_edit.html.erb +84 -0
  65. data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +5 -14
  66. data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
  67. data/app/views/caboose/media/admin_index.html.erb +14 -24
  68. data/app/views/caboose/my_account/index.html.erb +1 -0
  69. data/app/views/caboose/pages/_admin_header.html.erb +5 -0
  70. data/app/views/caboose/pages/admin_change_logs.html.erb +56 -0
  71. data/app/views/caboose/pages/admin_edit_content.html.erb +6 -2
  72. data/app/views/caboose/pages/admin_edit_general.html.erb +32 -4
  73. data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
  74. data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
  75. data/app/views/caboose/posts/_admin_header.html.erb +5 -0
  76. data/app/views/caboose/posts/admin_change_logs.html.erb +56 -0
  77. data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
  78. data/app/views/caboose/posts/admin_edit_content.html.erb +6 -2
  79. data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
  80. data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
  81. data/app/views/caboose/sites/admin_edit.html.erb +21 -0
  82. data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
  83. data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
  84. data/app/views/caboose/themes/admin_edit.html.erb +7 -3
  85. data/app/views/caboose/themes/admin_error_log.html.erb +9 -0
  86. data/app/views/caboose/themes/admin_js.html.erb +131 -0
  87. data/app/views/caboose/users/_admin_header.html.erb +4 -0
  88. data/app/views/caboose/users/admin_change_logs.html.erb +63 -0
  89. data/app/views/caboose/users/admin_edit_roles.html.erb +1 -0
  90. data/app/views/caboose/variants/admin_group.html.erb +1 -1
  91. data/app/views/layouts/caboose/admin.html.erb +9 -2
  92. data/app/views/layouts/caboose/application.html.erb +62 -92
  93. data/app/views/layouts/caboose/css.css.erb +44 -0
  94. data/app/views/layouts/caboose/footer_css.css.erb +41 -0
  95. data/app/views/layouts/caboose/footer_js.js.erb +31 -0
  96. data/app/views/layouts/caboose/js.js.erb +34 -0
  97. data/lib/caboose/version.rb +1 -1
  98. data/lib/tasks/caboose.rake +3 -14
  99. metadata +23 -27
  100. data/app/controllers/caboose/assets_controller.rb +0 -65
  101. data/app/models/caboose/asset.rb +0 -23
  102. data/app/models/caboose/asset_manifest.rb +0 -91
  103. data/app/models/caboose/block_cache.rb +0 -105
  104. data/app/models/caboose/block_cache_file.rb +0 -22
  105. data/app/models/caboose/block_cache_image.rb +0 -53
  106. data/app/models/caboose/page_cache.rb +0 -12
  107. data/app/models/caboose/page_cacher.rb +0 -137
  108. data/app/views/caboose/pages/admin_new_old.html.erb +0 -46
  109. data/app/views/caboose/pages/test.html.erb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b89809e13ef7764c5cad31cc964088a62059fd1d9c4f8fc605a6f25205d17b05
4
- data.tar.gz: 40eec51e9e0de7c6639ad0a08982f61501eb05c50275509fe0b6558234f0ed65
3
+ metadata.gz: 121271249da78a68a31b4fd59d45251631066a87fc53b308f8b0ef8c0eabd082
4
+ data.tar.gz: 2434ebfd7e93850f55da2a75320299e01c9ad778ee1b60210e0c93f218e50a92
5
5
  SHA512:
6
- metadata.gz: d483ad56514bf89e62d123521fe32c94471a696da74caa09854c1a255918254e30b1d7b94e749bf3cb0fa05f6d8b0c0685380648ff3d9f2af17ce6de97bc427c
7
- data.tar.gz: f42704933116462997b19e25c21d0f5ffa79a40b544c35a38558a63f84b27841318ffd27b1f98963f48b531befda1766902de057985d8c2abc5258883876c564
6
+ metadata.gz: 5189d3c36ef6c4aae4bf201d080c9e53616b2304bc2e145d2fd7e847a74f5fb08a7f7fabfb17d0d4fbac62f6441c839883d61f284f20892d876f834df6860b10
7
+ data.tar.gz: 35070ab584b77c04c51590ba62aa42ec9b514c850ed81723da554d7424d8ca09361e9223dbe8e28bc65d597e9e9f23cb5c40dcc1f19fc651fd59f3d36de619b7
@@ -17,4 +17,4 @@
17
17
  //= require caboose/jquery.datetimepicker
18
18
  //= require caboose/jquery.placeholder
19
19
  //= require caboose/modal_integration
20
- //= require caboose/admin_main
20
+ //= require caboose/admin_main
@@ -1,4 +1,3 @@
1
-
2
1
  function curr(x)
3
2
  {
4
3
  if (!x) return '0.00'
@@ -18,15 +17,4 @@ function add_to_crumbtrail(href, text)
18
17
  if (!c.is(':empty'))
19
18
  c.append(' > ');
20
19
  c.append($('<a/>').attr('href', href).html(text));
21
- }
22
-
23
- $(window).load(function() {
24
- $("#top_nav ul.quick > li").mouseenter(function() {
25
- $(this).find("ul").show();
26
- $(this).children('a, span').addClass('hovered');
27
- });
28
- $("#top_nav ul.quick > li").mouseleave(function() {
29
- $(this).find("ul").hide();
30
- $(this).children('a, span').removeClass('hovered');
31
- });
32
- });
20
+ }
@@ -29,20 +29,23 @@ MediaController.prototype = {
29
29
  .empty()
30
30
  .append($('<p/>')
31
31
  .append($('<a/>').addClass('caboose-btn').attr('href', '#').html('Upload').click(function(e) { e.preventDefault(); that.toggle_uploader(); }))
32
- .append($('<a/>').addClass('caboose-btn').attr('href', '#').html('Select All').click(function(e) { e.preventDefault(); that.select_all_media(); }))
33
- .append($('<a/>').addClass('caboose-btn').attr('href', '#').attr('id', 'sort-btn').html('Sort').click(function(e) { e.preventDefault(); that.sort_media(); }))
32
+ .append($('<a/>').addClass('caboose-btn blue').attr('href', '#').html('Select All').click(function(e) { e.preventDefault(); that.select_all_media(); }))
33
+ .append($('<a/>').addClass('caboose-btn blue').attr('href', '#').attr('id', 'sort-btn').html('Sort').click(function(e) { e.preventDefault(); that.sort_media(); }))
34
+ .append($('<a/>').addClass('caboose-btn red').attr('href', '#').attr('id', 'delete-btn').html('Delete Selected Files').click(function(e) { e.preventDefault(); that.delete_media(false); }))
35
+ .append($('<a/>').addClass('caboose-btn red').attr('href', '#').attr('id', 'delete-btn').html('Delete Selected Category').click(function(e) { e.preventDefault(); that.delete_category(that.cat_id, false); }))
36
+ .append($('<a/>').addClass('caboose-btn green').attr('href', '#').attr('id', 'new-btn').html('New Category').click(function(e) { e.preventDefault(); that.add_category(); }))
34
37
  )
38
+ .append("<div id='delete'></div>")
39
+ .append("<div id='new_cat_message'></div>")
35
40
  .append($('<div/>').attr('id', 'the_uploader'));
36
41
  that.refresh();
37
42
  },
38
43
 
39
44
  refresh: function()
40
45
  {
41
- //console.log("REFRESHING EVERYTHING");
42
46
  var that = this;
43
47
  that.refresh_categories();
44
48
  that.refresh_media();
45
- that.print_controls();
46
49
  },
47
50
 
48
51
  refresh_categories: function(after)
@@ -64,7 +67,6 @@ MediaController.prototype = {
64
67
 
65
68
  refresh_media: function()
66
69
  {
67
- //console.log("REFRESHING MEDIA");
68
70
  var that = this;
69
71
  $.ajax({
70
72
  url: '/admin/media/json',
@@ -88,7 +90,7 @@ MediaController.prototype = {
88
90
  sort: list
89
91
  },
90
92
  success: function(resp) {
91
- console.log("success");
93
+ // console.log("success");
92
94
  }
93
95
  });
94
96
  },
@@ -236,10 +238,9 @@ MediaController.prototype = {
236
238
  .addClass('category')
237
239
  .attr('id', 'cat' + cat.id)
238
240
  .data('media_category_id', cat.id)
239
- .append($('<a/>').attr('href', '#').html(cat.name + ' (' + cat.media_count + ')').click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_id')); }));
241
+ .append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_id')); }));
240
242
  if (cat.id == that.cat_id)
241
243
  li.addClass('selected');
242
- // console.dir(cat);
243
244
  if (cat.name && cat.name.indexOf('Products') > -1 && product_cat_id == 0) {
244
245
  li.addClass('products-li');
245
246
  li.html('').append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); $(this).closest('#left_content').toggleClass('hide-products'); }));
@@ -247,7 +248,7 @@ MediaController.prototype = {
247
248
  }
248
249
  else if ( cat.parent_id == product_cat_id ) {
249
250
  li.addClass('product-sub-li');
250
- li.html('').append($('<a/>').attr('href', '#').html(cat.name + ' (' + cat.media_count + ')').click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_id')); }));
251
+ li.html('').append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_id')); }));
251
252
  }
252
253
  ul.append(li);
253
254
  });
@@ -255,8 +256,8 @@ MediaController.prototype = {
255
256
  else
256
257
  ul = $('<p/>').html("There are no media categories.");
257
258
  $('#categories').empty().append(ul)
258
- .append($('<p/>').append($('<a/>').attr('href', '#').html('New Category').click(function(e) { e.preventDefault(); that.add_category(); })))
259
- .append($('<div/>').attr('id', 'new_cat_message'));
259
+ // .append($('<p/>').append($('<a/>').attr('href', '#').html('New Category').click(function(e) { e.preventDefault(); that.add_category(); })))
260
+ // .append($('<div/>').attr('id', 'new_cat_message'));
260
261
 
261
262
  $.each(that.categories, function(i, cat) {
262
263
  $('#cat' + cat.id).droppable({
@@ -290,34 +291,49 @@ MediaController.prototype = {
290
291
  $('#cat' + cat.id).draggable({ revert: 'invalid' });
291
292
  });
292
293
  },
294
+
295
+ // delete_media: function() {
296
+ // if (ui.draggable.hasClass('category')) {
297
+ // var media_category_id = ui.draggable.data('media_category_id');
298
+ // that.delete_category(media_category_id);
299
+ // }
300
+ // else {
301
+ // id = ui.draggable.data('media_id');
302
+ // if (that.selected_media.length > 0 && that.selected_media.indexOf(id) > -1)
303
+ // {
304
+ // that.select_media(id); // Go ahead and de-select because the select event is about to run
305
+ // }
306
+ // that.delete_media();
307
+ // }
308
+ // },
293
309
 
294
- print_controls: function()
295
- {
296
- var that = this;
297
- $('#controls').empty()
298
- .append($('<div/>').attr('id', 'delete').append($('<p/>').addClass('delete_dropper').html('Delete')));
310
+ // print_controls: function()
311
+ // {
312
+ // var that = this;
313
+ // $('#controls').empty()
314
+ // .append($('<div/>').attr('id', 'delete').append($('<p/>').addClass('delete_dropper').html('Delete')));
299
315
 
300
- $('#delete').droppable({
301
- accept: function(draggable) { return (draggable.hasClass('category') || draggable.hasClass('media')) },
302
- hoverClass: 'hover',
303
- drop: function(event, ui) {
304
- if (ui.draggable.hasClass('category'))
305
- {
306
- var media_category_id = ui.draggable.data('media_category_id');
307
- that.delete_category(media_category_id);
308
- }
309
- else // media
310
- {
311
- id = ui.draggable.data('media_id');
312
- if (that.selected_media.length > 0 && that.selected_media.indexOf(id) > -1)
313
- {
314
- that.select_media(id); // Go ahead and de-select because the select event is about to run
315
- }
316
- that.delete_media();
317
- }
318
- }
319
- });
320
- },
316
+ // $('#delete').droppable({
317
+ // accept: function(draggable) { return (draggable.hasClass('category') || draggable.hasClass('media')) },
318
+ // hoverClass: 'hover',
319
+ // drop: function(event, ui) {
320
+ // if (ui.draggable.hasClass('category'))
321
+ // {
322
+ // var media_category_id = ui.draggable.data('media_category_id');
323
+ // that.delete_category(media_category_id);
324
+ // }
325
+ // else // media
326
+ // {
327
+ // id = ui.draggable.data('media_id');
328
+ // if (that.selected_media.length > 0 && that.selected_media.indexOf(id) > -1)
329
+ // {
330
+ // that.select_media(id); // Go ahead and de-select because the select event is about to run
331
+ // }
332
+ // that.delete_media();
333
+ // }
334
+ // }
335
+ // });
336
+ // },
321
337
 
322
338
  print_media: function()
323
339
  {
@@ -342,8 +358,13 @@ MediaController.prototype = {
342
358
  if (m.original_name && m.original_name.indexOf('png') > 0) {
343
359
  li.addClass("png");
344
360
  }
361
+ //console.log("original_name: " + m.original_name);
345
362
  if (m.image_urls)
346
363
  li.append($("<div/>").addClass("table").append($("<div/>").addClass("table-cell").append($('<img/>').attr('src', m.image_urls.tiny_url).attr("id","image-" + m.id))));
364
+ // else if (m.original_name && (m.original_name.indexOf('.pdf') > 0 || m.original_name.indexOf('.PDF') > 0)) {
365
+ // li.append($('<canvas/>').attr('id','pdf-' + m.id).attr("width","80").attr("height","80"));
366
+ // that.load_pdf_preview(m);
367
+ // }
347
368
  else if (m.original_name) {
348
369
  var ext = m.original_name.match(/\.[0-9a-z]+$/i);
349
370
  li.addClass('empty');
@@ -354,22 +375,19 @@ MediaController.prototype = {
354
375
  li.addClass('selected ui-selected');
355
376
  var btndiv = $("<div/>").addClass("buttons");
356
377
  li.append(btndiv);
357
- if (that.allow_edit && m.image_urls) btndiv.append($("<a/>").html("Edit Image").click(function() { that.edit_image($(this).parent().parent().data('media_id')); }));
358
- else btndiv.append($("<a/>").attr('href', m.file_url).html("Direct URL"));
359
- if ( m.image_urls ) btndiv.append($("<a/>").addClass("dl i").html("Download").click(function() { that.download_image($(this).parent().parent().data('media_id')); }));
360
- else btndiv.append($("<a/>").addClass("dl i").html("Download").click(function() { that.download_image($(this).parent().parent().data('media_id')); }));
378
+ //if (that.allow_edit && m.image_urls) btndiv.append($("<a/>").html("Edit Image").click(function() { that.edit_image($(this).parent().parent().data('media_id')); }));
379
+ if ( m.image_urls && m.image_urls.large_url )
380
+ btndiv.append($("<a/>").attr('target','_blank').attr('href', m.image_urls.large_url).html("Direct URL"));
381
+ else
382
+ btndiv.append($("<a/>").attr('target','_blank').attr('href', m.file_url).html("Direct URL"));
383
+ btndiv.append($("<a/>").addClass("dl i").html("Download").click(function() { that.download_image($(this).parent().parent().data('media_id')); }));
361
384
  ul.append(li);
362
385
  });
363
386
  }
364
387
  else
365
388
  ul = $('<p/>').html("This category is empty.");
366
389
  $('#media').empty().append(ul);
367
- if (that.refresh_unprocessed_images == true && processing)
368
- {
369
- //setTimeout(function() { that.refresh_media(); }, 2000);
370
- setTimeout(function() { that.check_processing_status(); }, 3000);
371
- }
372
-
390
+ if (that.refresh_unprocessed_images == true && processing) { setTimeout(function() { that.check_processing_status(); }, 3000); }
373
391
  $.each(that.media, function(i, m) {
374
392
  $('li.media').draggable({
375
393
  multiple: true,
@@ -377,7 +395,6 @@ MediaController.prototype = {
377
395
  start: function() { $(this).data("origPosition", $(this).position()); }
378
396
  });
379
397
  });
380
- // $("#media ul").sortable();
381
398
  },
382
399
 
383
400
  //============================================================================
@@ -431,58 +448,37 @@ MediaController.prototype = {
431
448
  delete_media: function(confirm)
432
449
  {
433
450
  var that = this;
434
- if (!confirm)
451
+ if ( that.selected_media.length == 0 ) {
452
+ $('#delete').empty().html("<p class='note error'>You don't have any files selected.</p>");
453
+ setTimeout(function(){ $('#delete').empty() }, 3000);
454
+ }
455
+ else if (!confirm)
435
456
  {
436
- $.each(that.selected_media, function(i, id) {
437
- $('#media' + id).css('top', '0').css('left', '0');
438
- });
457
+ // $.each(that.selected_media, function(i, id) {
458
+ // $('#media' + id).css('top', '0').css('left', '0');
459
+ // });
439
460
  var div = $('<p/>').addClass('note error')
440
- .append('Are you sure?<br/>')
461
+ .append('Are you sure you want to delete the selected ' + that.selected_media.length + ' files?&nbsp;&nbsp;')
441
462
  .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_media(true); })).append(" ")
442
- .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_media(); that.print_controls(); }));
463
+ .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_media(); $('#delete').empty(); }));
443
464
  $('#delete').empty().append(div);
444
465
  return;
445
466
  }
446
- $('#delete').empty().html("<p class='loading'>Deleting...</p>");
447
- $.ajax({
448
- url: '/admin/media/bulk',
449
- type: 'delete',
450
- data: { ids: that.selected_media },
451
- success: function(resp) { that.refresh_categories(); that.refresh_media(); that.print_controls(); }
452
- });
467
+ else {
468
+ $('#delete').empty().html("<p class='note loading'>Deleting files...</p>");
469
+ $.ajax({
470
+ url: '/admin/media/bulk',
471
+ type: 'delete',
472
+ data: { ids: that.selected_media },
473
+ success: function(resp) { that.refresh_categories(); that.refresh_media(); $('#delete').empty(); }
474
+ });
475
+ }
453
476
  },
454
477
 
455
478
  edit_media_description: function(media_id)
456
479
  {
457
480
  var that = this;
458
481
  caboose_modal_url('/admin/media/' + media_id + '/description');
459
-
460
- //var div = $('<div/>').attr('id', 'media_' + media_id + '_description');
461
- //$('#media').append(div);
462
- //new ModelBinder({
463
- // name: 'Media',
464
- // id: media_id,
465
- // update_url: '/admin/media/' + media_id,
466
- // authenticity_token: that.authenticity_token,
467
- // attributes: [
468
- // {
469
- // name: 'description', nice_name: 'Description', type: 'textarea', value: '', width: 400, height: 100, fixed_placeholder: true,
470
- // after_update: function() { $('#media_' + media_id + '_description_container').remove(); },
471
- // after_cancel: function() { $('#media_' + media_id + '_description_container').remove(); }
472
- // }
473
- // ]
474
- //});
475
- //var options = {
476
- // iframe: true,
477
- // innerWidth: 200,
478
- // innerHeight: 50,
479
- // scrolling: false,
480
- // transition: 'fade',
481
- // closeButton: false,
482
- // onComplete: caboose_fix_colorbox,
483
- // opacity: 0.50
484
- //};
485
- //setTimeout(function() { $('#media_' + media_id + '_description_container').colorbox(options); }, 2000);
486
482
  },
487
483
 
488
484
  //============================================================================
@@ -502,14 +498,14 @@ MediaController.prototype = {
502
498
  if (!name)
503
499
  {
504
500
  var div = $('<p/>').addClass('note warning')
505
- .append('New Category Name: ')
501
+ .append('New category name:&nbsp;&nbsp;')
506
502
  .append($('<input/>').attr('type', 'text').attr('id', 'new_cat_name')).append(" ")
507
503
  .append($('<input/>').attr('type', 'button').val('Add').click(function() { that.add_category($('#new_cat_name').val()); })).append(" ")
508
504
  .append($('<input/>').attr('type', 'button').val('Cancel').click(function() { $('#new_cat_message').empty(); }));
509
505
  $('#new_cat_message').empty().append(div);
510
506
  return;
511
507
  }
512
- $('#new_cat_message').empty().html("<p class='loading'>Adding category...</p>");
508
+ $('#new_cat_message').empty().html("<p class='note loading'>Adding category...</p>");
513
509
  $.ajax({
514
510
  url: '/admin/media-categories',
515
511
  type: 'post',
@@ -520,6 +516,7 @@ MediaController.prototype = {
520
516
  success: function(resp) {
521
517
  if (resp.error) $('#new_cat_message').empty().html("<p class='note error'>" + resp.error + "</p>");
522
518
  if (resp.refresh) that.refresh_categories();
519
+ $('#new_cat_message').empty();
523
520
  }
524
521
  });
525
522
  },
@@ -527,31 +524,38 @@ MediaController.prototype = {
527
524
  delete_category: function(cat_id, confirm)
528
525
  {
529
526
  var that = this;
530
- if (!confirm)
527
+ if (cat_id == that.top_cat_id) {
528
+ $('#delete').empty().html("<p class='note error'>You cannot delete the top level category.</p>");
529
+ setTimeout(function(){ $('#delete').empty() }, 3000);
530
+ }
531
+ else if (!confirm)
531
532
  {
532
533
  var div = $('<p/>').addClass('note warning')
533
- .append('Are you sure? ')
534
+ .append('Are you sure you want to delete the selected category? All files in this category, and all subcategories, will also be deleted.&nbsp;&nbsp;')
534
535
  .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_category(cat_id, true); })).append(" ")
535
- .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_categories(); that.print_controls() }));
536
+ .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_categories(); $('#delete').empty(); }));
536
537
  $('#delete').empty().append(div);
537
538
  return;
538
539
  }
539
- $('#delete').empty().html("<p class='loading'>Deleting...</p>");
540
- $.ajax({
541
- url: '/admin/media-categories/' + cat_id,
542
- type: 'delete',
543
- success: function(resp) {
544
- that.refresh_categories(function() {
545
- var exists = false;
546
- $.each(that.categories, function(i, cat) { if (cat.id == cat_id) { exists = true; return false; }});
547
- if (!exists)
548
- that.select_category(that.categories[0].id);
549
- else
550
- that.refresh_media();
551
- that.print_controls();
552
- });
553
- }
554
- });
540
+ else {
541
+ $('#delete').empty().html("<p class='note loading'>Deleting category...</p>");
542
+ $.ajax({
543
+ url: '/admin/media-categories/' + cat_id,
544
+ type: 'delete',
545
+ success: function(resp) {
546
+ that.refresh_categories(function() {
547
+ var exists = false;
548
+ $.each(that.categories, function(i, cat) { if (cat.id == cat_id) { exists = true; return false; }});
549
+ if (!exists)
550
+ that.select_category(that.categories[0].id);
551
+ else
552
+ that.refresh_media();
553
+ });
554
+ $('#delete').empty();
555
+ }
556
+ });
557
+ }
558
+
555
559
  },
556
560
 
557
561
  media_with_id: function(media_id)
@@ -592,59 +596,58 @@ MediaController.prototype = {
592
596
  // Aviary
593
597
  //============================================================================
594
598
 
595
- edit_image: function(media_id)
596
- {
597
- var that = this;
598
- var m = that.media_with_id(media_id);
599
+ // edit_image: function(media_id)
600
+ // {
601
+ // var that = this;
602
+ // var m = that.media_with_id(media_id);
599
603
 
600
- if (that.feather_editor != false)
601
- {
602
- that.edit_image_helper(m);
603
- return;
604
- }
605
- that.feather_editor = new Aviary.Feather({
606
- apiKey: '933414ee42934e8b81d8cd2226a5a13b',
607
- theme: 'light',
608
- enableCORS: false,
609
- maxSize: 1600,
610
- onSave: function(media_id, new_url) { return that.update_image(media_id, new_url); },
611
- onLoad: function() { that.edit_image_helper(m); }
612
- });
613
- },
604
+ // if (that.feather_editor != false)
605
+ // {
606
+ // that.edit_image_helper(m);
607
+ // return;
608
+ // }
609
+ // that.feather_editor = new Aviary.Feather({
610
+ // apiKey: '933414ee42934e8b81d8cd2226a5a13b',
611
+ // theme: 'light',
612
+ // enableCORS: false,
613
+ // maxSize: 1600,
614
+ // onSave: function(media_id, new_url) { return that.update_image(media_id, new_url); },
615
+ // onLoad: function() { that.edit_image_helper(m); }
616
+ // });
617
+ // },
614
618
 
615
- edit_image_helper: function(m)
616
- {
617
- console.log(m.image_urls.original_url);
618
- var that = this;
619
- that.feather_editor.launch({
620
- image: 'image-' + m.id,
621
- url: m.image_urls.original_url
622
- });
623
- },
619
+ // edit_image_helper: function(m)
620
+ // {
621
+ // var that = this;
622
+ // that.feather_editor.launch({
623
+ // image: 'image-' + m.id,
624
+ // url: m.image_urls.original_url
625
+ // });
626
+ // },
624
627
 
625
- update_image: function(image_id, new_url)
626
- {
627
- var that = this;
628
- var media_id = parseInt(image_id.replace('image-', ''));
628
+ // update_image: function(image_id, new_url)
629
+ // {
630
+ // var that = this;
631
+ // var media_id = parseInt(image_id.replace('image-', ''));
629
632
 
630
- that.feather_editor.showWaitIndicator();
631
- $.ajax({
632
- url: '/admin/media/' + media_id,
633
- type: 'put',
634
- data: { image_url: new_url },
635
- success: function(resp) {
636
- if(resp.error) { alert("Error saving image:\n\n" + resp.error); }
637
- if(resp.success) {
638
- that.feather_editor.hideWaitIndicator();
639
- var src = $('#image-' + media_id).attr('src').split('?')[0];
640
- $('#image-' + media_id).attr('src', src + '?' + Date.now());
641
- that.feather_editor.close();
642
- that.refresh_media();
643
- }
644
- }
645
- });
646
- return false;
647
- }
633
+ // that.feather_editor.showWaitIndicator();
634
+ // $.ajax({
635
+ // url: '/admin/media/' + media_id,
636
+ // type: 'put',
637
+ // data: { image_url: new_url },
638
+ // success: function(resp) {
639
+ // if(resp.error) { alert("Error saving image:\n\n" + resp.error); }
640
+ // if(resp.success) {
641
+ // that.feather_editor.hideWaitIndicator();
642
+ // var src = $('#image-' + media_id).attr('src').split('?')[0];
643
+ // $('#image-' + media_id).attr('src', src + '?' + Date.now());
644
+ // that.feather_editor.close();
645
+ // that.refresh_media();
646
+ // }
647
+ // }
648
+ // });
649
+ // return false;
650
+ // }
648
651
 
649
652
  };
650
653