caboose-cms 0.9.229 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +5 -5
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin/application.js +20 -0
  4. data/app/assets/javascripts/caboose/admin_main.js +13 -3
  5. data/app/assets/javascripts/caboose/admin_media_index.js +158 -161
  6. data/app/assets/javascripts/caboose/application.js +7 -8
  7. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +4 -60
  8. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +2 -3
  9. data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +6 -17
  10. data/app/assets/javascripts/caboose/model/all.js +1 -5
  11. data/app/assets/stylesheets/caboose/admin/_config.scss +102 -0
  12. data/app/assets/stylesheets/caboose/admin/application.css +11 -0
  13. data/app/assets/stylesheets/caboose/admin/component.css +183 -0
  14. data/app/assets/stylesheets/caboose/admin/froala.min.css +91 -0
  15. data/app/assets/stylesheets/caboose/admin/ie.scss +67 -0
  16. data/app/assets/stylesheets/caboose/admin/integrations/main.scss +6 -0
  17. data/app/assets/stylesheets/caboose/admin/integrations/shopify.scss +128 -0
  18. data/app/assets/stylesheets/caboose/admin/jquery-ui-subnav-theme.min.css +5 -0
  19. data/app/assets/stylesheets/caboose/admin/layout.scss +150 -0
  20. data/app/assets/stylesheets/caboose/admin/main.scss +34 -0
  21. data/app/assets/stylesheets/caboose/admin/modules/body.scss +176 -0
  22. data/app/assets/stylesheets/caboose/admin/modules/buttons.scss +120 -0
  23. data/app/assets/stylesheets/caboose/admin/modules/countdown.css +21 -0
  24. data/app/assets/stylesheets/caboose/admin/modules/crumbtrail.scss +80 -0
  25. data/app/assets/stylesheets/caboose/admin/modules/data_table.scss +92 -0
  26. data/app/assets/stylesheets/caboose/admin/modules/footer.scss +62 -0
  27. data/app/assets/stylesheets/caboose/admin/modules/forms.scss +72 -0
  28. data/app/assets/stylesheets/caboose/admin/modules/functions.scss +31 -0
  29. data/app/assets/stylesheets/caboose/admin/modules/grid.scss +108 -0
  30. data/app/assets/stylesheets/caboose/admin/modules/header.scss +77 -0
  31. data/app/assets/stylesheets/caboose/admin/modules/headings.scss +38 -0
  32. data/app/assets/stylesheets/caboose/admin/modules/main_nav.scss +73 -0
  33. data/app/assets/stylesheets/caboose/admin/modules/message_boxes.scss +55 -0
  34. data/app/assets/stylesheets/caboose/admin/modules/model_binder.scss +189 -0
  35. data/app/assets/stylesheets/caboose/admin/modules/navigation.scss +261 -0
  36. data/app/assets/stylesheets/caboose/admin/modules/order_bumps.scss +57 -0
  37. data/app/assets/stylesheets/caboose/admin/modules/pager.scss +34 -0
  38. data/app/assets/stylesheets/caboose/admin/modules/product_images.scss +21 -0
  39. data/app/assets/stylesheets/caboose/admin/modules/products.css +86 -0
  40. data/app/assets/stylesheets/caboose/admin/modules/search.scss +49 -0
  41. data/app/assets/stylesheets/caboose/admin/modules/selects.scss +12 -0
  42. data/app/assets/stylesheets/caboose/admin/modules/subnav_tabs.scss +34 -0
  43. data/app/assets/stylesheets/caboose/admin/modules/tabs.scss +140 -0
  44. data/app/assets/stylesheets/caboose/admin/page_edit/block_anchors.scss +48 -0
  45. data/app/assets/stylesheets/caboose/admin/page_edit/block_overlays.scss +182 -0
  46. data/app/assets/stylesheets/caboose/admin/page_edit/device_selector.scss +65 -0
  47. data/app/assets/stylesheets/caboose/admin/page_edit/froala.scss +81 -0
  48. data/app/assets/stylesheets/caboose/admin/page_edit/group_overlay.scss +115 -0
  49. data/app/assets/stylesheets/caboose/admin/page_edit/layout.scss +128 -0
  50. data/app/assets/stylesheets/caboose/admin/page_edit/main.scss +18 -0
  51. data/app/assets/stylesheets/caboose/admin/page_edit/modal.scss +11 -0
  52. data/app/assets/stylesheets/caboose/admin/page_edit/preview.scss +25 -0
  53. data/app/assets/stylesheets/caboose/admin/page_edit/publish.scss +25 -0
  54. data/app/assets/stylesheets/caboose/admin/page_edit/revisions.scss +58 -0
  55. data/app/assets/stylesheets/caboose/admin/page_edit/subnav.scss +273 -0
  56. data/app/assets/stylesheets/caboose/admin/page_edit/top_nav.scss +109 -0
  57. data/app/assets/stylesheets/caboose/admin/pages/assets_index.css +48 -0
  58. data/app/assets/stylesheets/caboose/admin/pages/block_edit_image.css.scss +386 -0
  59. data/app/assets/stylesheets/caboose/admin/pages/media_index.css.scss +300 -0
  60. data/app/assets/stylesheets/caboose/admin/pages/new_block.css +9 -0
  61. data/app/assets/stylesheets/caboose/admin/pages/page_edit.scss +960 -0
  62. data/app/assets/stylesheets/caboose/admin/pages/page_edit_content.scss +103 -0
  63. data/app/assets/stylesheets/caboose/admin/pages/pages_index.scss +79 -0
  64. data/app/assets/stylesheets/caboose/admin/pages/post_edit_content.css +46 -0
  65. data/app/assets/stylesheets/caboose/admin/print.css +3 -0
  66. data/app/assets/stylesheets/caboose/admin/slack.scss +51 -0
  67. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +1 -2
  68. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +15 -71
  69. data/app/assets/stylesheets/caboose/admin_main.css.scss +29 -25
  70. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +5 -26
  71. data/app/assets/stylesheets/caboose/application.css +5 -11
  72. data/app/assets/stylesheets/caboose/login.scss +0 -1
  73. data/app/assets/stylesheets/caboose/modal_main.css +19 -21
  74. data/app/assets/stylesheets/caboose/model_binder.css +4 -13
  75. data/app/assets/stylesheets/caboose/page_bar_generator.css +1 -2
  76. data/app/controllers/caboose/admin_controller.rb +4 -3
  77. data/app/controllers/caboose/application_controller.rb +19 -16
  78. data/app/controllers/caboose/assets_controller.rb +65 -0
  79. data/app/controllers/caboose/block_types_controller.rb +6 -8
  80. data/app/controllers/caboose/cart_controller.rb +2 -2
  81. data/app/controllers/caboose/fonts_controller.rb +2 -139
  82. data/app/controllers/caboose/invoices_controller.rb +4 -5
  83. data/app/controllers/caboose/login_logs_controller.rb +7 -5
  84. data/app/controllers/caboose/media_categories_controller.rb +2 -16
  85. data/app/controllers/caboose/media_controller.rb +11 -14
  86. data/app/controllers/caboose/pages_controller.rb +42 -104
  87. data/app/controllers/caboose/posts_controller.rb +7 -53
  88. data/app/controllers/caboose/products_controller.rb +1 -1
  89. data/app/controllers/caboose/sites_controller.rb +6 -25
  90. data/app/controllers/caboose/sns_controller.rb +3 -3
  91. data/app/controllers/caboose/themes_controller.rb +0 -30
  92. data/app/controllers/caboose/users_controller.rb +10 -17
  93. data/app/controllers/caboose/variants_controller.rb +9 -9
  94. data/app/models/caboose/ab_variant.rb +1 -1
  95. data/app/models/caboose/asset.rb +23 -0
  96. data/app/models/caboose/asset_manager.rb +92 -0
  97. data/app/models/caboose/asset_manifest.rb +91 -0
  98. data/app/models/caboose/block.rb +24 -100
  99. data/app/models/caboose/block_cache.rb +105 -0
  100. data/app/models/caboose/block_cache_file.rb +22 -0
  101. data/app/models/caboose/block_cache_image.rb +53 -0
  102. data/app/models/caboose/block_type.rb +3 -4
  103. data/app/models/caboose/block_type_category.rb +2 -2
  104. data/app/models/caboose/block_type_parser.rb +1 -1
  105. data/app/models/caboose/block_type_source.rb +2 -2
  106. data/app/models/caboose/calendar_event_group.rb +2 -2
  107. data/app/models/caboose/category.rb +2 -2
  108. data/app/models/caboose/comment_routes.rb +8 -7
  109. data/app/models/caboose/core_plugin.rb +3 -4
  110. data/app/models/caboose/export.rb +1 -1
  111. data/app/models/caboose/font.rb +2 -7
  112. data/app/models/caboose/font_variant.rb +0 -12
  113. data/app/models/caboose/invoice.rb +14 -14
  114. data/app/models/caboose/line_item.rb +4 -4
  115. data/app/models/caboose/media.rb +4 -15
  116. data/app/models/caboose/media_category.rb +7 -5
  117. data/app/models/caboose/modification.rb +2 -2
  118. data/app/models/caboose/page.rb +54 -325
  119. data/app/models/caboose/page_bar_generator.rb +10 -20
  120. data/app/models/caboose/page_cache.rb +12 -0
  121. data/app/models/caboose/page_cacher.rb +137 -0
  122. data/app/models/caboose/post.rb +8 -108
  123. data/app/models/caboose/product.rb +5 -5
  124. data/app/models/caboose/product_image.rb +1 -1
  125. data/app/models/caboose/role.rb +2 -2
  126. data/app/models/caboose/schema.rb +72 -73
  127. data/app/models/caboose/site.rb +1 -203
  128. data/app/models/caboose/theme.rb +5 -70
  129. data/app/views/caboose/admin/_content.html.erb +44 -0
  130. data/app/views/caboose/admin/_fonts.html.erb +47 -0
  131. data/app/views/caboose/admin/_footer.html.erb +1 -0
  132. data/app/views/caboose/admin/_header.html.erb +12 -0
  133. data/app/views/caboose/admin/_icons.html.erb +6 -0
  134. data/app/views/caboose/admin/_mobile_navigation.html.erb +22 -0
  135. data/app/views/caboose/admin/_post.html.erb +74 -0
  136. data/app/views/caboose/admin/index.html.erb +33 -36
  137. data/app/views/caboose/block_types/admin_edit.html.erb +8 -6
  138. data/app/views/caboose/blocks/_file.html.erb +2 -2
  139. data/app/views/caboose/blocks/_ga.html.erb +2 -1
  140. data/app/views/caboose/blocks/_image.html.erb +0 -4
  141. data/app/views/caboose/blocks/_render_function.html.erb +4 -9
  142. data/app/views/caboose/fonts/admin_index.html.erb +10 -55
  143. data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +14 -5
  144. data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
  145. data/app/views/caboose/media/admin_index.html.erb +24 -14
  146. data/app/views/caboose/my_account/index.html.erb +0 -1
  147. data/app/views/caboose/pages/_admin_header.html.erb +0 -5
  148. data/app/views/caboose/pages/admin_edit_content.html.erb +2 -6
  149. data/app/views/caboose/pages/admin_edit_general.html.erb +4 -32
  150. data/app/views/caboose/pages/admin_new_old.html.erb +46 -0
  151. data/app/views/caboose/pages/test.html.erb +64 -0
  152. data/app/views/caboose/posts/_admin_header.html.erb +0 -5
  153. data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
  154. data/app/views/caboose/posts/admin_edit_content.html.erb +2 -6
  155. data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
  156. data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
  157. data/app/views/caboose/sites/admin_edit.html.erb +0 -21
  158. data/app/views/caboose/themes/admin_edit.html.erb +3 -7
  159. data/app/views/caboose/users/_admin_header.html.erb +0 -4
  160. data/app/views/caboose/users/admin_edit_roles.html.erb +0 -1
  161. data/app/views/caboose/variants/admin_group.html.erb +1 -1
  162. data/app/views/layouts/caboose/admin.html.erb +2 -9
  163. data/app/views/layouts/caboose/application.html.erb +92 -62
  164. data/config/routes.rb +1 -4
  165. data/lib/caboose/version.rb +1 -1
  166. data/lib/tasks/caboose.rake +14 -3
  167. metadata +238 -57
  168. data/app/controllers/caboose/change_logs_controller.rb +0 -13
  169. data/app/models/caboose/change_log.rb +0 -97
  170. data/app/views/caboose/blocks/_cached_block.html.erb +0 -28
  171. data/app/views/caboose/change_logs/admin_index.html.erb +0 -65
  172. data/app/views/caboose/fonts/admin_family_edit.html.erb +0 -63
  173. data/app/views/caboose/fonts/admin_family_index.html.erb +0 -42
  174. data/app/views/caboose/fonts/admin_variant_edit.html.erb +0 -84
  175. data/app/views/caboose/pages/admin_change_logs.html.erb +0 -56
  176. data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
  177. data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
  178. data/app/views/caboose/posts/admin_change_logs.html.erb +0 -56
  179. data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
  180. data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
  181. data/app/views/caboose/themes/admin_error_log.html.erb +0 -9
  182. data/app/views/caboose/themes/admin_js.html.erb +0 -131
  183. data/app/views/caboose/users/admin_change_logs.html.erb +0 -63
  184. data/app/views/layouts/caboose/css.css.erb +0 -44
  185. data/app/views/layouts/caboose/footer_css.css.erb +0 -41
  186. data/app/views/layouts/caboose/footer_js.js.erb +0 -31
  187. data/app/views/layouts/caboose/js.js.erb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 121271249da78a68a31b4fd59d45251631066a87fc53b308f8b0ef8c0eabd082
