rails_admin 2.0.0.beta → 2.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_admin might be problematic. Click here for more details.

Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +1 -1
  4. data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
  5. data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +1 -1
  6. data/app/assets/javascripts/rails_admin/ra.i18n.js +28 -0
  7. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +57 -0
  8. data/app/assets/javascripts/rails_admin/ra.sidescroll.js +31 -0
  9. data/app/assets/javascripts/rails_admin/ra.widgets.js +371 -0
  10. data/app/assets/javascripts/rails_admin/ui.js +135 -0
  11. data/app/assets/stylesheets/rails_admin/ra.widgets.scss +4 -0
  12. data/app/helpers/rails_admin/application_helper.rb +17 -2
  13. data/app/views/layouts/rails_admin/_head.html.haml +7 -0
  14. data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -1
  15. data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +2 -1
  16. data/app/views/layouts/rails_admin/application.html.haml +3 -8
  17. data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -3
  18. data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +6 -4
  19. data/config/locales/rails_admin.en.yml +1 -0
  20. data/lib/generators/rails_admin/templates/initializer.erb +2 -2
  21. data/lib/rails_admin.rb +0 -1
  22. data/lib/rails_admin/abstract_model.rb +1 -1
  23. data/lib/rails_admin/adapters/active_record.rb +12 -3
  24. data/lib/rails_admin/adapters/mongoid.rb +14 -0
  25. data/lib/rails_admin/bootstrap-sass.rb +1 -1
  26. data/lib/rails_admin/config.rb +4 -6
  27. data/lib/rails_admin/config/actions/base.rb +17 -1
  28. data/lib/rails_admin/config/actions/edit.rb +1 -3
  29. data/lib/rails_admin/config/actions/index.rb +1 -1
  30. data/lib/rails_admin/config/actions/new.rb +1 -3
  31. data/lib/rails_admin/config/fields.rb +0 -1
  32. data/lib/rails_admin/config/fields/association.rb +1 -1
  33. data/lib/rails_admin/config/fields/types/action_text.rb +1 -2
  34. data/lib/rails_admin/config/fields/types/all.rb +0 -1
  35. data/lib/rails_admin/config/fields/types/ck_editor.rb +2 -2
  36. data/lib/rails_admin/config/fields/types/code_mirror.rb +2 -2
  37. data/lib/rails_admin/config/fields/types/color.rb +2 -2
  38. data/lib/rails_admin/config/fields/types/file_upload.rb +6 -2
  39. data/lib/rails_admin/config/fields/types/froala.rb +2 -2
  40. data/lib/rails_admin/config/fields/types/hidden.rb +2 -2
  41. data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +1 -1
  42. data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +15 -3
  43. data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +17 -3
  44. data/lib/rails_admin/config/fields/types/polymorphic_association.rb +7 -0
  45. data/lib/rails_admin/config/fields/types/shrine.rb +5 -1
  46. data/lib/rails_admin/config/fields/types/simple_mde.rb +2 -2
  47. data/lib/rails_admin/config/fields/types/string.rb +2 -2
  48. data/lib/rails_admin/config/fields/types/string_like.rb +19 -0
  49. data/lib/rails_admin/config/fields/types/text.rb +2 -2
  50. data/lib/rails_admin/config/fields/types/wysihtml5.rb +2 -2
  51. data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +45 -21
  52. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +4 -1
  53. data/lib/rails_admin/version.rb +1 -1
  54. data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings-white.png +0 -0
  55. data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings.png +0 -0
  56. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
  57. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
  58. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
  59. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
  60. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
  61. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
  62. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
  63. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
  64. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
  65. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
  66. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
  67. data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
  68. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
  69. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
  70. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
  71. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
  72. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
  73. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
  74. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
  75. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
  76. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
  77. data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
  78. data/{app → vendor}/assets/images/rails_admin/colorpicker/select.png +0 -0
  79. data/{app → vendor}/assets/images/rails_admin/colorpicker/select2.png +0 -0
  80. data/{app → vendor}/assets/images/rails_admin/colorpicker/slider.png +0 -0
  81. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +0 -0
  82. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +0 -0
  83. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +0 -0
  84. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +0 -0
  85. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +0 -0
  86. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +0 -0
  87. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +0 -0
  88. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +0 -0
  89. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +0 -0
  90. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +0 -0
  91. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +0 -0
  92. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +0 -0
  93. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-typeahead.js +0 -0
  94. data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap.js +0 -0
  95. data/{app → vendor}/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -0
  96. data/{app → vendor}/assets/javascripts/rails_admin/jquery.pjax.js +0 -0
  97. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_alerts.scss +0 -0
  98. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_badges.scss +0 -0
  99. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_breadcrumbs.scss +0 -0
  100. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_button-groups.scss +0 -0
  101. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_buttons.scss +0 -0
  102. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_carousel.scss +0 -0
  103. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_close.scss +0 -0
  104. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_code.scss +0 -0
  105. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_component-animations.scss +0 -0
  106. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_dropdowns.scss +0 -0
  107. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_forms.scss +0 -0
  108. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_glyphicons.scss +0 -0
  109. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_grid.scss +0 -0
  110. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_input-groups.scss +0 -0
  111. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_jumbotron.scss +0 -0
  112. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_labels.scss +0 -0
  113. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_list-group.scss +0 -0
  114. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_media.scss +0 -0
  115. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_mixins.scss +0 -0
  116. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_modals.scss +0 -0
  117. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navbar.scss +0 -0
  118. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navs.scss +0 -0
  119. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_normalize.scss +0 -0
  120. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pager.scss +0 -0
  121. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pagination.scss +0 -0
  122. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_panels.scss +0 -0
  123. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_popovers.scss +0 -0
  124. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_print.scss +0 -0
  125. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_progress-bars.scss +0 -0
  126. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-embed.scss +0 -0
  127. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-utilities.scss +0 -0
  128. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_scaffolding.scss +0 -0
  129. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tables.scss +0 -0
  130. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_theme.scss +0 -0
  131. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_thumbnails.scss +0 -0
  132. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tooltip.scss +0 -0
  133. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_type.scss +0 -0
  134. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_utilities.scss +0 -0
  135. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_variables.scss +0 -0
  136. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_wells.scss +0 -0
  137. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/bootstrap.scss +0 -0
  138. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_alerts.scss +0 -0
  139. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_background-variant.scss +0 -0
  140. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_border-radius.scss +0 -0
  141. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_buttons.scss +0 -0
  142. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_center-block.scss +0 -0
  143. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss +0 -0
  144. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_forms.scss +0 -0
  145. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_gradients.scss +0 -0
  146. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid-framework.scss +0 -0
  147. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid.scss +0 -0
  148. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_hide-text.scss +0 -0
  149. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss +0 -0
  150. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_labels.scss +0 -0
  151. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss +0 -0
  152. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-divider.scss +0 -0
  153. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-vertical-align.scss +0 -0
  154. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_opacity.scss +0 -0
  155. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss +0 -0
  156. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_panels.scss +0 -0
  157. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_progress-bar.scss +0 -0
  158. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-filter.scss +0 -0
  159. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss +0 -0
  160. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_responsive-visibility.scss +0 -0
  161. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_size.scss +0 -0
  162. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_tab-focus.scss +0 -0
  163. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_table-row.scss +0 -0
  164. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-emphasis.scss +0 -0
  165. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-overflow.scss +0 -0
  166. data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_vendor-prefixes.scss +0 -0
  167. data/{app → vendor}/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -0
  168. metadata +130 -153
  169. data/app/assets/javascripts/rails_admin/custom/ui.coffee +0 -1
  170. data/app/assets/javascripts/rails_admin/ra.i18n.coffee +0 -10
  171. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +0 -55
  172. data/app/assets/javascripts/rails_admin/ra.sidescroll.coffee +0 -19
  173. data/app/assets/javascripts/rails_admin/ra.widgets.coffee +0 -359
  174. data/app/assets/javascripts/rails_admin/ui.coffee +0 -107
  175. data/lib/rails_admin/config/fields/factories/refile.rb +0 -25
  176. data/lib/rails_admin/config/fields/types/refile.rb +0 -27
  177. data/lib/rails_admin/extensions/cancan.rb +0 -3
  178. data/lib/rails_admin/extensions/cancan/authorization_adapter.rb +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 286d5b253a622e6ece58238f4b18544e53e0650f427ba1f0f4d4b3b880a46032
