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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/app/assets/javascripts/rails_admin/custom/ui.js +1 -0
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.i18n.js +28 -0
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +57 -0
- data/app/assets/javascripts/rails_admin/ra.sidescroll.js +31 -0
- data/app/assets/javascripts/rails_admin/ra.widgets.js +371 -0
- data/app/assets/javascripts/rails_admin/ui.js +135 -0
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +4 -0
- data/app/helpers/rails_admin/application_helper.rb +17 -2
- data/app/views/layouts/rails_admin/_head.html.haml +7 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -1
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +2 -1
- data/app/views/layouts/rails_admin/application.html.haml +3 -8
- data/app/views/rails_admin/main/_form_file_upload.html.haml +3 -3
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +6 -4
- data/config/locales/rails_admin.en.yml +1 -0
- data/lib/generators/rails_admin/templates/initializer.erb +2 -2
- data/lib/rails_admin.rb +0 -1
- data/lib/rails_admin/abstract_model.rb +1 -1
- data/lib/rails_admin/adapters/active_record.rb +12 -3
- data/lib/rails_admin/adapters/mongoid.rb +14 -0
- data/lib/rails_admin/bootstrap-sass.rb +1 -1
- data/lib/rails_admin/config.rb +4 -6
- data/lib/rails_admin/config/actions/base.rb +17 -1
- data/lib/rails_admin/config/actions/edit.rb +1 -3
- data/lib/rails_admin/config/actions/index.rb +1 -1
- data/lib/rails_admin/config/actions/new.rb +1 -3
- data/lib/rails_admin/config/fields.rb +0 -1
- data/lib/rails_admin/config/fields/association.rb +1 -1
- data/lib/rails_admin/config/fields/types/action_text.rb +1 -2
- data/lib/rails_admin/config/fields/types/all.rb +0 -1
- data/lib/rails_admin/config/fields/types/ck_editor.rb +2 -2
- data/lib/rails_admin/config/fields/types/code_mirror.rb +2 -2
- data/lib/rails_admin/config/fields/types/color.rb +2 -2
- data/lib/rails_admin/config/fields/types/file_upload.rb +6 -2
- data/lib/rails_admin/config/fields/types/froala.rb +2 -2
- data/lib/rails_admin/config/fields/types/hidden.rb +2 -2
- data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +1 -1
- data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +15 -3
- data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +17 -3
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +7 -0
- data/lib/rails_admin/config/fields/types/shrine.rb +5 -1
- data/lib/rails_admin/config/fields/types/simple_mde.rb +2 -2
- data/lib/rails_admin/config/fields/types/string.rb +2 -2
- data/lib/rails_admin/config/fields/types/string_like.rb +19 -0
- data/lib/rails_admin/config/fields/types/text.rb +2 -2
- data/lib/rails_admin/config/fields/types/wysihtml5.rb +2 -2
- data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +45 -21
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +4 -1
- data/lib/rails_admin/version.rb +1 -1
- data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings-white.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/bootstrap/glyphicons-halflings.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/{app → vendor}/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap-typeahead.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/bootstrap/bootstrap.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -0
- data/{app → vendor}/assets/javascripts/rails_admin/jquery.pjax.js +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_alerts.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_badges.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_breadcrumbs.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_button-groups.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_buttons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_carousel.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_close.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_code.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_component-animations.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_dropdowns.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_forms.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_glyphicons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_grid.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_input-groups.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_jumbotron.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_labels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_list-group.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_media.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_mixins.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_modals.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navbar.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_navs.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_normalize.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pager.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_pagination.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_panels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_popovers.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_print.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_progress-bars.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-embed.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_responsive-utilities.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_scaffolding.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tables.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_theme.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_thumbnails.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_tooltip.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_type.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_utilities.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_variables.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/_wells.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/bootstrap.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_alerts.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_background-variant.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_border-radius.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_buttons.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_center-block.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_forms.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_gradients.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid-framework.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_grid.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_hide-text.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_labels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-divider.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-vertical-align.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_opacity.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_panels.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_progress-bar.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-filter.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_responsive-visibility.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_size.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_tab-focus.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_table-row.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-emphasis.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_text-overflow.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/bootstrap/mixins/_vendor-prefixes.scss +0 -0
- data/{app → vendor}/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -0
- metadata +130 -153
- data/app/assets/javascripts/rails_admin/custom/ui.coffee +0 -1
- data/app/assets/javascripts/rails_admin/ra.i18n.coffee +0 -10
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.coffee +0 -55
- data/app/assets/javascripts/rails_admin/ra.sidescroll.coffee +0 -19
- data/app/assets/javascripts/rails_admin/ra.widgets.coffee +0 -359
- data/app/assets/javascripts/rails_admin/ui.coffee +0 -107
- data/lib/rails_admin/config/fields/factories/refile.rb +0 -25
- data/lib/rails_admin/config/fields/types/refile.rb +0 -27
- data/lib/rails_admin/extensions/cancan.rb +0 -3
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b0f4ab7caf68837692964e8e69e90d167282dafa55a35aaaa3d76eb93f97b9d
|
4
|
+
data.tar.gz: 9a6407f79b492dffafd49568675b7982122c76e080519c0f6b3156abbeb3e71a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 127e444d5dee93ccb6cd28c210368bc143d06732f5683917b0b969eac3717a3a606d5415891d5e768385cc3fd445ce2d754c39f97daec21b50ee49595a5ecde2
|
7
|
+
data.tar.gz: 14ff533ab2205b78c5d3529bd0b16166af4b2ad54547c6c67d20ffde399ed17defe559dc53c7e34a3c3457ef16bf4de8b4122211c6ea663090946ca84e687380
|
data/Gemfile
CHANGED
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.
|
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));
|