diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-04-17 07:40:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-04-17 07:40:39 +0000 |
commit | 42b5c332b2c24c8dcc2581e0cd130ef930959d99 (patch) | |
tree | 3ddade3fa50427138419d48c57b20d93ac960048 /public | |
parent | 64afa24a7f72526a2cbf6761e51b6cd326aa0c36 (diff) | |
download | redmine-42b5c332b2c24c8dcc2581e0cd130ef930959d99.tar.gz redmine-42b5c332b2c24c8dcc2581e0cd130ef930959d99.zip |
Lists can be reordered with drag and drop (#12909).
git-svn-id: http://svn.redmine.org/redmine/trunk@15336 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r-- | public/javascripts/application.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 3409bc64c..f791addab 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -590,6 +590,45 @@ function beforeShowDatePicker(input, inst) { $(input).datepicker("option", "defaultDate", default_date); } +(function($){ + $.fn.positionedItems = function(sortableOptions, options){ + var settings = $.extend({ + firstPosition: 1 + }, options ); + + return this.sortable($.extend({ + handle: ".sort-handle", + helper: function(event, ui){ + ui.children().each(function(){ + $(this).width($(this).width()); + }); + return ui; + }, + update: function(event, ui) { + var sortable = $(this); + var url = ui.item.find(".sort-handle").data("reorder-url"); + var param = ui.item.find(".sort-handle").data("reorder-param"); + var data = {}; + data[param] = {position: ui.item.index() + settings['firstPosition']}; + $.ajax({ + url: url, + type: 'put', + dataType: 'script', + data: data, + success: function(data){ + sortable.children(":even").removeClass("even").addClass("odd"); + sortable.children(":odd").removeClass("odd").addClass("even"); + }, + error: function(jqXHR, textStatus, errorThrown){ + alert(jqXHR.status); + sortable.sortable("cancel"); + } + }); + }, + }, sortableOptions)); + } +}( jQuery )); + function initMyPageSortable(list, url) { $('#list-'+list).sortable({ connectWith: '.block-receiver', |