summaryrefslogtreecommitdiffstats
path: root/public
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-17 22:57:40 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-17 22:57:40 +0000
commitcbf10b0eb8c4d8fd4dac190436050b834878f90a (patch)
tree08cb15d271c5e90a23092937d718e7f5d0d9bd04 /public
parent043c2c92da7d922f43f77ad9d88b738781846df5 (diff)
downloadredmine-cbf10b0eb8c4d8fd4dac190436050b834878f90a.tar.gz
redmine-cbf10b0eb8c4d8fd4dac190436050b834878f90a.zip
Allows to move multiple columns in selection list (#18357).
Patch by Filou Centrinov. git-svn-id: http://svn.redmine.org/redmine/trunk@13610 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r--public/javascripts/select_list_move.js59
1 files changed, 38 insertions, 21 deletions
diff --git a/public/javascripts/select_list_move.js b/public/javascripts/select_list_move.js
index c3a5d0a2b..a5687981f 100644
--- a/public/javascripts/select_list_move.js
+++ b/public/javascripts/select_list_move.js
@@ -7,13 +7,16 @@ function addOption(theSel, theText, theValue) {
}
function swapOptions(theSel, index1, index2) {
- var text, value;
+ var text, value, selected;
text = theSel.options[index1].text;
value = theSel.options[index1].value;
+ selected = theSel.options[index1].selected;
theSel.options[index1].text = theSel.options[index2].text;
theSel.options[index1].value = theSel.options[index2].value;
+ theSel.options[index1].selected = theSel.options[index2].selected;
theSel.options[index2].text = text;
theSel.options[index2].value = value;
+ theSel.options[index2].selected = selected;
}
function deleteOption(theSel, theIndex) {
@@ -44,40 +47,54 @@ function moveOptions(theSelFrom, theSelTo) {
}
function moveOptionUp(theSel) {
- var index = theSel.selectedIndex;
- if (index > 0) {
- swapOptions(theSel, index-1, index);
- theSel.selectedIndex = index-1;
+ var indexTop = 0;
+ for(var s=0; s<theSel.length; s++) {
+ if (theSel.options[s].selected) {
+ if (s > indexTop) {
+ swapOptions(theSel, s-1, s);
+ }
+ indexTop++;
+ }
}
}
function moveOptionTop(theSel) {
- var index = theSel.selectedIndex;
-
- if (index > 0) {
- for (i=index; i>0; i--) {
- swapOptions(theSel, i-1, i);
+ var indexTop = 0;
+ for(var s=0; s<theSel.length; s++) {
+ if (theSel.options[s].selected) {
+ if (s > indexTop) {
+ for (var i=s; i>indexTop; i--) {
+ swapOptions(theSel, i-1, i);
+ }
+ }
+ indexTop++;
}
- theSel.selectedIndex = 0;
}
}
function moveOptionDown(theSel) {
- var index = theSel.selectedIndex;
- if (index < theSel.length - 1) {
- swapOptions(theSel, index, index+1);
- theSel.selectedIndex = index+1;
+ var indexBottom = theSel.length - 1;
+ for(var s=indexBottom; s>=0; s--) {
+ if (theSel.options[s].selected) {
+ if (s < indexBottom) {
+ swapOptions(theSel, s+1, s);
+ }
+ indexBottom--;
+ }
}
}
function moveOptionBottom(theSel) {
- var index = theSel.selectedIndex;
- var indexTop = theSel.length - 1;
- if (index < theSel.length - 1) {
- for (i=index; i<indexTop; i++) {
- swapOptions(theSel, i+1, i);
+ var indexBottom = theSel.length - 1;
+ for(var s=indexBottom; s>=0; s--) {
+ if (theSel.options[s].selected) {
+ if (s < indexBottom) {
+ for (i=s; i<indexBottom; i++) {
+ swapOptions(theSel, i+1, i);
+ }
+ }
+ indexBottom--;
}
- theSel.selectedIndex = indexTop;
}
}