4
- data.tar.gz: 21b11784af9577e8823db1fe56f4e87a187c962d632788e61ced23ea9af99214
3
+ metadata.gz: 1b0f4ab7caf68837692964e8e69e90d167282dafa55a35aaaa3d76eb93f97b9d
4
+ data.tar.gz: 9a6407f79b492dffafd49568675b7982122c76e080519c0f6b3156abbeb3e71a
5
5
  SHA512:
6
- metadata.gz: 2e89158a576546098a11cf0c660f84a43130bbc69e57d592e68e65a3adce27461e811c93649a9624632d1299d10cabbdce06ff41ecb90119f42c488dc6f95f46
7
- data.tar.gz: e5944858dd931bc962e2c4a3b64117464c6ef118c9bc322c4ab9c54e5103b2d07972b3f50513b59b7d50e30ca19e05839cb58a93882b81425538d3be2eb37246
6
+ metadata.gz: 127e444d5dee93ccb6cd28c210368bc143d06732f5683917b0b969eac3717a3a606d5415891d5e768385cc3fd445ce2d754c39f97daec21b50ee49595a5ecde2
7
+ data.tar.gz: 14ff533ab2205b78c5d3529bd0b16166af4b2ad54547c6c67d20ffde399ed17defe559dc53c7e34a3c3457ef16bf4de8b4122211c6ea663090946ca84e687380
data/Gemfile CHANGED
@@ -19,7 +19,7 @@ group :development, :test do
19
19
  end