4
- data.tar.gz: 2434ebfd7e93850f55da2a75320299e01c9ad778ee1b60210e0c93f218e50a92
2
+ SHA1:
3
+ metadata.gz: baac14246cad522d361a83bef4fc56834e4aa6ec
4
+ data.tar.gz: d59419b1a8984e4728df7f301a5e51c3284e5bb9
5
5
  SHA512:
6
- metadata.gz: 5189d3c36ef6c4aae4bf201d080c9e53616b2304bc2e145d2fd7e847a74f5fb08a7f7fabfb17d0d4fbac62f6441c839883d61f284f20892d876f834df6860b10
7
- data.tar.gz: 35070ab584b77c04c51590ba62aa42ec9b514c850ed81723da554d7424d8ca09361e9223dbe8e28bc65d597e9e9f23cb5c40dcc1f19fc651fd59f3d36de619b7
6
+ metadata.gz: 58d92891b8f85db3a35682cf03140055bd6929e16e6e577263643a88e86f44e6c2d4298feaa677a5c853f9c62e5f71c8bb17530730b90bc5bee4504bc90d6050
7
+ data.tar.gz: a3d136234e9b51bb59a8d95e7a1159700a66f929c198a6507717cf21e5c02bcc98f2387f84e3ae3e18ce1d58e9956611476d8362e2f8394a91bbd6f85153254f
@@ -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
@@ -0,0 +1,20 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require jquery-ui
16
+ //= require colorbox-rails
17
+ //= require caboose/jquery.datetimepicker
18
+ //= require caboose/jquery.placeholder
19
+ //= require caboose/modal_integration
20
+ //= require caboose/admin_main
@@ -1,3 +1,4 @@
1
+
1
2
  function curr(x)
