Ticket #90: 90.patch
| File 90.patch, 7.5 kB (added by tschaub, 3 years 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({ 229 "visibilitychanged": this.onLayerVisibilityChanged, 230 scope: this 231 }); 234 232 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 }, 233 "checkchange": this.onCheckChange, 241 234 scope: this 242 235 }); 243 236 }, 244 237 238 /** private: method[onLayerVisiilityChanged 239 * handler for visibilitychanged events on the layer 240 */ 241 onLayerVisibilityChanged: function() { 242 if(!this.visibilityChanging && 243 this.attributes.checked != this.layer.getVisibility()) { 244 this.getUI().toggleCheck(this.layer.getVisibility()); 245 } 246 }, 247 248 /** private: method[onCheckChange] 249 * :param node: ``GeoExt.tree.LayerNode`` 250 * :param checked: ``Boolean`` 251 * handler for checkchange events 252 */ 253 onCheckChange: function(node, checked) { 254 if (checked && this.layer.isBaseLayer && this.layer.map) { 255 this.layer.map.setBaseLayer(this.layer); 256 } 257 this.layer.setVisibility(checked); 258 }, 259 245 260 /** private: method[addStoreEventHandlers] 246 261 * Adds handlers that make sure the node disappeares when the layer is 247 262 * removed from the store, and appears when it is re-added. 248 263 */ 249 264 addStoreEventHandlers: function() { 250 265 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 }, 266 "add": this.onStoreAdd, 267 "remove": this.onStoreRemove, 271 268 scope: this 272 269 }); 273 270 }, 274 271 272 /** private: method[onStoreAdd] 273 * :param store: ``Ext.data.Store`` 274 * :param records: ``Array(Ext.data.Record)`` 275 * :param index: ``Nmber`` 276 * handler for add events on the store 277 */ 278 onStoreAdd: function(store, records, index) { 279 var l; 280 for(var i=0; i<records.length; ++i) { 281 l = records[i].get("layer"); 282 if(this.layer == l) { 283 this.getUI().show(); 284 } else if (this.layer == l.name) { 285 // layer is a string, which means the node has not yet 286 // been rendered because the layer was not found. But 287 // now we have the layer and can render. 288 this.render(bulkRender); 289 return; 290 } 291 } 292 }, 293 294 /** private: method[onStoreRemove] 295 * :param store: ``Ext.data.Store`` 296 * :param record: ``Ext.data.Record`` 297 * :param index: ``Nmber`` 298 * handler for remove events on the store 299 */ 300 onStoreRemove: function(store, record, index) { 301 if(this.layer == record.get("layer")) { 302 this.getUI().hide(); 303 } 304 }, 305 275 306 /** private: method[addChildNodes] 276 307 * Calls the add method of a node type configured as ``childNodeType`` 277 308 * to add children. … … 282 313 } else if(typeof this.childNodeType.add === "function") { 283 314 this.childNodeType.add(this); 284 315 } 316 }, 317 318 /** private: method[destroy] 319 */ 320 destroy: function() { 321 this.layer.events.un({ 322 "visibilitychanged": this.onLayerVisibilityChanged, 323 scope: this 324 }); 325 delete this.layer; 326 this.layerStore.un("add", this.onStoreAdd, this); 327 this.layerStore.un("remove", this.onStoreRemove, this); 328 delete this.layerStore; 329 this.un("checkchange", this.onCheckChange, this); 330 331 GeoExt.tree.LayerNode.superclass.destroy.call(this); 285 332 } 286 333 }); 287 334