Mercurial > hg > soundsoftware-site
comparison public/javascripts/select_list_move.js @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | 513646585e45 |
children | 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
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 } | |
73 } | |
74 | |
75 function selectAllOptions(id) | |
76 { | |
77 var select = $(id); | |
78 for (var i=0; i<select.options.length; i++) { | |
79 select.options[i].selected = true; | |
80 } | 72 } |
81 } | 73 } |
82 | 74 |
75 // OK | |
76 function selectAllOptions(id) | |
77 { | |
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); | |
83 } |