Changeset 6155
- Timestamp:
- 02/08/08 20:09:15 (10 months ago)
- Files:
-
- sandbox/tschaub/events/lib/OpenLayers/Control.js (modified) (6 diffs)
- sandbox/tschaub/events/lib/OpenLayers/Control/Panel.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/tschaub/events/lib/OpenLayers/Control.js
r6125 r6155 105 105 handler: null, 106 106 107 /** 108 * Property: events 109 * {<OpenLayers.Events>} Events instance for triggering control specific 110 * events. 111 */ 112 events: null, 113 114 /** 115 * Constant: EVENT_TYPES 116 * {Array(String)} Supported application event types. Register a listener 117 * for a particular event with the following syntax: 118 * (code) 119 * layer.events.register(type, obj, listener); 120 * (end) 121 * 122 * Listeners will be called with a reference to an event object. The 123 * properties of this event depends on exactly what happened. 124 * 125 * All event objects have at least the following properties: 126 * - *object* {Object} A reference to control.events.object (a reference 127 * to the control). 128 * - *element* {DOMElement} A reference to control.events.element (which 129 * will be null unless documented otherwise). 130 * 131 * Supported map event types: 132 * - *activate* Triggered when layer loading starts. 133 * - *deactivate* Triggered when layer loading ends. 134 */ 135 EVENT_TYPES: ["activate", "deactivate"], 136 107 137 /** 108 138 * Constructor: OpenLayers.Control … … 125 155 OpenLayers.Util.extend(this, options); 126 156 157 this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES); 127 158 this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 128 159 }, … … 135 166 */ 136 167 destroy: function () { 168 this.events.destroy(); 137 169 // eliminate circular references 138 170 if (this.handler) { … … 196 228 this.position = px.clone(); 197 229 } 198 this.moveTo(this.position); 230 this.moveTo(this.position); 199 231 return this.div; 200 232 }, … … 233 265 } 234 266 this.active = true; 267 this.events.triggerEvent("activate"); 235 268 return true; 236 269 }, … … 251 284 } 252 285 this.active = false; 286 this.events.triggerEvent("deactivate"); 253 287 return true; 254 288 } sandbox/tschaub/events/lib/OpenLayers/Control/Panel.js
r5910 r6155 46 46 OpenLayers.Control.prototype.destroy.apply(this, arguments); 47 47 for(var i = this.controls.length - 1 ; i >= 0; i--) { 48 this.controls[i].events.un({ 49 "activate": this.redraw, 50 "deactivate": this.redraw, 51 scope: this 52 }); 48 53 OpenLayers.Event.stopObservingElement(this.controls[i].panel_div); 49 54 this.controls[i].panel_div = null; … … 61 66 } 62 67 } 63 this.redraw();64 68 return true; 65 69 } else { … … 76 80 this.controls[i].deactivate(); 77 81 } 78 this.redraw();79 82 return true; 80 83 } else { … … 94 97 this.map.addControl(this.controls[i]); 95 98 this.controls[i].deactivate(); 99 this.controls[i].events.on({ 100 "activate": this.redraw, 101 "deactivate": this.redraw, 102 scope: this 103 }); 96 104 } 97 105 this.activate(); … … 103 111 */ 104 112 redraw: function() { 113 console.log('asdf'); 105 114 this.div.innerHTML = ""; 106 115 if (this.active) { … … 146 155 } 147 156 } 148 this.redraw();149 157 }, 150 158 … … 186 194 this.map.addControl(controls[i]); 187 195 controls[i].deactivate(); 196 controls[i].events.on({ 197 "activate": this.redraw, 198 "deactivate": this.redraw, 199 scope: this 200 }); 188 201 } 189 202 this.redraw();
