[ Index ] |
|
Code source de Horde 3.1.3 |
1 /** 2 * Horde Form Sorter Field Javascript Class 3 * 4 * Provides the javascript class to accompany the Horde_Form sorter 5 * field. 6 * 7 * $Horde: horde/js/sorter.js,v 1.2.10.3 2006/01/01 21:29:02 jan Exp $ 8 * 9 * Copyright 2003-2006 Marko Djukic <marko@oblo.com> 10 * 11 * See the enclosed file COPYING for license information (LGPL). If you 12 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 13 */ 14 15 function Horde_Form_Sorter(instanceName, varName, header) 16 { 17 /* Set up this class instance for function calls from the page. */ 18 this._instanceName = instanceName; 19 20 this._varName = varName; 21 22 /* Sorter variables. */ 23 this._header = ''; 24 this.minLength = 0; 25 if (header != '') { 26 this._header = header; 27 this.minLength = 1; 28 } 29 this.sorterList = document.getElementById(this._varName + '[list]'); 30 this.sorterArray = document.getElementById(this._varName + '[array]'); 31 32 this.deselectHeader = function() 33 { 34 if (this._header != '') { 35 this.sorterList[0].selected = false; 36 } 37 } 38 39 this.setHidden = function() 40 { 41 var tmpArray = new Array(); 42 43 for (var i = this.minLength; i < this.sorterList.length; i++) { 44 if (this.sorterList[i].value) { 45 tmpArray[i - this.minLength] = this.sorterList[i].value; 46 } 47 } 48 49 this.sorterArray.value = tmpArray.join("\t"); 50 } 51 52 this.moveColumnUp = function() 53 { 54 var sel = this.sorterList.selectedIndex; 55 56 if (sel <= this.minLength || this.sorterList.length <= this.minLength + 1) return; 57 58 /* Deselect everything but the first selected item. */ 59 this.sorterList.selectedIndex = sel; 60 var up = this.sorterList[sel].value; 61 62 tmp = new Array(); 63 for (i = this.minLength; i < this.sorterList.length; i++) { 64 tmp[i - this.minLength] = new Option(this.sorterList[i].text, this.sorterList[i].value) 65 } 66 67 for (i = 0; i < tmp.length; i++) { 68 if (i + this.minLength == sel - 1) { 69 this.sorterList[i + this.minLength] = tmp[i + 1]; 70 } else if (i + this.minLength == sel) { 71 this.sorterList[i + this.minLength] = tmp[i - 1]; 72 } else { 73 this.sorterList[i + this.minLength] = tmp[i]; 74 } 75 } 76 77 this.sorterList.selectedIndex = sel - 1; 78 79 this.setHidden(); 80 } 81 82 this.moveColumnDown = function() 83 { 84 var sel = this.sorterList.selectedIndex; 85 86 if (sel == -1 || sel == this.sorterList.length - 1) return; 87 88 /* Deselect everything but the first selected item. */ 89 this.sorterList.selectedIndex = sel; 90 var down = this.sorterList[sel].value; 91 92 tmp = new Array(); 93 for (i = this.minLength; i < this.sorterList.length; i++) { 94 tmp[i - this.minLength] = new Option(this.sorterList[i].text, this.sorterList[i].value) 95 } 96 97 for (i = 0; i < tmp.length; i++) { 98 if (i + this.minLength == sel) { 99 this.sorterList[i + this.minLength] = tmp[i + 1]; 100 } else if (i + this.minLength == sel + 1) { 101 this.sorterList[i + this.minLength] = tmp[i - 1]; 102 } else { 103 this.sorterList[i + this.minLength] = tmp[i]; 104 } 105 } 106 107 this.sorterList.selectedIndex = sel + 1; 108 109 this.setHidden(); 110 } 111 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |