annotate .svn/pristine/fe/fea377ca3507d29436339adfee4cde6107a60b60.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

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