20
20
 
21
21
  group :test do
22
- gem 'carrierwave', '>= 0.8'
22
+ gem 'carrierwave', ['>= 2.0.0.rc', '< 3']
23
23
  gem 'coveralls'
24
24
  gem 'database_cleaner', ['>= 1.2', '!= 1.4.0', '!= 1.5.0']
25
25
  gem 'dragonfly', '~> 1.0'
data/README.md CHANGED
@@ -50,7 +50,7 @@ RailsAdmin is a Rails engine that provides an easy-to-use interface for managing
50
50
 
51
51
  ## Installation
52
52
 
53
- 1. On your gemfile: `gem 'rails_admin', '~> 2.0.0.beta'`
53
+ 1. On your gemfile: `gem 'rails_admin', '~> 2.0.0.rc'`
54
54
  2. Run `bundle install`
55
55
  3. Run `rails g rails_admin:install`
56
56
  4. Provide a namespace for the routes when asked
@@ -0,0 +1 @@
1
+ // override this file in your application to add custom behaviour
@@ -118,7 +118,7 @@
118
118
 
119
119
  /* Add all to selection */
120
120
  this.addAll.click(function(e){
121
- widget._select($('option', widget.collection));
121
+ widget._select($('option:not(:disabled)', widget.collection));
122
122
  e.preventDefault();
123
123
  widget.selection.trigger('change');
124
124
  });
