annotate .svn/pristine/8d/8d16ae55d2f1c008a010086c27548d8733c4f49f.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

Merge from branch "live"
author Chris Cannam
date Tue, 09 Sep 2014 09:34:53 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
Chris@909 2
Chris@909 3 function addOption(theSel, theText, theValue)
Chris@909 4 {
Chris@909 5 var newOpt = new Option(theText, theValue);
Chris@909 6 var selLength = theSel.length;
Chris@909 7 theSel.options[selLength] = newOpt;
Chris@909 8 }
Chris@909 9
Chris@909 10 function swapOptions(theSel, index1, index2)
Chris@909 11 {
Chris@909 12 var text, value;
Chris@909 13 text = theSel.options[index1].text;
Chris@909 14 value = theSel.options[index1].value;
Chris@909 15 theSel.options[index1].text = theSel.options[index2].text;
Chris@909 16 theSel.options[index1].value = theSel.options[index2].value;
Chris@909 17 theSel.options[index2].text = text;
Chris@909 18 theSel.options[index2].value = value;
Chris@909 19 }
Chris@909 20
Chris@909 21 function deleteOption(theSel, theIndex)
Chris@909 22 {
Chris@909 23 var selLength = theSel.length;
Chris@909 24 if(selLength>0)
Chris@909 25 {
Chris@909 26 theSel.options[theIndex] = null;
Chris@909 27 }
Chris@909 28 }
Chris@909 29
Chris@909 30 function moveOptions(theSelFrom, theSelTo)
Chris@909 31 {
Chris@909 32
Chris@909 33 var selLength = theSelFrom.length;
Chris@909 34 var selectedText = new Array();
Chris@909 35 var selectedValues = new Array();
Chris@909 36 var selectedCount = 0;
Chris@909 37
Chris@909 38 var i;
Chris@909 39
Chris@909 40 for(i=selLength-1; i>=0; i--)
Chris@909 41 {
Chris@909 42 if(theSelFrom.options[i].selected)
Chris@909 43 {
Chris@909 44 selectedText[selectedCount] = theSelFrom.options[i].text;
Chris@909 45 selectedValues[selectedCount] = theSelFrom.options[i].value;
Chris@909 46 deleteOption(theSelFrom, i);
Chris@909 47 selectedCount++;
Chris@909 48 }
Chris@909 49 }
Chris@909 50
Chris@909 51 for(i=selectedCount-1; i>=0; i--)
Chris@909 52 {
Chris@909 53 addOption(theSelTo, selectedText[i], selectedValues[i]);
Chris@909 54 }
Chris@909 55
Chris@909 56 if(NS4) history.go(0);
Chris@909 57 }
Chris@909 58
Chris@909 59 function moveOptionUp(theSel) {
Chris@909 60 var index = theSel.selectedIndex;
Chris@909 61 if (index > 0) {
Chris@909 62 swapOptions(theSel, index-1, index);
Chris@909 63 theSel.selectedIndex = index-1;
Chris@909 64 }
Chris@909 65 }
Chris@909 66
Chris@909 67 function moveOptionDown(theSel) {
Chris@909 68 var index = theSel.selectedIndex;
Chris@909 69 if (index < theSel.length - 1) {
Chris@909 70 swapOptions(theSel, index, index+1);
Chris@909 71 theSel.selectedIndex = index+1;
Chris@909 72 }
Chris@909 73 }
Chris@909 74
Chris@909 75 function selectAllOptions(id)
Chris@909 76 {
Chris@909 77 var select = $(id);
Chris@909 78 for (var i=0; i<select.options.length; i++) {
Chris@909 79 select.options[i].selected = true;
Chris@909 80 }
Chris@909 81 }
Chris@909 82