aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/plugin_admin.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/inc/plugin_admin.js b/inc/plugin_admin.js
index 134ffb33..055ac285 100644
--- a/inc/plugin_admin.js
+++ b/inc/plugin_admin.js
@@ -22,14 +22,22 @@ function changePos(elem, toPos)
22function changeOrder(pos, move) 22function changeOrder(pos, move)
23{ 23{
24 var newpos = parseInt(pos) + move; 24 var newpos = parseInt(pos) + move;
25 var line = document.querySelector('[data-order="'+ pos +'"]'); 25 var lines = document.querySelectorAll('[data-order="'+ pos +'"]');
26 var changeline = document.querySelector('[data-order="'+ newpos +'"]'); 26 var changelines = document.querySelectorAll('[data-order="'+ newpos +'"]');
27 var parent = changeline.parentNode; 27
28 // If we go down reverse lines to preserve the rows order
29 if (move > 0) {
30 lines = [].slice.call(lines).reverse();
31 }
32
33 for (var i = 0 ; i < lines.length ; i++) {
34 var parent = changelines[0].parentNode;
35 changePos(lines[i], newpos);
36 changePos(changelines[i], parseInt(pos));
37 var changeItem = move < 0 ? changelines[0] : changelines[changelines.length - 1].nextSibling;
38 parent.insertBefore(lines[i], changeItem);
39 }
28 40
29 changePos(line, newpos);
30 changePos(changeline, parseInt(pos));
31 var changeItem = move < 0 ? changeline : changeline.nextSibling;
32 parent.insertBefore(line, changeItem);
33} 41}
34 42
35/** 43/**