2
3
  {
3
4
  if (!x) return '0.00'
@@ -14,7 +15,16 @@ function curr(x)
14
15
  function add_to_crumbtrail(href, text)
15
16
  {
16
17
  var c = $('#crumbtrail');
17
- if (!c.is(':empty'))
18
- c.append(' > ');
19
18
  c.append($('<a/>').attr('href', href).html(text));
20
- }
19
+ }
20
+
21
+ $(window).load(function() {
22
+ $("#top_nav ul.quick > li").mouseenter(function() {
23
+ $(this).find("ul").show();
24
+ $(this).children('a, span').addClass('hovered');
25
+ });
26
+ $("#top_nav ul.quick > li").mouseleave(function() {
27
+ $(this).find("ul").hide();
28
+ $(this).children('a, span').removeClass('hovered');
29
+ });
30
+ });
@@ -29,23 +29,20 @@ 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 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(); }))
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(); }))
37
34
  )
38
- .append("<div id='delete'></div>")
39
- .append("<div id='new_cat_message'></div>")
40
35
  .append($('<div/>').attr('id', 'the_uploader'));
41
36
  that.refresh();
42
37
  },
43
38
 
44
39
  refresh: function()
45
40
  {
41
+ //console.log("REFRESHING EVERYTHING");
46
42
  var that = this;
47
43
  that.refresh_categories();
48
44
  that.refresh_media();
45
+ that.print_controls();
49
46
  },
