Changeset 130 for ether_megapoli/trunk/web/resources/js
- Timestamp:
- 08/18/11 12:39:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ether_megapoli/trunk/web/resources/js/etherClasses.js
r89 r130 2 2 /* ****************** LIST ************************* */ 3 3 /* ************************************************* */ 4 var ListItem = Class.create( {4 var ListItem = Class.create( { 5 5 6 6 initialize: function( plateforms, objectParameter ) 7 7 { 8 8 this.array = $A(); 9 $A( plateforms).each(function( jsonObject )9 $A( plateforms ).each( function( jsonObject ) 10 10 { 11 this.addItem( jsonObject, objectParameter);12 }.bind( this));11 this.addItem( jsonObject, objectParameter ); 12 }.bind( this ) ); 13 13 }, 14 14 … … 19 19 var objectItemNew = new Object(); 20 20 objectItemNew.jsonElement = jsonElement; 21 objectItemNew.divItem = this.createItemDiv( objectItemNew.jsonElement, objectParameter);21 objectItemNew.divItem = this.createItemDiv( objectItemNew.jsonElement, objectParameter ); 22 22 23 this.array.push( objectItemNew);23 this.array.push( objectItemNew ); 24 24 }, 25 25 26 26 createItemDiv: function( itemHash, objectParameter ) 27 27 { 28 return new Plateform( itemHash, objectParameter);28 return new Plateform( itemHash, objectParameter ); 29 29 }, 30 30 31 31 addOpenListener : function( func ) 32 32 { 33 this.array.each( function( objectItem )33 this.array.each( function( objectItem ) 34 34 { 35 objectItem.divItem.addOpenListener( func);36 } );35 objectItem.divItem.addOpenListener( func ); 36 } ); 37 37 }, 38 38 … … 41 41 if( 0 >= this.array.size() ) 42 42 { 43 var divNoItem = $( document.createElement("div"));43 var divNoItem = $( document.createElement( "div" ) ); 44 44 divNoItem.id = idIfNoItem; 45 45 divNoItem.textContent = textIfNoItem; 46 parentNode.appendChild( divNoItem);46 parentNode.appendChild( divNoItem ); 47 47 } 48 48 else 49 this.array.each( function( item )49 this.array.each( function( item ) 50 50 { 51 item.divItem.display( parentNode);52 } );51 item.divItem.display( parentNode ); 52 } ); 53 53 }, 54 54 55 55 displayWithPairImpair : function( parentNode, idIfNoItem, textIfNoItem ) 56 56 { 57 Dom.clearContainer(parentNode);57 Dom.clearContainer( parentNode ); 58 58 if( 0 >= this.array.size() ) 59 59 { 60 var divNoItem = $( document.createElement("div"));60 var divNoItem = $( document.createElement( "div" ) ); 61 61 divNoItem.id = idIfNoItem; 62 62 divNoItem.textContent = textIfNoItem; 63 parentNode.appendChild( divNoItem);63 parentNode.appendChild( divNoItem ); 64 64 } 65 65 else 66 66 { 67 68 this.array.each( function( item )67 var rowNumber = 0; 68 this.array.each( function( item ) 69 69 { 70 if(rowNumber % 2 == 0)71 item.divItem.display( parentNode,"pair");72 73 item.divItem.display( parentNode,"impair");74 75 } );70 if( rowNumber % 2 == 0 ) 71 item.divItem.display( parentNode, "pair" ); 72 else 73 item.divItem.display( parentNode, "impair" ); 74 rowNumber++; 75 } ); 76 76 } 77 77 }, … … 80 80 { 81 81 var returnObj = false; 82 this.array.each( function( objItem )82 this.array.each( function( objItem ) 83 83 { 84 84 if( objItem.jsonElement.id == itemId ) 85 85 returnObj = objItem; 86 }.bind( this));86 }.bind( this ) ); 87 87 88 88 return returnObj; 89 89 } 90 90 91 } );91 } ); 92 92 93 93 /* ************************************************* */ 94 94 /* ****************** ITEM ************************* */ 95 95 /* ************************************************* */ 96 var Item = Class.create( {96 var Item = Class.create( { 97 97 98 98 initialize: function( jsonElement, objectParameter ) 99 99 { 100 this.jsonElement = Object.clone( jsonElement); // Warning: This is only a shallow copy100 this.jsonElement = Object.clone( jsonElement ); // Warning: This is only a shallow copy 101 101 this.listeners = $A(); 102 102 … … 124 124 createContainer: function ( containerName, classNameValue ) 125 125 { 126 this.divContainer = $( document.createElement("div"));126 this.divContainer = $( document.createElement( "div" ) ); 127 127 this.divContainer.item = this; 128 if( classNameValue)129 this.divContainer.className = classNameValue;128 if( classNameValue ) 129 this.divContainer.className = classNameValue; 130 130 this.divContainer.id = containerName + "_" + this.jsonElement.id; 131 131 }, … … 134 134 { 135 135 this.parentNode = parentNode; 136 parentNode.appendChild( this.divContainer);136 parentNode.appendChild( this.divContainer ); 137 137 }, 138 138 … … 146 146 { 147 147 if( classNameValue ) 148 this.divContainer.addClassName( classNameValue);148 this.divContainer.addClassName( classNameValue ); 149 149 }, 150 150 … … 152 152 { 153 153 if( classNameValue ) 154 this.divContainer.removeClassName( classNameValue);154 this.divContainer.removeClassName( classNameValue ); 155 155 }, 156 156 157 157 executeListenersFunction: function() 158 158 { 159 this.listeners.each( function ( func )159 this.listeners.each( function ( func ) 160 160 { 161 func( this);162 }.bind( this));161 func( this ); 162 }.bind( this ) ); 163 163 }, 164 164 … … 166 166 { 167 167 if( this.divContainer ) 168 Event.observe( this.divContainer, 'click', this.onClickContainer.bindAsEventListener(this));168 Event.observe( this.divContainer, 'click', this.onClickContainer.bindAsEventListener( this ) ); 169 169 }, 170 170 171 171 addOpenListener: function( func ) 172 172 { 173 this.listeners.push( func);173 this.listeners.push( func ); 174 174 }, 175 175 … … 179 179 return; 180 180 181 this.divName = $( document.createElement("div"));181 this.divName = $( document.createElement( "div" ) ); 182 182 this.divName.className = classNameValue; 183 183 this.divName.innerHTML = this.jsonElement.name; 184 184 185 this.divContainer.appendChild(this.divName); 185 this.divContainer.appendChild( this.divName ); 186 }, 187 188 getName: function () 189 { 190 return this.jsonElement.name; 186 191 } 187 }); 192 193 } );
Note: See TracChangeset
for help on using the changeset viewer.