Ticket #90: geoext-90.patch
| File geoext-90.patch, 7.5 kB (added by ahocevar, 1 year ago) |
|---|
-
tests/lib/GeoExt/widgets/tree/LayerContainer.html
old new 54 54 t.ok(node.firstChild.layer === layer, "child layer is correct"); 55 55 56 56 node.destroy(); 57 //map.destroy();57 map.destroy(); 58 58 59 59 } 60 60 … … 117 117 t.eq(root.childNodes[3].layer.name, "c", "[c, a, b, d] first layer drawn at bottom of root"); 118 118 119 119 root.destroy(); 120 //map.destroy();120 map.destroy(); 121 121 122 122 } 123 123 -
lib/GeoExt/widgets/tree/LayerContainer.js
old new 100 100 } 101 101 }, 102 102 103 /** private: method[onDestroy]104 */105 onDestroy: function() {106 if(this.layerStore) {107 this.layerStore.un("add", this.onStoreAdd, this);108 this.layerStore.un("remove", this.onStoreRemove, this);109 }110 GeoExt.tree.LayerContainer.superclass.onDestroy.apply(this, arguments);111 },112 113 103 /** private: method[recordIndexToNodeIndex] 114 104 * :param index: ``Number`` The record index in the layer store. 115 105 * :return: ``Number`` The appropriate child node index for the record. … … 220 210 this.layerStore.insert(newRecordIndex, [record]); 221 211 delete this._reordering; 222 212 } 213 }, 214 215 /** private: method[destroy] 216 */ 217 destroy: function() { 218 if(this.layerStore) { 219 this.layerStore.un("add", this.onStoreAdd, this); 220 this.layerStore.un("remove", this.onStoreRemove, this); 221 } 222 GeoExt.tree.LayerContainer.superclass.destroy.apply(this, arguments); 223 223 } 224 225 224 }); 226 225 227 226 /** -
lib/GeoExt/widgets/tree/LayerNode.js
old new 64 64 node.visibilityChanging = false; 65 65 }, 66 66 67 /** private: method[ onDestroy]67 /** private: method[destroy] 68 68 */ 69 onDestroy: function() {69 destroy: function() { 70 70 delete this.radio; 71 GeoExt.tree.LayerNodeUI.superclass. onDestroy.call(this);71 GeoExt.tree.LayerNodeUI.superclass.destroy.call(this); 72 72 } 73 73 }); 74 74 … … 225 225 * state 226 226 */ 227 227 addVisibilityEventHandlers: function() { 228 this.layer.events.register("visibilitychanged", this, function() { 229 if(!this.visibilityChanging && 230 this.attributes.checked != this.layer.getVisibility()) { 231 this.getUI().toggleCheck(this.layer.getVisibility()); 232 } 233 }); 228 this.layer.events.on("visibilitychanged", this, 229 this.onLayerVisibilityChanged); 234 230 this.on({ 235 "checkchange": function(node, checked) { 236 if (checked && this.layer.isBaseLayer && this.layer.map) { 237 this.layer.map.setBaseLayer(this.layer); 238 } 239 this.layer.setVisibility(checked); 240 }, 231 "checkchange": this.onCheckChange, 241 232 scope: this 242 233 }); 243 234 }, 244 235 236 /** private: method[onLayerVisiilityChanged 237 * handler for visibilitychanged events on the layer 238 */ 239 onLayerVisibilityChanged: function() { 240 if(!this.visibilityChanging && 241 this.attributes.checked != this.layer.getVisibility()) { 242 this.getUI().toggleCheck(this.layer.getVisibility()); 243 } 244 }, 245 246 /** private: method[onCheckChange] 247 * :param node: ``GeoExt.tree.LayerNode`` 248 * :param checked: ``Boolean`` 249 * handler for checkchange events 250 */ 251 onCheckChange: function(node, checked) { 252 if (checked && this.layer.isBaseLayer && this.layer.map) { 253 this.layer.map.setBaseLayer(this.layer); 254 } 255 this.layer.setVisibility(checked); 256 }, 257 245 258 /** private: method[addStoreEventHandlers] 246 259 * Adds handlers that make sure the node disappeares when the layer is 247 260 * removed from the store, and appears when it is re-added. 248 261 */ 249 262 addStoreEventHandlers: function() { 250 263 this.layerStore.on({ 251 "add": function(store, records, index) { 252 var l; 253 for(var i=0; i<records.length; ++i) { 254 l = records[i].get("layer"); 255 if(this.layer == l) { 256 this.getUI().show(); 257 } else if (this.layer == l.name) { 258 // layer is a string, which means the node has not yet 259 // been rendered because the layer was not found. But 260 // now we have the layer and can render. 261 this.render(bulkRender); 262 return; 263 } 264 } 265 }, 266 "remove": function(store, record, index) { 267 if(this.layer == record.get("layer")) { 268 this.getUI().hide(); 269 } 270 }, 264 "add": this.onStoreAdd, 265 "remove": this.onStoreRemove, 271 266 scope: this 272 267 }); 273 268 }, 274 269 270 /** private: method[onStoreAdd] 271 * :param store: ``Ext.data.Store`` 272 * :param records: ``Array(Ext.data.Record)`` 273 * :param index: ``Nmber`` 274 * handler for add events on the store 275 */ 276 onStoreAdd: function(store, records, index) { 277 var l; 278 for(var i=0; i<records.length; ++i) { 279 l = records[i].get("layer"); 280 if(this.layer == l) { 281 this.getUI().show(); 282 } else if (this.layer == l.name) { 283 // layer is a string, which means the node has not yet 284 // been rendered because the layer was not found. But 285 // now we have the layer and can render. 286 this.render(bulkRender); 287 return; 288 } 289 } 290 }, 291 292 /** private: method[onStoreRemove] 293 * :param store: ``Ext.data.Store`` 294 * :param record: ``Ext.data.Record`` 295 * :param index: ``Nmber`` 296 * handler for remove events on the store 297 */ 298 onStoreRemove: function(store, record, index) { 299 if(this.layer == record.get("layer")) { 300 this.getUI().hide(); 301 } 302 }, 303 275 304 /** private: method[addChildNodes] 276 305 * Calls the add method of a node type configured as ``childNodeType`` 277 306 * to add children. … … 282 311 } else if(typeof this.childNodeType.add === "function") { 283 312 this.childNodeType.add(this); 284 313 } 314 }, 315 316 /** private: method[destroy] 317 */ 318 destroy: function() { 319 this.layer.events.un("visibilitychanged", this, 320 this.onLayerVisibilityChanged); 321 delete this.layer; 322 this.layerStore.un("add", this.onStoreAdd, this); 323 this.layerStore.un("remove", this.onStoreRemove, this); 324 delete this.layerStore; 325 this.un("checkchange", this.onCheckChange, this); 326 327 GeoExt.tree.LayerNode.superclass.destroy.call(this); 285 328 } 286 329 }); 287 330