50
47
 
51
48
  refresh_categories: function(after)
@@ -67,6 +64,7 @@ MediaController.prototype = {
67
64
 
68
65
  refresh_media: function()
69
66
  {
67
+ //console.log("REFRESHING MEDIA");
70
68
  var that = this;
71
69
  $.ajax({
72
70
  url: '/admin/media/json',
@@ -90,7 +88,7 @@ MediaController.prototype = {
90
88
  sort: list
91
89
  },
92
90
  success: function(resp) {
93
- // console.log("success");
91
+ console.log("success");
94
92
  }
95
93
  });
96
94
  },
@@ -238,9 +236,10 @@ MediaController.prototype = {
238
236
  .addClass('category')
239
237
  .attr('id', 'cat' + cat.id)
240
238
  .data('media_category_id', cat.id)
241
- .append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_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')); }));
242
240
  if (cat.id == that.cat_id)
243
241
  li.addClass('selected');
242
+ // console.dir(cat);
244
243
  if (cat.name && cat.name.indexOf('Products') > -1 && product_cat_id == 0) {
245
244
  li.addClass('products-li');
246
245
  li.html('').append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); $(this).closest('#left_content').toggleClass('hide-products'); }));
@@ -248,7 +247,7 @@ MediaController.prototype = {
248
247
  }
