comparison .svn/pristine/fe/fea377ca3507d29436339adfee4cde6107a60b60.svn-base @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
1 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
2
3 function addOption(theSel, theText, theValue) {
4 var newOpt = new Option(theText, theValue);
5 var selLength = theSel.length;
6 theSel.options[selLength] = newOpt;
7 }
8
9 function swapOptions(theSel, index1, index2) {
10 var text, value;
11 text = theSel.options[index1].text;
12 value = theSel.options[index1].value;
13 theSel.options[index1].text = theSel.options[index2].text;
14 theSel.options[index1].value = theSel.options[index2].value;
15 theSel.options[index2].text = text;
16 theSel.options[index2].value = value;
17 }
18
19 function deleteOption(theSel, theIndex) {
20 var selLength = theSel.length;
21 if (selLength > 0) {
22 theSel.options[theIndex] = null;
23 }
24 }
25
26 function moveOptions(theSelFrom, theSelTo) {
27 var selLength = theSelFrom.length;
28 var selectedText = new Array();
29 var selectedValues = new Array();
30 var selectedCount = 0;
31 var i;
32 for (i = selLength - 1; i >= 0; i--) {
33 if (theSelFrom.options[i].selected) {
34 selectedText[selectedCount] = theSelFrom.options[i].text;
35 selectedValues[selectedCount] = theSelFrom.options[i].value;
36 deleteOption(theSelFrom, i);
37 selectedCount++;
38 }
39 }
40 for (i = selectedCount - 1; i >= 0; i--) {
41 addOption(theSelTo, selectedText[i], selectedValues[i]);
42 }
43 if (NS4) history.go(0);
44 }
45
46 function moveOptionUp(theSel) {
47 var index = theSel.selectedIndex;
48 if (index > 0) {
49 swapOptions(theSel, index-1, index);
50 theSel.selectedIndex = index-1;
51 }
52 }
53
54 function moveOptionTop(theSel) {
55 var index = theSel.selectedIndex;
56
57 if (index > 0) {
58 for (i=index; i>0; i--) {
59 swapOptions(theSel, i-1, i);
60 }
61 theSel.selectedIndex = 0;
62 }
63 }
64
65 function moveOptionDown(theSel) {
66 var index = theSel.selectedIndex;
67 if (index < theSel.length - 1) {
68 swapOptions(theSel, index, index+1);
69 theSel.selectedIndex = index+1;
70 }
71 }
72
73 function moveOptionBottom(theSel) {
74 var index = theSel.selectedIndex;
75 var indexTop = theSel.length - 1;
76 if (index < theSel.length - 1) {
77 for (i=index; i<indexTop; i++) {
78 swapOptions(theSel, i+1, i);
79 }
80 theSel.selectedIndex = indexTop;
81 }
82 }
83
84 // OK
85 function selectAllOptions(id) {
86 var select = $('#'+id);
87 select.children('option').attr('selected', true);
88 }