Changeset 172 for ether_megapoli/trunk/web/resources/js
- Timestamp:
- 08/31/11 16:51:42 (13 years ago)
- Location:
- ether_megapoli/trunk/web/resources/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/web/resources/js/Button.js
r89 r172 11 11 //******************************************************** 12 12 13 var Button = Class.create( {13 var Button = Class.create( { 14 14 initialize: function( param ) 15 15 { … … 21 21 this.classNameText = param.classNameText ? param.classNameText : false; 22 22 this.callbackOnClick = param.onClick ? param.onClick : false; 23 this.callbackOnMouseOver = param.onMouseOver ? param.onMouseOver : false; 24 this.callbackOnMouseOut = param.onMouseOut ? param.onMouseOut : false; 23 25 this.boolDisabled = false; 24 26 this.boolSelected = false; … … 26 28 27 29 // Create button elements 28 this.divContainer = $( document.createElement("button"));29 if( this.className)30 30 this.divContainer = $( document.createElement( "button" ) ); 31 if( this.className ) 32 this.divContainer.className = this.className; 31 33 this.divContainer.atMe = this; 32 34 this.divContainer.id = this.id; 33 35 if( this.parent ) 34 this.parent.appendChild( this.divContainer);36 this.parent.appendChild( this.divContainer ); 35 37 36 this.divText = $( document.createElement("div"));37 if( this.classNameText)38 38 this.divText = $( document.createElement( "div" ) ); 39 if( this.classNameText ) 40 this.divText.className = "button_text"; 39 41 this.divText.innerHTML = this.value; 40 this.divContainer.appendChild( this.divText);41 42 this.divContainer.appendChild( this.divText ); 43 42 44 // Define button events 43 Event.observe(this.divContainer, 'click', this.onClick.bindAsEventListener(this)); 44 Event.observe(this.divContainer, 'mouseover', this.onHover.bindAsEventListener(this)); 45 Event.observe( this.divContainer, 'click', this.onClick.bindAsEventListener( this ) ); 46 Event.observe( this.divContainer, 'mouseover', this.onHover.bindAsEventListener( this ) ); 47 Event.observe( this.divContainer, 'mouseout', this.onOut.bindAsEventListener( this ) ); 45 48 }, 46 49 … … 51 54 return this.divContainer; 52 55 }, 53 56 54 57 isDisable : function() 55 58 { 56 59 return this.boolDisabled; 57 60 }, 58 61 59 62 isSelected: function() 60 63 { 61 64 return this.boolSelected; 62 65 }, 63 66 64 67 setValue : function( value ) 65 68 { … … 67 70 this.divText.innerHTML = this.value; 68 71 }, 69 72 70 73 setCallbackOnClick : function( value ) 71 74 { 72 75 this.callbackOnClick = value; 73 76 }, 74 77 75 78 // Actions ******************************************************** 76 79 … … 78 81 { 79 82 this.boolDisabled = true; 80 this.divContainer.addClassName( "disable");83 this.divContainer.addClassName( "disable" ); 81 84 }, 82 85 83 86 enable : function() 84 87 { 85 88 this.boolDisabled = false; 86 this.divContainer.removeClassName( "disable");89 this.divContainer.removeClassName( "disable" ); 87 90 }, 88 91 89 92 select : function( value ) 90 93 { 91 94 this.boolSelected = value; 92 95 if( this.boolSelected ) 93 this.divContainer.addClassName( "selected");96 this.divContainer.addClassName( "selected" ); 94 97 else 95 this.divContainer.removeClassName( "selected");98 this.divContainer.removeClassName( "selected" ); 96 99 }, 97 100 98 101 show : function() 99 102 { … … 117 120 this.callbackOnClick(); 118 121 } 119 Event.stop( event);122 Event.stop( event ); 120 123 }, 121 124 122 125 onHover : function( event ) 123 126 { 124 Event.stop(event); 127 if( !this.isDisable() && this.callbackOnMouseOver ) 128 this.callbackOnMouseOver(); 129 130 Event.stop( event ); 131 }, 132 133 onOut: function() 134 { 135 if( !this.isDisable() && this.callbackOnMouseOut ) 136 this.callbackOnMouseOut(); 125 137 } 126 } );138 } ); -
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 -
ether_megapoli/trunk/web/resources/js/etherClasses.js
r130 r172 109 109 if( objectParameter.isExpiredTitle ) 110 110 this.isExpiredTitle = objectParameter.isExpiredTitle; 111 this.onMouseOverContainer = objectParameter.onMouseOverContainer ? objectParameter.onMouseOverContainer : false; 112 this.onMouseOutContainer = objectParameter.onMouseOutContainer ? objectParameter.onMouseOutContainer : false; 111 113 } 112 114 }, … … 137 139 }, 138 140 139 on ClickContainer: function( event )141 onHoverContainer: function( event ) 140 142 { 141 143 if( !event || (event.detail == undefined || 1 == event.detail) ) … … 143 145 }, 144 146 147 onClickContainer: function( event ) 148 { 149 if( !event || (event.detail == undefined || 1 == event.detail) ) 150 this.executeListenersFunction(); 151 }, 152 145 153 selectWithParameter: function( classNameValue ) 146 154 { … … 167 175 if( this.divContainer ) 168 176 Event.observe( this.divContainer, 'click', this.onClickContainer.bindAsEventListener( this ) ); 177 if( this.divContainer && this.onMouseOverContainer ) 178 Event.observe( this.divContainer, 'mouseover', this.onMouseOverContainer.bindAsEventListener( this ) ); 179 if( this.divContainer && this.onMouseOutContainer ) 180 Event.observe( this.divContainer, 'mouseout', this.onMouseOutContainer.bindAsEventListener( this ) ); 169 181 }, 170 182
Note: See TracChangeset
for help on using the changeset viewer.