249
248
  else if ( cat.parent_id == product_cat_id ) {
250
249
  li.addClass('product-sub-li');
251
- li.html('').append($('<a/>').attr('href', '#').html(cat.name).click(function(e) { e.preventDefault(); that.select_category($(this).parent().data('media_category_id')); }));
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')); }));
252
251
  }
253
252
  ul.append(li);
254
253
  });
@@ -256,8 +255,8 @@ MediaController.prototype = {
256
255
  else
257
256
  ul = $('<p/>').html("There are no media categories.");
258
257
  $('#categories').empty().append(ul)
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'));
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'));
261
260
 
262
261
  $.each(that.categories, function(i, cat) {
263
262
  $('#cat' + cat.id).droppable({
@@ -291,49 +290,34 @@ MediaController.prototype = {
291
290
  $('#cat' + cat.id).draggable({ revert: 'invalid' });
292
291
  });
293
292
  },
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
- // },
309
293
 
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')));
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')));
315
299
 
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
- // },
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
+ },
337
321
 
338
322
  print_media: function()
339
323
  {
@@ -358,13 +342,8 @@ MediaController.prototype = {
358
342
  if (m.original_name && m.original_name.indexOf('png') > 0) {
359
343
  li.addClass("png");
360
344
  }
361
- //console.log("original_name: " + m.original_name);
362
345
  if (m.image_urls)
363
346
  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
- // }
368
347
  else if (m.original_name) {
369
348
  var ext = m.original_name.match(/\.[0-9a-z]+$/i);
370
349
  li.addClass('empty');
@@ -375,19 +354,22 @@ MediaController.prototype = {
375
354
  li.addClass('selected ui-selected');
376
355
  var btndiv = $("<div/>").addClass("buttons");
377
356
  li.append(btndiv);
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')); }));
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')); }));
384
361
  ul.append(li);
385
362
  });
386
363
  }
387
364
  else
388
365
  ul = $('<p/>').html("This category is empty.");
389
366
  $('#media').empty().append(ul);
390
- if (that.refresh_unprocessed_images == true && processing) { setTimeout(function() { that.check_processing_status(); }, 3000); }
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
+
391
373
  $.each(that.media, function(i, m) {
392
374
  $('li.media').draggable({
393
375
  multiple: true,
@@ -395,6 +377,7 @@ MediaController.prototype = {
395
377
  start: function() { $(this).data("origPosition", $(this).position()); }
396
378
  });
397
379
  });
380
+ // $("#media ul").sortable();
398
381
  },
399
382
 
400
383
  //============================================================================
@@ -448,37 +431,58 @@ MediaController.prototype = {
448
431
  delete_media: function(confirm)
449
432
  {
450
433
  var that = this;
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)
434
+ if (!confirm)
456
435
  {
457
- // $.each(that.selected_media, function(i, id) {
458
- // $('#media' + id).css('top', '0').css('left', '0');
459
- // });
436
+ $.each(that.selected_media, function(i, id) {
437
+ $('#media' + id).css('top', '0').css('left', '0');
438
+ });
460
439
  var div = $('<p/>').addClass('note error')
461
- .append('Are you sure you want to delete the selected ' + that.selected_media.length + ' files?&nbsp;&nbsp;')
440
+ .append('Are you sure?<br/>')
462
441
  .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_media(true); })).append(" ")
463
- .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_media(); $('#delete').empty(); }));
442
+ .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_media(); that.print_controls(); }));
464
443
  $('#delete').empty().append(div);
