##// END OF EJS Templates
remove trailing white-spaces from public/javascripts/select_list_move.js...
Toshi MARUYAMA -
r8983:2f1d6cd94d2a
parent child
Show More
@@ -1,82 +1,82
1 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
1 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
2
2
3 function addOption(theSel, theText, theValue)
3 function addOption(theSel, theText, theValue)
4 {
4 {
5 var newOpt = new Option(theText, theValue);
5 var newOpt = new Option(theText, theValue);
6 var selLength = theSel.length;
6 var selLength = theSel.length;
7 theSel.options[selLength] = newOpt;
7 theSel.options[selLength] = newOpt;
8 }
8 }
9
9
10 function swapOptions(theSel, index1, index2)
10 function swapOptions(theSel, index1, index2)
11 {
11 {
12 var text, value;
12 var text, value;
13 text = theSel.options[index1].text;
13 text = theSel.options[index1].text;
14 value = theSel.options[index1].value;
14 value = theSel.options[index1].value;
15 theSel.options[index1].text = theSel.options[index2].text;
15 theSel.options[index1].text = theSel.options[index2].text;
16 theSel.options[index1].value = theSel.options[index2].value;
16 theSel.options[index1].value = theSel.options[index2].value;
17 theSel.options[index2].text = text;
17 theSel.options[index2].text = text;
18 theSel.options[index2].value = value;
18 theSel.options[index2].value = value;
19 }
19 }
20
20
21 function deleteOption(theSel, theIndex)
21 function deleteOption(theSel, theIndex)
22 {
22 {
23 var selLength = theSel.length;
23 var selLength = theSel.length;
24 if(selLength>0)
24 if(selLength>0)
25 {
25 {
26 theSel.options[theIndex] = null;
26 theSel.options[theIndex] = null;
27 }
27 }
28 }
28 }
29
29
30 function moveOptions(theSelFrom, theSelTo)
30 function moveOptions(theSelFrom, theSelTo)
31 {
31 {
32
32
33 var selLength = theSelFrom.length;
33 var selLength = theSelFrom.length;
34 var selectedText = new Array();
34 var selectedText = new Array();
35 var selectedValues = new Array();
35 var selectedValues = new Array();
36 var selectedCount = 0;
36 var selectedCount = 0;
37
37
38 var i;
38 var i;
39
39
40 for(i=selLength-1; i>=0; i--)
40 for(i=selLength-1; i>=0; i--)
41 {
41 {
42 if(theSelFrom.options[i].selected)
42 if(theSelFrom.options[i].selected)
43 {
43 {
44 selectedText[selectedCount] = theSelFrom.options[i].text;
44 selectedText[selectedCount] = theSelFrom.options[i].text;
45 selectedValues[selectedCount] = theSelFrom.options[i].value;
45 selectedValues[selectedCount] = theSelFrom.options[i].value;
46 deleteOption(theSelFrom, i);
46 deleteOption(theSelFrom, i);
47 selectedCount++;
47 selectedCount++;
48 }
48 }
49 }
49 }
50
50
51 for(i=selectedCount-1; i>=0; i--)
51 for(i=selectedCount-1; i>=0; i--)
52 {
52 {
53 addOption(theSelTo, selectedText[i], selectedValues[i]);
53 addOption(theSelTo, selectedText[i], selectedValues[i]);
54 }
54 }
55
55
56 if(NS4) history.go(0);
56 if(NS4) history.go(0);
57 }
57 }
58
58
59 function moveOptionUp(theSel) {
59 function moveOptionUp(theSel) {
60 var index = theSel.selectedIndex;
60 var index = theSel.selectedIndex;
61 if (index > 0) {
61 if (index > 0) {
62 swapOptions(theSel, index-1, index);
62 swapOptions(theSel, index-1, index);
63 theSel.selectedIndex = index-1;
63 theSel.selectedIndex = index-1;
64 }
64 }
65 }
65 }
66
66
67 function moveOptionDown(theSel) {
67 function moveOptionDown(theSel) {
68 var index = theSel.selectedIndex;
68 var index = theSel.selectedIndex;
69 if (index < theSel.length - 1) {
69 if (index < theSel.length - 1) {
70 swapOptions(theSel, index, index+1);
70 swapOptions(theSel, index, index+1);
71 theSel.selectedIndex = index+1;
71 theSel.selectedIndex = index+1;
72 }
72 }
73 }
73 }
74
74
75 function selectAllOptions(id)
75 function selectAllOptions(id)
76 {
76 {
77 var select = $(id);
77 var select = $(id);
78 for (var i=0; i<select.options.length; i++) {
78 for (var i=0; i<select.options.length; i++) {
79 select.options[i].selected = true;
79 select.options[i].selected = true;
80 }
80 }
81 }
81 }
82
82
General Comments 0
You need to be logged in to leave comments. Login now