Sha256: cd5f2b4f5eab7e760fc635e3cc8f72cff2e19c59ab3e65779e3257f29ca48eb3
Contents?: true
Size: 1.75 KB
Versions: 6
Compression:
Stored size: 1.75 KB
Contents
<% list_id ||= "sortable_list" update_url ||= url_for(:action => "update_positions") tree ||= false content_for :head do %> <script type='text/javascript'> reordering_button_enabled = true; FastInit.addOnLoad(function() { $('reorder_action').observe('click', enable_reordering); $('reorder_action_done').observe('click', disable_reordering); }); disable_reordering = function(e) { if (reordering_button_enabled) { $('<%= list_id %>').removeClassName('reordering'); Sortable.destroy("<%= list_id %>"); $('reorder_action_done').hide(); $('reorder_action').show(); } if (e) { e.stop(); } } enable_reordering = function(e) { sortable_list = $('<%= list_id %>'); sortable_list.addClassName('reordering'); nest_id = 0; sortable_list.select('ul.nested').each(function(nested) { nested.id = nested.id.length > 0 ? nested.id : "nested_" + nest_id++; Sortable.create(nested.id, { constraint: <%= tree ? "false" : "'vertical'" %> , hoverclass: 'hover' , scroll: window , tree: <%= tree %> }); }); Sortable.create("<%= list_id %>", { constraint: <%= tree ? "false" : "'vertical'" %> , hoverclass: 'hover' , scroll: window , tree: <%= tree %> , onUpdate:function() { reordering_button_enabled = false; new Ajax.Updater('<%= list_id %>', '<%= update_url %>', { asynchronous:true , evalScripts:true , parameters: Sortable.serialize('<%= list_id %>') + '&tree=<%= tree %>' + '&authenticity_token=' + encodeURIComponent($('reorder_authenticity_token').value) , onComplete: function(e) { reordering_button_enabled = true; } }); } }); $('reorder_action').hide(); $('reorder_action_done').show(); if (e) { e.stop(); } } </script> <% end %>
Version data entries
6 entries across 6 versions & 1 rubygems