Sha256: e1d7104e3c430a6c92c698ce5853af4acf85ac7f7358a5a23172183dbb6ae01f
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
ActiveScaffold.update_positions = function(content) { if (typeof(content) == 'string') content = jQuery('#' + content); var element = content.closest('.sortable-container'); jQuery.each(content.find('.sub-form-record input[name$="[' + element.data('column') + ']"]'), function(i, field) { jQuery(field).val(i); }); } ActiveScaffold.sortable = function(element) { var form, content, sortable_options = {}; if (typeof(element) == 'string') { content = jQuery('#' + element); element = content.closest('.sortable-container'); form = element.closest('form.as_form').length > 0; } else { form = element.closest('form.as_form').length > 0; if (form) content = element; else content = element.find('.records:first'); } if (form) { sortable_options.update = function(event, ui) { ActiveScaffold.update_positions(content); }; } else { var csrf = jQuery('meta[name=csrf-param]').attr('content') + '=' + jQuery('meta[name=csrf-token]').attr('content'); var url = element.data('reorder-url'); sortable_options.update = function(event, ui) { var body = jQuery(this).sortable('serialize',{key: encodeURIComponent(jQuery(this).attr('id') + '[]'), expression: new RegExp(element.data('format'))}); var params = element.data('with'); if (params) body += '&' + params; jQuery.post(url, body + '&' + csrf); }; } sortable_options.handle = element.data('handle'); sortable_options.items = element.data('tag'); content.sortable(sortable_options); }; jQuery(document).ready(function($) { $(document).on('as:action_success', 'a.as_action', function(e, action_link) { var sortable = $('.sortable-container', action_link.adapter); if (sortable.length) $.each(sortable, function(i, s) { ActiveScaffold.sortable(s); }); }); var sortable = $('.sortable-container'); if (sortable.length) ActiveScaffold.sortable(sortable); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_scaffold_sortable-3.2.0 | app/assets/javascripts/jquery/active_scaffold_sortable.js |