Mercurial > hg > soundsoftware-site
comparison public/javascripts/select_list_move.js @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | 433d4f72a19b |
children | dffacf8a6908 |
comparison
equal
deleted
inserted
replaced
1296:038ba2d95de8 | 1464:261b3d9a4903 |
---|---|
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 { | |
5 var newOpt = new Option(theText, theValue); | 4 var newOpt = new Option(theText, theValue); |
6 var selLength = theSel.length; | 5 var selLength = theSel.length; |
7 theSel.options[selLength] = newOpt; | 6 theSel.options[selLength] = newOpt; |
8 } | 7 } |
9 | 8 |
10 function swapOptions(theSel, index1, index2) | 9 function swapOptions(theSel, index1, index2) { |
11 { | |
12 var text, value; | 10 var text, value; |
13 text = theSel.options[index1].text; | 11 text = theSel.options[index1].text; |
14 value = theSel.options[index1].value; | 12 value = theSel.options[index1].value; |
15 theSel.options[index1].text = theSel.options[index2].text; | 13 theSel.options[index1].text = theSel.options[index2].text; |
16 theSel.options[index1].value = theSel.options[index2].value; | 14 theSel.options[index1].value = theSel.options[index2].value; |
17 theSel.options[index2].text = text; | 15 theSel.options[index2].text = text; |
18 theSel.options[index2].value = value; | 16 theSel.options[index2].value = value; |
19 } | 17 } |
20 | 18 |
21 function deleteOption(theSel, theIndex) | 19 function deleteOption(theSel, theIndex) { |
22 { | |
23 var selLength = theSel.length; | 20 var selLength = theSel.length; |
24 if(selLength>0) | 21 if (selLength > 0) { |
25 { | |
26 theSel.options[theIndex] = null; | 22 theSel.options[theIndex] = null; |
27 } | 23 } |
28 } | 24 } |
29 | 25 |
30 function moveOptions(theSelFrom, theSelTo) | 26 function moveOptions(theSelFrom, theSelTo) { |
31 { | |
32 | |
33 var selLength = theSelFrom.length; | 27 var selLength = theSelFrom.length; |
34 var selectedText = new Array(); | 28 var selectedText = new Array(); |
35 var selectedValues = new Array(); | 29 var selectedValues = new Array(); |
36 var selectedCount = 0; | 30 var selectedCount = 0; |
37 | |
38 var i; | 31 var i; |
39 | 32 for (i = selLength - 1; i >= 0; i--) { |
40 for(i=selLength-1; i>=0; i--) | 33 if (theSelFrom.options[i].selected) { |
41 { | |
42 if(theSelFrom.options[i].selected) | |
43 { | |
44 selectedText[selectedCount] = theSelFrom.options[i].text; | 34 selectedText[selectedCount] = theSelFrom.options[i].text; |
45 selectedValues[selectedCount] = theSelFrom.options[i].value; | 35 selectedValues[selectedCount] = theSelFrom.options[i].value; |
46 deleteOption(theSelFrom, i); | 36 deleteOption(theSelFrom, i); |
47 selectedCount++; | 37 selectedCount++; |
48 } | 38 } |
49 } | 39 } |
50 | 40 for (i = selectedCount - 1; i >= 0; i--) { |
51 for(i=selectedCount-1; i>=0; i--) | |
52 { | |
53 addOption(theSelTo, selectedText[i], selectedValues[i]); | 41 addOption(theSelTo, selectedText[i], selectedValues[i]); |
54 } | 42 } |
55 | 43 if (NS4) history.go(0); |
56 if(NS4) history.go(0); | |
57 } | 44 } |
58 | 45 |
59 function moveOptionUp(theSel) { | 46 function moveOptionUp(theSel) { |
60 var index = theSel.selectedIndex; | 47 var index = theSel.selectedIndex; |
61 if (index > 0) { | 48 if (index > 0) { |
71 theSel.selectedIndex = index+1; | 58 theSel.selectedIndex = index+1; |
72 } | 59 } |
73 } | 60 } |
74 | 61 |
75 // OK | 62 // OK |
76 function selectAllOptions(id) | 63 function selectAllOptions(id) { |
77 { | 64 var select = $('#'+id); |
78 var select = $('#'+id);/* | |
79 for (var i=0; i<select.options.length; i++) { | |
80 select.options[i].selected = true; | |
81 }*/ | |
82 select.children('option').attr('selected', true); | 65 select.children('option').attr('selected', true); |
83 } | 66 } |