465
444
  return;
466
445
  }
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
- }
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
+ });
476
453
  },
477
454
 
478
455
  edit_media_description: function(media_id)
479
456
  {
480
457
  var that = this;
481
458
  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);
482
486
  },
483
487
 
484
488
  //============================================================================
@@ -498,14 +502,14 @@ MediaController.prototype = {
498
502
  if (!name)
499
503
  {
500
504
  var div = $('<p/>').addClass('note warning')
501
- .append('New category name:&nbsp;&nbsp;')
505
+ .append('New Category Name: ')
502
506
  .append($('<input/>').attr('type', 'text').attr('id', 'new_cat_name')).append(" ")
503
507
  .append($('<input/>').attr('type', 'button').val('Add').click(function() { that.add_category($('#new_cat_name').val()); })).append(" ")
504
508
  .append($('<input/>').attr('type', 'button').val('Cancel').click(function() { $('#new_cat_message').empty(); }));
505
509
  $('#new_cat_message').empty().append(div);
506
510
  return;
507
511
  }
508
- $('#new_cat_message').empty().html("<p class='note loading'>Adding category...</p>");
512
+ $('#new_cat_message').empty().html("<p class='loading'>Adding category...</p>");
509
513
  $.ajax({
510
514
  url: '/admin/media-categories',
511
515
  type: 'post',
@@ -516,7 +520,6 @@ MediaController.prototype = {
516
520
  success: function(resp) {
517
521
  if (resp.error) $('#new_cat_message').empty().html("<p class='note error'>" + resp.error + "</p>");
518
522
  if (resp.refresh) that.refresh_categories();
519
- $('#new_cat_message').empty();
520
523
  }
521
524
  });
522
525
  },
@@ -524,38 +527,31 @@ MediaController.prototype = {
524
527
  delete_category: function(cat_id, confirm)
525
528
  {
526
529
  var that = this;
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)
530
+ if (!confirm)
532
531
  {
533
532
  var div = $('<p/>').addClass('note warning')
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;')
533
+ .append('Are you sure? ')
535
534
  .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_category(cat_id, true); })).append(" ")
536
- .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_categories(); $('#delete').empty(); }));
535
+ .append($('<input/>').attr('type', 'button').val('No' ).click(function() { that.refresh_categories(); that.print_controls() }));
537
536
  $('#delete').empty().append(div);
538
537
  return;
539
538
  }
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
-
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
+ });
559
555
  },
560
556
 
561
557
  media_with_id: function(media_id)
@@ -596,58 +592,59 @@ MediaController.prototype = {
596
592
  // Aviary
597
593
  //============================================================================
598
594
 
599
- // edit_image: function(media_id)
600
- // {
601
- // var that = this;
602
- // var m = that.media_with_id(media_id);
595
+ edit_image: function(media_id)
596
+ {
597
+ var that = this;
598
+ var m = that.media_with_id(media_id);
603
599
 
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
- // },
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
+ },
618
614
 
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
- // },
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
+ },
627
624
 
628
- // update_image: function(image_id, new_url)
629
- // {
630
- // var that = this;
631
- // var media_id = parseInt(image_id.replace('image-', ''));
625
+ update_image: function(image_id, new_url)
626
+ {
627
+ var that = this;
628
+ var media_id = parseInt(image_id.replace('image-', ''));
632
629
 
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
- // }
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
+ }
651
648
 
652
649
  };
653
650