Changeset 6435
- Timestamp:
- 03/04/08 19:07:46 (10 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Control.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Events.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (2 diffs)
- trunk/openlayers/tests/test_Control.html (modified) (1 diff)
- trunk/openlayers/tests/test_Layer.html (modified) (1 diff)
- trunk/openlayers/tests/test_Map.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control.js
r6230 r6435 105 105 handler: null, 106 106 107 /** 108 * APIProperty: eventListeners 109 * {Object} If set as an option at construction, the eventListeners 110 * object will be registered with <OpenLayers.Events.on>. Object 111 * structure must be a listeners object as shown in the example for 112 * the events.on method. 113 */ 114 eventListeners: null, 115 107 116 /** 108 117 * Property: events … … 156 165 157 166 this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES); 167 if(this.eventListeners instanceof Object) { 168 this.events.on(this.eventListeners); 169 } 158 170 this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 159 171 }, … … 231 243 this.position = px.clone(); 232 244 } 233 this.moveTo(this.position); 245 this.moveTo(this.position); 234 246 return this.div; 235 247 }, trunk/openlayers/lib/OpenLayers/Events.js
r6200 r6435 652 652 evt.object = this.object; 653 653 evt.element = this.element; 654 if(!evt.type) { 655 evt.type = type; 656 } 654 657 655 658 // execute all callbacks registered for specified type trunk/openlayers/lib/OpenLayers/Layer.js
r6332 r6435 140 140 141 141 /** 142 * APIProperty: eventListeners 143 * {Object} If set as an option at construction, the eventListeners 144 * object will be registered with <OpenLayers.Events.on>. Object 145 * structure must be a listeners object as shown in the example for 146 * the events.on method. 147 */ 148 eventListeners: null, 149 150 /** 142 151 * APIProperty: gutter 143 152 * {Integer} Determines the width (in pixels) of the gutter around image … … 273 282 this.events = new OpenLayers.Events(this, this.div, 274 283 this.EVENT_TYPES); 284 if(this.eventListeners instanceof Object) { 285 this.events.on(this.eventListeners); 286 } 287 275 288 } 276 289 trunk/openlayers/lib/OpenLayers/Map.js
r6423 r6435 338 338 339 339 /** 340 * APIProperty: eventListeners 341 * {Object} If set as an option at construction, the eventListeners 342 * object will be registered with <OpenLayers.Events.on>. Object 343 * structure must be a listeners object as shown in the example for 344 * the events.on method. 345 */ 346 eventListeners: null, 347 348 /** 340 349 * Property: panMethod 341 350 * {Function} The Easing function to be used for tweening. Default is … … 409 418 this.fallThrough); 410 419 this.updateSize(); 420 if(this.eventListeners instanceof Object) { 421 this.events.on(this.eventListeners); 422 } 411 423 412 424 // update the map size and location before the map moves trunk/openlayers/tests/test_Control.html
r5910 r6435 30 30 } 31 31 32 function test_eventListeners(t) { 33 t.plan(1); 34 35 var method = OpenLayers.Events.prototype.on; 36 // test that events.on is called at control construction 37 var options = { 38 eventListeners: {foo: "bar"} 39 }; 40 OpenLayers.Events.prototype.on = function(obj) { 41 t.eq(obj, options.eventListeners, "events.on called with eventListeners"); 42 } 43 var control = new OpenLayers.Control(options); 44 OpenLayers.Events.prototype.on = method; 45 control.destroy(); 46 47 // if events.on is called again, this will fail due to an extra test 48 // test control without eventListeners 49 OpenLayers.Events.prototype.on = function(obj) { 50 t.fail("events.on called without eventListeners"); 51 } 52 var control2 = new OpenLayers.Control(); 53 OpenLayers.Events.prototype.on = method; 54 control2.destroy(); 55 } 56 32 57 function test_Control_destroy(t) { 33 58 t.plan(3); trunk/openlayers/tests/test_Layer.html
r6332 r6435 120 120 } 121 121 122 function test_eventListeners(t) { 123 t.plan(1); 124 125 var method = OpenLayers.Events.prototype.on; 126 // test that events.on is called at layer construction 127 var options = { 128 eventListeners: {foo: "bar"} 129 }; 130 OpenLayers.Events.prototype.on = function(obj) { 131 t.eq(obj, options.eventListeners, "events.on called with eventListeners"); 132 } 133 var layer = new OpenLayers.Layer("test", options); 134 OpenLayers.Events.prototype.on = method; 135 layer.destroy(); 136 137 // if events.on is called again, this will fail due to an extra test 138 // test layer without eventListeners 139 OpenLayers.Events.prototype.on = function(obj) { 140 t.fail("events.on called without eventListeners"); 141 } 142 var layer2 = new OpenLayers.Layer("test"); 143 OpenLayers.Events.prototype.on = method; 144 layer2.destroy(); 145 } 146 122 147 function test_Layer_initResolutions(t) { 123 148 t.plan(12); trunk/openlayers/tests/test_Map.html
r6111 r6435 84 84 t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" ); 85 85 t.eq( map.theme, 'foo', "map theme set correctly." ); 86 } 87 88 function test_eventListeners(t) { 89 t.plan(1); 90 91 var method = OpenLayers.Events.prototype.on; 92 // test that events.on is called at map construction 93 var options = { 94 eventListeners: {foo: "bar"}, 95 controls: [] 96 }; 97 OpenLayers.Events.prototype.on = function(obj) { 98 t.eq(obj, options.eventListeners, "events.on called with eventListeners"); 99 } 100 var map = new OpenLayers.Map('map', options); 101 OpenLayers.Events.prototype.on = method; 102 map.destroy(); 103 104 // if events.on is called again, this will fail due to an extra test 105 // test map without eventListeners 106 OpenLayers.Events.prototype.on = function(obj) { 107 t.fail("events.on called without eventListeners"); 108 } 109 var map2 = new OpenLayers.Map("map", {controls: []}); 110 OpenLayers.Events.prototype.on = method; 111 map2.destroy(); 86 112 } 87 113
