<commit_before><% 
	list_id ||= "sortable_list"
	update_url ||= url_for(:action => "update_positions")
	tree ||= false
	
	content_for :head do 
%>
<script type='text/javascript'>
	FastInit.addOnLoad(function()
	{
		$('reorder_action').observe('click', enable_reordering);
		$('reorder_action_done').observe('click', disable_reordering);
	});
	
	disable_reordering = function(e)
	{
		$('<%= 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() {
				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)
				});
			}
		});
		
		$('reorder_action').hide();
		$('reorder_action_done').show();
		
		if (e) 
		{
			e.stop();
		}
	}
</script>
<% end %><commit_msg>Disable the 'Done reordering' button until the reordering request completes. Works with all current reordering controls that hook into this code.<commit_after><% 
	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 %>
{'fraction_non_alphanumeric': 0.20105820105820105, 'fraction_numerical': 0.001113895850737956, 'mean_word_length': 3.8409703504043127, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117285', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1248, 'n_words': 204}