@@ -0,0 +1,28 @@
1
+ (function() {
2
+ var Locale;
3
+
4
+ this.RailsAdmin || (this.RailsAdmin = {});
5
+
6
+ this.RailsAdmin.I18n = Locale = (function() {
7
+ function Locale() {}
8
+
9
+ Locale.init = function(locale, translations) {
10
+ this.locale = locale;
11
+ this.translations = translations;
12
+ moment.locale(this.locale);
13
+ if (typeof this.translations === "string") {
14
+ this.translations = JSON.parse(this.translations);
15
+ }
16
+ };
17
+
18
+ Locale.t = function(key) {
19
+ var humanize;
20
+ humanize = key.charAt(0).toUpperCase() + key.replace(/_/g, " ").slice(1);
21
+ return this.translations[key] || humanize;
22
+ };
23
+
24
+ return Locale;
25
+
26
+ })();
27
+
28
+ }).call(this);
@@ -0,0 +1,57 @@
1
+ (function($) {
2
+ $(document).ready(function() {
3
+ return window.nestedFormEvents.insertFields = function(content, assoc, link) {
4
+ var tab_content;
5
+ tab_content = $(link).closest(".controls").siblings(".tab-content");
6
+ tab_content.append(content);
7
+ return tab_content.children().last();
8
+ };
9
+ });
10
+
11
+ $(document).on('nested:fieldAdded', 'form', function(content) {
12
+ var controls, field, nav, new_tab, one_to_one, parent_group, toggler;
13
+ field = content.field.addClass('tab-pane').attr('id', 'unique-id-' + (new Date().getTime()));
14
+ new_tab = $('<li><a data-toggle="tab" href="#' + field.attr('id') + '">' + field.children('.object-infos').data('object-label') + '</a></li>');
15
+ parent_group = field.closest('.control-group');
16
+ controls = parent_group.children('.controls');
17
+ one_to_one = controls.data('nestedone') !== void 0;
18
+ nav = controls.children('.nav');
19
+ content = parent_group.children('.tab-content');
20
+ toggler = controls.find('.toggler');
21
+ nav.append(new_tab);
22
+ $(window.document).trigger('rails_admin.dom_ready', [field, parent_group]);
23
+ new_tab.children('a').tab('show');
24
+ if (!one_to_one) {
25
+ nav.select(':hidden').show('slow');
26
+ }
27
+ content.select(':hidden').show('slow');
28
+ toggler.addClass('active').removeClass('disabled').children('i').addClass('icon-chevron-down').removeClass('icon-chevron-right');
29
+ if (one_to_one) {
30
+ controls.find('.add_nested_fields').removeClass('add_nested_fields').html(field.children('.object-infos').data('object-label'));
31
+ }
32
+ });
33
+
34
+ $(document).on('nested:fieldRemoved', 'form', function(content) {
35
+ var add_button, controls, current_li, field, nav, one_to_one, parent_group, toggler;
36
+ field = content.field;
37
+ nav = field.closest(".control-group").children('.controls').children('.nav');
38
+ current_li = nav.children('li').has('a[href="#' + field.attr('id') + '"]');
39
+ parent_group = field.closest(".control-group");
40
+ controls = parent_group.children('.controls');
41
+ one_to_one = controls.data('nestedone') !== void 0;
42
+ toggler = controls.find('.toggler');
43
+ (current_li.next().length ? current_li.next() : current_li.prev()).children('a:first').tab('show');
44
+ current_li.remove();
45
+ if (nav.children().length === 0) {
46
+ nav.select(':visible').hide('slow');
47
+ toggler.removeClass('active').addClass('disabled').children('i').removeClass('icon-chevron-down').addClass('icon-chevron-right');
48
+ }
49
+ if (one_to_one) {
50
+ add_button = toggler.next();
51
+ add_button.addClass('add_nested_fields').html(add_button.data('add-label'));
52
+ }
53
+ field.find('[required]').each(function() {
54
+ $(this).removeAttr('required');
55
+ });
56
+ });
57
+ }(jQuery));
@@ -0,0 +1,31 @@
1
+ (function($) {
2
+ function setFrozenColPositions() {
3
+ var $listForm, frozenColumns;
4
+
5
+ $listForm = $('#bulk_form');
6
+ if (!$listForm.is('.ra-sidescroll')) {
7
+ return;
8
+ }
9
+ frozenColumns = $listForm.data('ra-sidescroll');
10
+
11
+ $listForm.find('table tr').each(function(index, tr) {
12
+ var firstPosition = 0;
13
+
14
+ $(tr).children().slice(0, frozenColumns).each(function(idx, td) {
15
+ var tdLeft;
16
+ $(td).addClass('ra-sidescroll-frozen');
17
+ if (idx === frozenColumns - 1) {
18
+ $(td).addClass('last-of-frozen');
19
+ }
20
+ tdLeft = $(td).position().left;
21
+ if (idx === 0) {
22
+ firstPosition = tdLeft;
23
+ }
24
+ td.style.left = (tdLeft - firstPosition) + "px";
25
+ });
26
+ });
27
+ };
28
+
29
+ $(window).on('load', setFrozenColPositions);
30
+ $(document).on('rails_admin.dom_ready', setFrozenColPositions);
31
+ })(jQuery);
@@ -0,0 +1,371 @@
1
+ (function($) {
2
+ $(document).on('rails_admin.dom_ready', function(e, content) {
3
+ var $editors, array, config_options, goBootstrapWysihtml5s, goCkeditors, goCodeMirrors, goFroalaWysiwygs, goSimpleMDEs, options;
4
+ content = content ? content : $('form');
5
+ if (content.length) {
6
+ content.find('[data-color]').each(function() {
7
+ var that;
8
+ that = this;
9
+ return $(this).ColorPicker({
10
+ color: $(that).val(),
11
+ onShow: function(el) {
12
+ $(el).fadeIn(500);
13
+ return false;
14
+ },
15
+ onHide: function(el) {
16
+ $(el).fadeOut(500);
17
+ return false;
18
+ },
19
+ onChange: function(hsb, hex, rgb) {
20
+ $(that).val(hex);
21
+ $(that).css('backgroundColor', '#' + hex);
22
+ }
23
+ });
24
+ });
25
+ $.fn.datetimepicker.defaults.icons = {
26
+ time: 'fa fa-clock-o',
27
+ date: 'fa fa-calendar',
28
+ up: 'fa fa-chevron-up',
29
+ down: 'fa fa-chevron-down',
30
+ previous: 'fa fa-angle-double-left',
31
+ next: 'fa fa-angle-double-right',
32
+ today: 'fa fa-dot-circle-o',
33
+ clear: 'fa fa-trash',
34
+ close: 'fa fa-times'
35
+ };
36
+ content.find('[data-datetimepicker]').each(function() {
37
+ var options;
38
+ options = $(this).data('options');
39
+ $.extend(options, {
40
+ locale: RailsAdmin.I18n.locale
41
+ });
42
+ $(this).datetimepicker(options);
43
+ });
44
+ content.find('[data-enumeration]').each(function() {
45
+ if ($(this).is('[multiple]')) {
46
+ $(this).filteringMultiselect($(this).data('options'));
47
+ } else {
48
+ $(this).filteringSelect($(this).data('options'));
49
+ }
50
+ });
51
+ content.find('[data-fileupload]').each(function() {
52
+ var parent;
53
+ parent = $(this).closest('.controls');
54
+ parent.find('.btn-remove-image').on('click', function() {
55
+ $(this).siblings('[type=checkbox]').click();
56
+ parent.find('.toggle').toggle('slow');
57
+ $(this).toggleClass('btn-danger btn-info');
58
+ return false;
59
+ });
60
+ });
61
+ content.find('[data-fileupload]').change(function() {
62
+ var ext, image_container, input, reader;
63
+ input = this;
64
+ image_container = $("#" + input.id).parent().children(".preview");
65
+ if (!image_container.length) {
66
+ image_container = $("#" + input.id).parent().prepend($('<img />').addClass('preview').addClass('img-thumbnail')).find('img.preview');
67
+ image_container.parent().find('img:not(.preview)').hide();
68
+ }
69
+ ext = $("#" + input.id).val().split('.').pop().toLowerCase();
70
+ if (input.files && input.files[0] && $.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) !== -1) {
71
+ reader = new FileReader();
72
+ reader.onload = function(e) {
73
+ image_container.attr("src", e.target.result);
74
+ };
75
+ reader.readAsDataURL(input.files[0]);
76
+ image_container.show();
77
+ } else {
78
+ image_container.hide();
79
+ }
80
+ });
81
+ content.find('[data-multiple-fileupload]').each(function() {
82
+ $(this).closest('.controls').find('.btn-remove-image').on('click', function() {
83
+ $(this).siblings('[type=checkbox]').click();
84
+ $(this).parent('.toggle').toggle('slow');
85
+ $(this).toggleClass('btn-danger btn-info');
86
+ return false;
87
+ }).end().sortable({
88
+ items: '.sortables'
89
+ });
90
+ });
91
+ content.find('[data-multiple-fileupload]').change(function() {
92
+ var ext, file, i, image_container, input, len, ref, results;
93
+ input = this;
94
+ $("#" + input.id).parent().children(".preview").remove();
95
+ ref = input.files;
96
+ results = [];
97
+ for (i = 0, len = ref.length; i < len; i++) {
98
+ file = ref[i];
99
+ ext = file.name.split('.').pop().toLowerCase();
100
+ if ($.inArray(ext, ['gif', 'png', 'jpg', 'jpeg', 'bmp']) === -1) {
101
+ continue;
102
+ }
103
+ image_container = $('<img />').addClass('preview').addClass('img-thumbnail');
104
+ results.push((function(image_container) {
105
+ var reader;
106
+ reader = new FileReader();
107
+ reader.onload = function(e) {
108
+ image_container.attr("src", e.target.result);
109
+ };
110
+ reader.readAsDataURL(file);
111
+ return $("#" + input.id).parent().append($('<div></div>').addClass('preview').append(image_container));
112
+ })(image_container));
113
+ }
114
+ return results;
115
+ });
116
+ content.find('[data-filteringmultiselect]').each(function() {
117
+ $(this).filteringMultiselect($(this).data('options'));
118
+ if ($(this).parents("#modal").length) {
119
+ $(this).siblings('.btn').remove();
120
+ } else {
121
+ $(this).parents('.control-group').first().remoteForm();
122
+ }
123
+ });
124
+ content.find('[data-filteringselect]').each(function() {
125
+ $(this).filteringSelect($(this).data('options'));
126
+ if ($(this).parents("#modal").length) {
127
+ $(this).siblings('.btn').remove();
128
+ } else {
129
+ $(this).parents('.control-group').first().remoteForm();
130
+ }
131
+ });
132
+ content.find('[data-nestedmany]').each(function() {
133
+ var field, nav, tab_content, toggler;
134
+ field = $(this).parents('.control-group').first();
135
+ nav = field.find('> .controls > .nav');
136
+ tab_content = field.find('> .tab-content');
137
+ toggler = field.find('> .controls > .btn-group > .toggler');
138
+ tab_content.children('.fields:not(.tab-pane)').addClass('tab-pane').each(function() {
139
+ $(this).attr('id', 'unique-id-' + (new Date().getTime()) + Math.floor(Math.random() * 100000));
140
+ nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>');
141
+ });
142
+ if (nav.find("> li.active").length === 0) {
143
+ nav.find("> li > a[data-toggle='tab']:first").tab('show');
144
+ }
145
+ if (nav.children().length === 0) {
146
+ nav.hide();
147
+ tab_content.hide();
148
+ toggler.addClass('disabled').removeClass('active').children('i').addClass('icon-chevron-right');
149
+ } else {
150
+ if (toggler.hasClass('active')) {
151
+ nav.show();
152
+ tab_content.show();
153
+ toggler.children('i').addClass('icon-chevron-down');
154
+ } else {
155
+ nav.hide();
156
+ tab_content.hide();
157
+ toggler.children('i').addClass('icon-chevron-right');
158
+ }
159
+ }
160
+ });
161
+ content.find('[data-nestedone]').each(function() {
162
+ var field, first_tab, nav, tab_content, toggler;
163
+ field = $(this).parents('.control-group').first();
164
+ nav = field.find("> .controls > .nav");
165
+ tab_content = field.find("> .tab-content");
166
+ toggler = field.find('> .controls > .btn-group > .toggler');
167
+ tab_content.children(".fields:not(.tab-pane)").addClass('tab-pane active').each(function() {
168
+ field.find('> .controls .add_nested_fields').removeClass('add_nested_fields').html($(this).children('.object-infos').data('object-label'));
169
+ nav.append('<li><a data-toggle="tab" href="#' + this.id + '">' + $(this).children('.object-infos').data('object-label') + '</a></li>');
170
+ });
171
+ first_tab = nav.find("> li > a[data-toggle='tab']:first");
172
+ first_tab.tab('show');
173
+ field.find("> .controls > [data-target]:first").html('<i class="icon-white"></i> ' + first_tab.html());
174
+ nav.hide();
175
+ if (nav.children().length === 0) {
176
+ nav.hide();
177
+ tab_content.hide();
178
+ toggler.addClass('disabled').removeClass('active').children('i').addClass('icon-chevron-right');
179
+ } else {
180
+ if (toggler.hasClass('active')) {
181
+ toggler.children('i').addClass('icon-chevron-down');
182
+ tab_content.show();
183
+ } else {
184
+ toggler.children('i').addClass('icon-chevron-right');
185
+ tab_content.hide();
186
+ }
187
+ }
188
+ });
189
+ content.find('[data-polymorphic]').each(function() {
190
+ var field, object_select, type_select, urls;
191
+ type_select = $(this);
192
+ field = type_select.parents('.control-group').first();
193
+ object_select = field.find('select').last();
194
+ urls = type_select.data('urls');
195
+ type_select.on('change', function(e) {
196
+ var selected_data, selected_type;
197
+ selected_type = type_select.val().toLowerCase();
198
+ selected_data = $("#" + selected_type + "-js-options").data('options');
199
+ object_select.data('options', selected_data);
200
+ object_select.filteringSelect("destroy");
201
+ object_select.filteringSelect(selected_data);
202
+ });
203
+ });
204
+ goSimpleMDEs = function() {
205
+ return content.find('[data-richtext=simplemde]').not('.simplemded').each(function(index, domEle) {
206
+ var instance_config, options;
207
+ options = $(this).data('options');
208
+ instance_config = options.instance_config;
209
+ new window.SimpleMDE($.extend(true, {
210
+ element: document.getElementById(this.id),
211
+ autosave: {
212
+ uniqueId: this.id
213
+ }
214
+ }, instance_config));
215
+ $(this).addClass('simplemded');
216
+ });
217
+ };
218
+ $editors = content.find('[data-richtext=simplemde]').not('.simplemded');
219
+ if ($editors.length) {
220
+ if (!window.SimpleMDE) {
221
+ options = $editors.first().data('options');
222
+ $('head').append('<link href="' + options['css_location'] + '" rel="stylesheet" media="all" type="text\/css">');
223
+ $.getScript(options['js_location'], function(script, textStatus, jqXHR) {
224
+ return goSimpleMDEs();
225
+ });
226
+ } else {
227
+ goSimpleMDEs();
228
+ }
229
+ }
230
+ goCkeditors = function() {
231
+ return content.find('[data-richtext=ckeditor]').not('.ckeditored').each(function(index, domEle) {
232
+ var instance;
233
+ try {
234
+ if (instance = window.CKEDITOR.instances[this.id]) {
235
+ instance.destroy(true);
236
+ }
237
+ } catch (error1) {}
238
+ window.CKEDITOR.replace(this, $(this).data('options').options);
239
+ $(this).addClass('ckeditored');
240
+ });
241
+ };
242
+ $editors = content.find('[data-richtext=ckeditor]').not('.ckeditored');
243
+ if ($editors.length) {
244
+ if (!window.CKEDITOR) {
245
+ options = $editors.first().data('options');
246
+ window.CKEDITOR_BASEPATH = options['base_location'];
247
+ $.getScript(options['jspath'], (function(_this) {
248
+ return function(script, textStatus, jqXHR) {
249
+ return goCkeditors();
250
+ };
251
+ })(this));
252
+ } else {
253
+ goCkeditors();
254
+ }
255
+ }
256
+ goCodeMirrors = (function(_this) {
257
+ return function(array) {
258
+ return array.each(function(index, domEle) {
259
+ var textarea;
260
+ options = $(this).data('options');
261
+ textarea = this;
262
+ $.getScript(options['locations']['mode'], function(script, textStatus, jqXHR) {
263
+ options = $(domEle).data('options');
264
+ $('head').append('<link href="' + options['locations']['theme'] + '" rel="stylesheet" media="all" type="text\/css">');
265
+ CodeMirror.fromTextArea(textarea, options['options']);
266
+ return $(textarea).addClass('codemirrored');
267
+ });
268
+ });
269
+ };
270
+ })(this);
271
+ array = content.find('[data-richtext=codemirror]').not('.codemirrored');
272
+ if (array.length) {
273
+ this.array = array;
274
+ if (!window.CodeMirror) {
275
+ options = $(array[0]).data('options');
276
+ $('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">');
277
+ $.getScript(options['jspath'], (function(_this) {
278
+ return function(script, textStatus, jqXHR) {
279
+ return goCodeMirrors(_this.array);
280
+ };
281
+ })(this));
282
+ } else {
283
+ goCodeMirrors(this.array);
284
+ }
285
+ }
286
+ goBootstrapWysihtml5s = (function(_this) {
287
+ return function(array, config_options) {
288
+ return array.each(function() {
289
+ $(this).addClass('bootstrap-wysihtml5ed');
290
+ $(this).closest('.controls').addClass('well');
291
+ $(this).wysihtml5(config_options);
292
+ });
293
+ };
294
+ })(this);
295
+ array = content.find('[data-richtext=bootstrap-wysihtml5]').not('.bootstrap-wysihtml5ed');
296
+ if (array.length) {
297
+ this.array = array;
298
+ options = $(array[0]).data('options');
299
+ config_options = $.parseJSON(options['config_options']);
300
+ if (!window.wysihtml5) {
301
+ $('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">');
302
+ $.getScript(options['jspath'], (function(_this) {
303
+ return function(script, textStatus, jqXHR) {
304
+ return goBootstrapWysihtml5s(_this.array, config_options);
305
+ };
306
+ })(this));
307
+ } else {
308
+ goBootstrapWysihtml5s(this.array, config_options);
309
+ }
310
+ }
311
+ goFroalaWysiwygs = (function(_this) {
312
+ return function(array) {
313
+ return array.each(function() {
314
+ var uploadEnabled;
315
+ options = $(this).data('options');
316
+ config_options = $.parseJSON(options['config_options']);
317
+ if (config_options) {
318
+ if (!config_options['inlineMode']) {
319
+ config_options['inlineMode'] = false;
320
+ }
321
+ } else {
322
+ config_options = {
323
+ inlineMode: false
324
+ };
325
+ }
326
+ uploadEnabled = config_options['imageUploadURL'] ? config_options['imageUploadParams'] = {
327
+ authenticity_token: $('meta[name=csrf-token]').attr('content')
328
+ } : void 0;
329
+ $(this).addClass('froala-wysiwyged');
330
+ $(this).froalaEditor(config_options);
331
+ if (uploadEnabled) {
332
+ $(this).on('froalaEditor.image.error', function(e, editor, error) {
333
+ alert("error uploading image: " + error.message);
334
+ }).on('froalaEditor.image.removed', function(e, editor, $img) {
335
+ editor.options.imageDeleteParams = {
336
+ src: $img.attr('src'),
337
+ authenticity_token: $('meta[name=csrf-token]').attr('content')
338
+ };
339
+ editor.deleteImage($img);
340
+ }).on('editable.imageDeleteSuccess', function(e, editor, data) {}).on('editable.imageDeleteError', function(e, editor, error) {
341
+ alert("error deleting image: " + error.message);
342
+ });
343
+ }
344
+ });
345
+ };
346
+ })(this);
347
+ array = content.find('[data-richtext=froala-wysiwyg]').not('.froala-wysiwyged');
348
+ if (array.length) {
349
+ options = $(array[0]).data('options');
350
+ if (!$.isFunction($.fn.editable)) {
351
+ $('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">');
352
+ $.getScript(options['jspath'], (function(_this) {
353
+ return function(script, textStatus, jqXHR) {
354
+ return goFroalaWysiwygs(array);
355
+ };
356
+ })(this));
357
+ } else {
358
+ goFroalaWysiwygs(array);
359
+ }
360
+ }
361
+ return content.find('trix-editor').each(function() {
362
+ if (!window.Trix) {
363
+ options = $(this).data('options');
364
+ $('head').append('<link href="' + options['csspath'] + '" rel="stylesheet" media="all" type="text\/css">');
365
+ return $.getScript(options['jspath']);
366
+ }
367
+ });
368
+ }
369
+ });
370
+
371
+ }(jQuery));