Changeset 172 for ether_megapoli/trunk/web/resources/js/Select.js
- Timestamp:
- 08/31/11 16:51:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/web/resources/js/Select.js
r131 r172 3 3 // Display a Select 4 4 // 5 // obj objParam: {id, [parent], [specificClass], [maxOptionSize], [isDisable], [isDisplayed] , [arrayData]}5 // obj objParam: {id, [parent], [specificClass], [maxOptionSize], [isDisable], [isDisplayed]} 6 6 // int objParam.id: id of the dom element 7 7 // [dom objParam.parent]: in which dom element to draw the button … … 10 10 // [int objParam.isDisable]: is the Select disable by default? 11 11 // [int objParam.isDisplayed]: is the Select opened by default? 12 // [arr objParam.arrayData]: array of data to display13 12 // 14 13 // Public functions … … 38 37 this.indexOption = 0; 39 38 this.isHover = false; 40 this.arrayData = objectParameter.arrayData ? objectParameter.arrayData : $A();41 39 this.arrayOptions = $A(); 40 this.className = objectParameter.className ? "select_container " + objectParameter.className : "select_container"; 41 this.classNameOption = objectParameter.classNameOption ? "select_choicelist " + objectParameter.classNameOption : "select_choicelist"; 42 42 43 43 // Select div 44 44 this.divSelect = document.createElement( "div" ); 45 45 this.divSelect.id = this.id; 46 this.divSelect.className = "select_container";46 this.divSelect.className = this.className; 47 47 48 48 this.divSelectLeft = document.createElement( "div" ); … … 63 63 this.divOption = document.createElement( "div" ); 64 64 this.divSelect.id = this.id; 65 this.divOption.className = "select_choicelist";65 this.divOption.className = this.classNameOption; 66 66 this.parent.appendChild( this.divOption ); 67 67 … … 90 90 }, 91 91 92 getSize: function() 93 { 94 return this.arrayOptions.size(); 95 }, 96 92 97 // private 93 98 toggleOption:function() … … 139 144 140 145 // public 146 /** 147 * This method indicates if the itemValue is already in the array 148 */ 149 content: function( itemValue ) 150 { 151 var resu = false; 152 this.arrayOptions.each( function( divOption ) 153 { 154 if( divOption.itemValue == itemValue ) 155 { 156 resu = true; 157 throw $break; 158 } 159 }.bind( this ) ); 160 return resu; 161 }, 162 163 // public 141 164 add: function( itemValue, itemName, callback ) 142 165 { 143 144 166 var divOption = document.createElement( "div" ); 145 167 divOption.className = "select_item_middle"; … … 177 199 this.arrayOptions = this.arrayOptions.without( divOption ); 178 200 }.bind( this ) ); 201 }, 202 203 // public 204 /** 205 * This method changes only the content of the divSelect without add the item to the array 206 * @param itemValue 207 * @param itemName 208 * @param callback 209 */ 210 changeSelectMiddle: function( itemValue, itemName, callback ) 211 { 212 this.add( itemValue, itemName, callback ); 213 this.select( itemValue, callback ); 214 this.remove( itemValue ); 179 215 }, 180 216
Note: See TracChangeset
for help on using the changeset viewer.