From 3c0769d8f8720ed0b9b0b81e6a6128360a70c932 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 11 May 2011 13:18:41 +0200 Subject: [PATCH] =?utf8?q?Automatisches=20Neu-Einf=C3=A4rben=20nach=20Drag?= =?utf8?q?&Drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Template/Plugin/L.pm | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index 5a59e025d..0d159dc85 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -410,14 +410,29 @@ sub sortable_element { } JAVASCRIPT + my $stop_event = ''; + if ($params{url} && $params{with}) { my $as = $params{as} || $params{with}; my $filter = ".filter(function(idx) { return this.substr(0, " . length($params{with}) . ") == '$params{with}'; })"; $filter .= ".map(function(idx, str) { return str.replace('$params{with}_', ''); })"; + $stop_event = <*:odd').removeClass('listrow1').removeClass('listrow0').addClass('listrow0'); + \$('${selector}>*:even').removeClass('listrow1').removeClass('listrow0').addClass('listrow1'); +JAVASCRIPT + } + + if ($stop_event) { $attributes{stop} = < + +If trueish then the children will not be recolored. The default is to +recolor the children by setting the class C on odd and +C on even entries. + =back Example: @@ -704,9 +725,10 @@ Example: [% L.sortable_element('#thing_list tbody', - 'url' => 'controller.pl?action=SystemThings/reorder', - 'with' => 'thingy', - 'as' => 'thing_ids') %] + url => 'controller.pl?action=SystemThings/reorder', + with => 'thingy', + as => 'thing_ids', + recolor_rows => 1) %] After dropping e.g. the third element at the top of the list a POST request would be made to the C action of the C -- 2.20.1