Changeset 6149
- Timestamp:
- 02/08/08 18:31:27 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Control/Attribution.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MouseDefaults.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Control/Permalink.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Events.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Vector.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WFS.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (6 diffs)
- trunk/openlayers/lib/OpenLayers/Popup.js (modified) (1 diff)
- trunk/openlayers/tests/Control/test_ModifyFeature.html (modified) (9 diffs)
- trunk/openlayers/tests/Control/test_SelectFeature.html (modified) (1 diff)
- trunk/openlayers/tests/Layer/test_Grid.html (modified) (1 diff)
- trunk/openlayers/tests/test_Events.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/Attribution.js
r6131 r6149 36 36 */ 37 37 destroy: function() { 38 this.map.events.unregister("removelayer", this, this.updateAttribution); 39 this.map.events.unregister("addlayer", this, this.updateAttribution); 40 this.map.events.unregister("changelayer", this, this.updateAttribution); 41 this.map.events.unregister("changebaselayer", this, this.updateAttribution); 38 this.map.events.un({ 39 "removelayer": this.updateAttribution, 40 "addlayer": this.updateAttribution, 41 "changelayer": this.updateAttribution, 42 "changebaselayer": this.updateAttribution, 43 scope: this 44 }); 42 45 43 46 OpenLayers.Control.prototype.destroy.apply(this, arguments); … … 54 57 OpenLayers.Control.prototype.draw.apply(this, arguments); 55 58 56 this.map.events.register('changebaselayer', this, this.updateAttribution); 57 this.map.events.register('changelayer', this, this.updateAttribution); 58 this.map.events.register('addlayer', this, this.updateAttribution); 59 this.map.events.register('removelayer', this, this.updateAttribution); 59 this.map.events.on({ 60 'changebaselayer': this.updateAttribution, 61 'changelayer': this.updateAttribution, 62 'addlayer': this.updateAttribution, 63 'removelayer': this.updateAttribution, 64 scope: this 65 }); 60 66 this.updateAttribution(); 61 67 trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js
r5614 r6149 114 114 this.clearLayersArray("data"); 115 115 116 this.map.events.unregister("addlayer", this, this.redraw); 117 this.map.events.unregister("changelayer", this, this.redraw); 118 this.map.events.unregister("removelayer", this, this.redraw); 119 this.map.events.unregister("changebaselayer", this, this.redraw); 116 this.map.events.un({ 117 "addlayer": this.redraw, 118 "changelayer": this.redraw, 119 "removelayer": this.redraw, 120 "changebaselayer": this.redraw, 121 scope: this 122 }); 120 123 121 124 OpenLayers.Control.prototype.destroy.apply(this, arguments); … … 131 134 OpenLayers.Control.prototype.setMap.apply(this, arguments); 132 135 133 this.map.events.register("addlayer", this, this.redraw); 134 this.map.events.register("changelayer", this, this.redraw); 135 this.map.events.register("removelayer", this, this.redraw); 136 this.map.events.register("changebaselayer", this, this.redraw); 136 this.map.events.on({ 137 "addlayer": this.redraw, 138 "changelayer": this.redraw, 139 "removelayer": this.redraw, 140 "changebaselayer": this.redraw, 141 scope: this 142 }); 137 143 }, 138 144 trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js
r6131 r6149 183 183 geometryTypes: this.geometryTypes, 184 184 clickout: this.clickout, 185 toggle: this.toggle, 186 onSelect: function(feature) { 187 control.selectFeature.apply(control, [feature]); 188 }, 189 onUnselect: function(feature) { 190 control.unselectFeature.apply(control, [feature]); 191 } 185 toggle: this.toggle 192 186 }; 193 187 this.selectControl = new OpenLayers.Control.SelectFeature( 194 188 layer, selectOptions 195 189 ); 190 this.layer.events.on({ 191 "featureselected": this.selectFeature, 192 "featureunselected": this.unselectFeature, 193 scope: this 194 }); 196 195 197 196 // configure the drag control … … 227 226 */ 228 227 destroy: function() { 228 this.layer.events.un({ 229 "featureselected": this.selectFeature, 230 "featureunselected": this.unselectFeature, 231 scope: this 232 }); 229 233 this.layer = null; 230 234 this.selectControl.destroy(); … … 277 281 * 278 282 * Parameters: 279 * feature - {<OpenLayers.Feature.Vector>} The selected feature. 280 */ 281 selectFeature: function(feature) { 282 this.feature = feature; 283 * object - {Object} Object with a feature property referencing the 284 * selected feature. 285 */ 286 selectFeature: function(object) { 287 this.feature = object.feature; 283 288 this.resetVertices(); 284 289 this.dragControl.activate(); … … 291 296 * 292 297 * Parameters: 293 * feature - {<OpenLayers.Feature.Vector>} The unselected feature. 294 */ 295 unselectFeature: function(feature) { 298 * object - {Object} Object with a feature property referencing the 299 * unselected feature. 300 */ 301 unselectFeature: function(object) { 296 302 this.layer.removeFeatures(this.vertices); 297 303 this.vertices = []; … … 308 314 this.feature = null; 309 315 this.dragControl.deactivate(); 310 this.onModificationEnd( feature);316 this.onModificationEnd(object.feature); 311 317 }, 312 318 trunk/openlayers/lib/OpenLayers/Control/MouseDefaults.js
r6004 r6149 48 48 this.handler = null; 49 49 50 this.map.events.unregister( "click", this, this.defaultClick ); 51 this.map.events.unregister( "dblclick", this, this.defaultDblClick ); 52 this.map.events.unregister( "mousedown", this, this.defaultMouseDown ); 53 this.map.events.unregister( "mouseup", this, this.defaultMouseUp ); 54 this.map.events.unregister( "mousemove", this, this.defaultMouseMove ); 55 this.map.events.unregister( "mouseout", this, this.defaultMouseOut ); 50 this.map.events.un({ 51 "click": this.defaultClick, 52 "dblclick": this.defaultDblClick, 53 "mousedown": this.defaultMouseDown, 54 "mouseup": this.defaultMouseUp, 55 "mousemove": this.defaultMouseMove, 56 "mouseout": this.defaultMouseOut, 57 scope: this 58 }); 56 59 57 60 //unregister mousewheel events specifically on the window and document … … 71 74 */ 72 75 draw: function() { 73 this.map.events.register( "click", this, this.defaultClick ); 74 this.map.events.register( "dblclick", this, this.defaultDblClick ); 75 this.map.events.register( "mousedown", this, this.defaultMouseDown ); 76 this.map.events.register( "mouseup", this, this.defaultMouseUp ); 77 this.map.events.register( "mousemove", this, this.defaultMouseMove ); 78 this.map.events.register( "mouseout", this, this.defaultMouseOut ); 76 this.map.events.on({ 77 "click": this.defaultClick, 78 "dblclick": this.defaultDblClick, 79 "mousedown": this.defaultMouseDown, 80 "mouseup": this.defaultMouseUp, 81 "mousemove": this.defaultMouseMove, 82 "mouseout": this.defaultMouseOut, 83 scope: this 84 }); 79 85 80 86 this.registerWheelEvents(); trunk/openlayers/lib/OpenLayers/Control/MouseToolbar.js
r5614 r6149 106 106 107 107 btn.events = new OpenLayers.Events(this, btn, null, true); 108 btn.events.register("mousedown", this, this.buttonDown); 109 btn.events.register("mouseup", this, this.buttonUp); 110 btn.events.register("dblclick", this, OpenLayers.Event.stop); 108 btn.events.on({ 109 "mousedown": this.buttonDown, 110 "mouseup": this.buttonUp, 111 "dblclick": OpenLayers.Event.stop, 112 scope: this 113 }); 111 114 btn.action = id; 112 115 btn.title = title; trunk/openlayers/lib/OpenLayers/Control/OverviewMap.js
r6111 r6149 155 155 } 156 156 157 this.map.events.unregister('moveend', this, this.update); 158 this.map.events.unregister("changebaselayer", this, 159 this.baseLayerDraw); 157 this.map.events.un({ 158 "moveend": this.update, 159 "changebaselayer": this.baseLayerDraw, 160 scope: this 161 }); 160 162 161 163 OpenLayers.Control.prototype.destroy.apply(this, arguments); trunk/openlayers/lib/OpenLayers/Control/PanZoomBar.js
r5614 r6149 80 80 this.divEvents = null; 81 81 82 this.map.events.unregister("zoomend", this, this.moveZoomBar); 83 this.map.events.unregister("changebaselayer", this, this.redraw); 82 this.map.events.un({ 83 "zoomend": this.moveZoomBar, 84 "changebaselayer": this.redraw, 85 scope: this 86 }); 84 87 85 88 OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments); … … 165 168 166 169 this.sliderEvents = new OpenLayers.Events(this, slider, null, true); 167 this.sliderEvents.register("mousedown", this, this.zoomBarDown); 168 this.sliderEvents.register("mousemove", this, this.zoomBarDrag); 169 this.sliderEvents.register("mouseup", this, this.zoomBarUp); 170 this.sliderEvents.register("dblclick", this, this.doubleClick); 171 this.sliderEvents.register("click", this, this.doubleClick); 170 this.sliderEvents.on({ 171 "mousedown": this.zoomBarDown, 172 "mousemove": this.zoomBarDrag, 173 "mouseup": this.zoomBarUp, 174 "dblclick": this.doubleClick, 175 "click": this.doubleClick 176 }); 172 177 173 178 var sz = new OpenLayers.Size(); … … 195 200 196 201 this.divEvents = new OpenLayers.Events(this, div, null, true); 197 this.divEvents.register("mousedown", this, this.divClick); 198 this.divEvents.register("mousemove", this, this.passEventToSlider); 199 this.divEvents.register("dblclick", this, this.doubleClick); 200 this.divEvents.register("click", this, this.doubleClick); 202 this.divEvents.on({ 203 "mousedown": this.divClick, 204 "mousemove": this.passEventToSlider, 205 "dblclick": this.doubleClick, 206 "click": this.doubleClick 207 }); 201 208 202 209 this.div.appendChild(div); … … 251 258 return; 252 259 } 253 this.map.events.register("mousemove", this, this.passEventToSlider); 254 this.map.events.register("mouseup", this, this.passEventToSlider); 260 this.map.events.on({ 261 "mousemove": this.passEventToSlider, 262 "mouseup": this.passEventToSlider, 263 scope: this 264 }); 255 265 this.mouseDragStart = evt.xy.clone(); 256 266 this.zoomStart = evt.xy.clone(); … … 299 309 if (this.zoomStart) { 300 310 this.div.style.cursor=""; 301 this.map.events.unregister("mouseup", this, this.passEventToSlider); 302 this.map.events.unregister("mousemove", this, this.passEventToSlider); 311 this.map.events.un({ 312 "mouseup": this.passEventToSlider, 313 "mousemove": this.passEventToSlider, 314 scope: this 315 }); 303 316 var deltaY = this.zoomStart.y - evt.xy.y; 304 317 this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); trunk/openlayers/lib/OpenLayers/Control/Permalink.js
r5614 r6149 116 116 this.div.appendChild(this.element); 117 117 } 118 this.map.events.register('moveend', this, this.updateLink); 119 this.map.events.register('changelayer', this, this.updateLink); 120 this.map.events.register('changebaselayer', this, this.updateLink); 118 this.map.events.on({ 119 'moveend': this.updateLink, 120 'changelayer': this.updateLink, 121 'changebaselayer': this.updateLink, 122 scope: this 123 }); 121 124 return this.div; 122 125 }, trunk/openlayers/lib/OpenLayers/Control/SelectFeature.js
r5959 r6149 267 267 268 268 this.layer.drawFeature(feature); 269 this.layer.events.triggerEvent("featureselected", {feature: feature}); 269 270 this.onSelect(feature); 270 271 }, … … 285 286 this.layer.drawFeature(feature); 286 287 OpenLayers.Util.removeItem(this.layer.selectedFeatures, feature); 288 this.layer.events.triggerEvent("featureunselected", {feature: feature}); 287 289 this.onUnselect(feature); 288 290 }, trunk/openlayers/lib/OpenLayers/Events.js
r6021 r6149 481 481 // disable dragstart in IE so that mousedown/move/up works normally 482 482 OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop); 483 }, 484 485 /** 486 * Method: on 487 * Convenience method for registering listeners with a common scope. 488 * 489 * Example use: 490 * (code) 491 * events.on({ 492 * "loadstart": loadStartListener, 493 * "loadend": loadEndListener, 494 * scope: object 495 * }); 496 * (end) 497 */ 498 on: function(object) { 499 for(var type in object) { 500 if(type != "scope") { 501 this.register(type, object.scope, object[type]); 502 } 503 } 483 504 }, 484 505 … … 554 575 555 576 /** 577 * Method: un 578 * Convenience method for unregistering listeners with a common scope. 579 * 580 * Example use: 581 * (code) 582 * events.un({ 583 * "loadstart": loadStartListener, 584 * "loadend": loadEndListener, 585 * scope: object 586 * }); 587 * (end) 588 */ 589 un: function(object) { 590 for(var type in object) { 591 if(type != "scope") { 592 this.unregister(type, object.scope, object[type]); 593 } 594 } 595 }, 596 597 /** 556 598 * APIMethod: unregister 557 599 * … … 597 639 * type - {String} 598 640 * evt - {Event} 599 * args - {Array} Optional array of arguments to call the listener with.600 641 * 601 642 * Returns: … … 603 644 * chain of listeners will stop getting called. 604 645 */ 605 triggerEvent: function (type, evt , args) {646 triggerEvent: function (type, evt) { 606 647 607 648 // prep evt object with object & div references … … 611 652 evt.object = this.object; 612 653 evt.element = this.element; 613 614 if(!args) { 615 args = [evt]; 616 } else { 617 args.unshift(evt); 618 } 619 654 620 655 // execute all callbacks registered for specified type 621 656 // get a clone of the listeners array to … … 628 663 var callback = listeners[i]; 629 664 // bind the context to callback.obj 630 continueChain = callback.func.apply(callback.obj, args);665 continueChain = callback.func.apply(callback.obj, [evt]); 631 666 632 667 if ((continueChain != undefined) && (continueChain == false)) { trunk/openlayers/lib/OpenLayers/Layer.js
r5982 r6149 38 38 opacity: null, 39 39 40 /** 40 /** 41 41 * Constant: EVENT_TYPES 42 * {Array(String)} Supported application event types 42 * {Array(String)} Supported application event types. Register a listener 43 * for a particular event with the following syntax: 44 * (code) 45 * layer.events.register(type, obj, listener); 46 * (end) 47 * 48 * Listeners will be called with a reference to an event object. The 49 * properties of this event depends on exactly what happened. 50 * 51 * All event objects have at least the following properties: 52 * - *object* {Object} A reference to layer.events.object. 53 * - *element* {DOMElement} A reference to layer.events.element. 54 * 55 * Supported map event types: 56 * - *loadstart* Triggered when layer loading starts. 57 * - *loadend* Triggered when layer loading ends. 58 * - *loadcancel* Triggered when layer loading is canceled. 59 * - *visibilitychanged* Triggered when layer visibility is changed. 43 60 */ 44 61 EVENT_TYPES: ["loadstart", "loadend", "loadcancel", "visibilitychanged"], … … 328 345 this.name = newName; 329 346 if (this.map != null) { 330 this.map.events.triggerEvent("changelayer"); 347 this.map.events.triggerEvent("changelayer", { 348 layer: this, 349 property: "name" 350 }); 331 351 } 332 352 } … … 531 551 this.redraw(); 532 552 if (this.map != null) { 533 this.map.events.triggerEvent("changelayer"); 553 this.map.events.triggerEvent("changelayer", { 554 layer: this, 555 property: "visibility" 556 }); 534 557 } 535 558 this.events.triggerEvent("visibilitychanged"); … … 577 600 this.isBaseLayer = isBaseLayer; 578 601 if (this.map != null) { 579 this.map.events.triggerEvent("changebaselayer"); 602 this.map.events.triggerEvent("changebaselayer", { 603 layer: this 604 }); 580 605 } 581 606 } trunk/openlayers/lib/OpenLayers/Layer/Grid.js
r5614 r6149 527 527 */ 528 528 removeTileMonitoringHooks: function(tile) { 529 tile.events.unregister("loadstart", this, tile.onLoadStart); 530 tile.events.unregister("loadend", this, tile.onLoadEnd); 529 tile.events.un({ 530 "loadstart": tile.onLoadStart, 531 "loadend": tile.onLoadEnd, 532 scope: this 533 }); 531 534 }, 532 535 trunk/openlayers/lib/OpenLayers/Layer/Vector.js
r5614 r6149 19 19 */ 20 20 OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, { 21 22 /** 23 * Constant: EVENT_TYPES 24 * {Array(String)} Supported application event types. Register a listener 25 * for a particular event with the following syntax: 26 * (code) 27 * layer.events.register(type, obj, listener); 28 * (end) 29 * 30 * Listeners will be called with a reference to an event object. The 31 * properties of this event depends on exactly what happened. 32 * 33 * All event objects have at least the following properties: 34 * - *object* {Object} A reference to layer.events.object. 35 * - *element* {DOMElement} A reference to layer.events.element. 36 * 37 * Supported map event types: 38 * - *loadstart* Triggered when layer loading starts. 39 * - *loadend* Triggered when layer loading ends. 40 * - *loadcancel* Triggered when layer loading is canceled. 41 * - *visibilitychanged* Triggered when layer visibility is changed. 42 * - *beforefeatureadded* Triggered before a feature is added. Listeners 43 * will receive an object with a *feature* property referencing the 44 * feature to be added. 45 * - *featureadded* Triggered after a feature is added. The event 46 * object passed to listeners will have a *feature* property with a 47 * reference to the added feature. 48 * - *featuresadded* Triggered after features are added. The event 49 * object passed to listeners will have a *features* property with a 50 * reference to an array of added features. 51 * - *featureselected* Triggered after a feature is selected. Listeners 52 * will receive an object with a *feature* property referencing the 53 * selected feature. 54 * - *featureunselected* Triggered after a feature is unselected. 55 * Listeners will receive an object with a *feature* property 56 * referencing the unselected feature. 57 */ 58 EVENT_TYPES: ["loadstart", "loadend", "loadcancel", "visibilitychanged", 59 "beforefeatureadded", "featureadded", 60 "featuresadded", "featureselected", "featureunselected"], 21 61 22 62 /** … … 274 314 275 315 if (notify) { 316 this.events.triggerEvent("beforefeatureadded", { 317 feature: feature 318 }); 276 319 this.preFeatureInsert(feature); 277 320 } … … 282 325 283 326 if (notify) { 327 this.events.triggerEvent("featureadded", { 328 feature: feature 329 }); 284 330 this.onFeatureInsert(feature); 285 331 } 332 } 333 334 if(notify) { 335 this.events.triggerEvent("featuresadded", {features: features}); 286 336 } 287 337 }, trunk/openlayers/lib/OpenLayers/Layer/WFS.js
r5989 r6149 354 354 */ 355 355 removeTileMonitoringHooks: function(tile) { 356 tile.events.unregister("loadstart", tile, tile.onLoadStart); 357 tile.events.unregister("loadend", tile, tile.onLoadEnd); 356 tile.events.un({ 357 "loadstart": tile.onLoadStart, 358 "loadend": tile.onLoadEnd, 359 scope: tile 360 }); 358 361 }, 359 362 trunk/openlayers/lib/OpenLayers/Map.js
r6129 r6149 33 33 * (end) 34 34 * 35 * Listeners will be called with a reference to an event object. The 36 * properties of this event depends on exactly what happened. 37 * 38 * All event objects have at least the following properties: 39 * - *object* {Object} A reference to map.events.object. 40 * - *element* {DOMElement} A reference to map.events.element. 41 * 42 * Browser events have the following additional properties: 43 * - *xy* {<OpenLayers.Pixel>} The pixel location of the event (relative 44 * to the the map viewport). 45 * - other properties that come with browser events 46 * 35 47 * Supported map event types: 36 * - *addlayer* triggered after a layer has been added 37 * - *removelayer* triggered after a layer has been removed 48 * - *addlayer* triggered after a layer has been added. The event object 49 * will include a *layer* property that references the added layer. 50 * - *removelayer* triggered after a layer has been removed. The event 51 * object will include a *layer* property that references the removed 52 * layer. 38 53 * - *changelayer* triggered after a layer name change, order change, or 39 * visibility change (due to resolution thresholds) 54 * visibility change (due to resolution thresholds). Listeners will 55 * receive an event object with *layer* and *property* properties. The 56 * *layer* property will be a reference to the changed layer. The 57 * *property* property will be a key to the changed property (name, 58 * visibility, or order). 40 59 * - *movestart* triggered after the start of a drag, pan, or zoom 41 60 * - *move* triggered after each drag, pan, or zoom … … 736 755 } 737 756 738 this.events.triggerEvent("addlayer" );757 this.events.triggerEvent("addlayer", {layer: layer}); 739 758 }, 740 759 … … 809 828 this.resetLayersZIndex(); 810 829 811 this.events.triggerEvent("removelayer" );830 this.events.triggerEvent("removelayer", {layer: layer}); 812 831 }, 813 832 … … 861 880 this.setLayerZIndex(this.layers[i], i); 862 881 } 863 this.events.triggerEvent("changelayer"); 882 this.events.triggerEvent("changelayer", { 883 layer: layer, property: "order" 884 }); 864 885 } 865 886 }, … … 934 955 } 935 956 936 this.events.triggerEvent("changebaselayer"); 957 this.events.triggerEvent("changebaselayer", { 958 layer: this.baseLayer 959 }); 937 960 } 938 961 } … … 1454 1477 layer.display(false); 1455 1478 } 1456 this.events.triggerEvent("changelayer"); 1479 this.events.triggerEvent("changelayer", { 1480 layer: layer, property: "visibility" 1481 }); 1457 1482 } 1458 1483 if (inRange && layer.visibility) { trunk/openlayers/lib/OpenLayers/Popup.js
r6048 r6149 404 404 this.events = new OpenLayers.Events(this, this.div, null, true); 405 405 406 this.events.register("mousedown", this, this.onmousedown); 407 this.events.register("mousemove", this, this.onmousemove); 408 this.events.register("mouseup", this, this.onmouseup); 409 this.events.register("click", this, this.onclick); 410 this.events.register("mouseout", this, this.onmouseout); 411 this.events.register("dblclick", this, this.ondblclick); 406 this.events.on({ 407 "mousedown": this.onmousedown, 408 "mousemove": this.onmousemove, 409 "mouseup": this.onmouseup, 410 "click": this.onclick, 411 "mouseout": this.onmouseout, 412 "dblclick": this.ondblclick, 413 scope: this 414 }); 415 412 416 }, 413 417 trunk/openlayers/tests/Control/test_ModifyFeature.html
r6131 r6149 6 6 function test_ModifyFeature_constructor(t) { 7 7 t.plan(3); 8 var layer = "foo"; 8 var layer = { 9 events: { 10 on: function() {} 11 } 12 }; 9 13 var options = { 10 14 geometryTypes: "bar" … … 12 16 var control = new OpenLayers.Control.ModifyFeature(layer, options); 13 17 14 t. eq(control.layer, "foo",18 t.ok(control.layer == layer, 15 19 "constructor sets layer correctly"); 16 20 t.eq(control.selectControl.geometryTypes, "bar", … … 73 77 */ 74 78 75 var control = new OpenLayers.Control.ModifyFeature({style: null}); 79 var control = new OpenLayers.Control.ModifyFeature({ 80 style: null, 81 events: { 82 on: function() {} 83 } 84 }); 76 85 var delKey = 46; 77 86 var dKey = 100; … … 198 207 t.ok(verts == 'b', "Virtual verts destroyed correctly"); 199 208 } 200 control.unselectFeature( fakeFeature);209 control.unselectFeature({feature: fakeFeature}); 201 210 t.eq(control.feature, null, "feature is set to null"); 202 211 } … … 217 226 218 227 // Points don't call collectVertices 219 control.selectFeature( fakeFeature);228 control.selectFeature({feature: fakeFeature}); 220 229 221 230 control.collectVertices = function() { … … 233 242 234 243 // OnSelect calls collectVertices and passes features to layer 235 control.selectFeature( fakeFeature);244 control.selectFeature({feature: fakeFeature}); 236 245 237 246 control.vertices = ['a']; … … 245 254 246 255 // Features are removed whenever they exist 247 control.selectFeature( fakeFeature);256 control.selectFeature({feature: fakeFeature}); 248 257 249 258 } … … 390 399 "onModificationStart called with the right feature"); 391 400 }; 392 control.selectFeature( testFeature);401 control.selectFeature({feature: testFeature}); 393 402 } 394 403 … … 451 460 "onModificationEnd called with the right feature"); 452 461 }; 453 control.unselectFeature( testFeature);462 control.unselectFeature({feature: testFeature}); 454 463 } 455 464 trunk/openlayers/tests/Control/test_SelectFeature.html
r6131 r6149 79 79 var layer = { 80 80 selectedFeatures: [], 81 drawFeature: function() {} 81 drawFeature: function() {}, 82 events: { 83 triggerEvent: function() {} 84 } 82 85 }; 83 86 // mock up active control trunk/openlayers/tests/Layer/test_Grid.html
r6111 r6149 500 500 unregister: function(name, obj, func) { 501 501 g_unregistered[name] = [obj, func]; 502 } 502 }, 503 un: OpenLayers.Events.prototype.un 503 504 } 504 505 } trunk/openlayers/tests/test_Events.html
r5398 r6149 206 206 events = new OpenLayers.Events(null, null, eventTypes); 207 207 var instance = {id: Math.random()}; 208 var listener = function( ) {208 var listener = function(obj) { 209 209 t.eq(this.id, instance.id, 210 210 "listener called with proper scope"); 211 t.eq(arguments [0].id, evt.id,212 "listener called with evt as first arg");213 t.eq( arguments[1], "arg1",214 "listener called with correct extra arg1");215 t.eq( arguments[2], "arg2",216 " listener called with correct extra arg2");211 t.eq(arguments.length, 1, 212 "listener called with a single argument"); 213 t.eq(typeof arguments, "object", 214 "listener called with an object"); 215 t.eq(obj.foo, evt.foo, 216 "foo property set on the layer"); 217 217 }; 218 218 events.register("something", instance, listener); 219 var evt = {id: Math.random()}; 220 events.triggerEvent("something", evt, ["arg1", "arg2", "arg3"]); 219 var evt = { 220 id: Math.random(), 221 "foo": "bar" 222 }; 223 events.triggerEvent("something", evt); 221 224 events.unregister("something", instance, listener); 222 225
