patch for #809 - add the addEventType() function to the OpenLayers.Events objects so that subclasses can safely add new event types without modifying their parents' constant values
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3622 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -410,7 +410,7 @@ OpenLayers.Events.prototype = {
|
||||
// custom application event.
|
||||
if (this.eventTypes != null) {
|
||||
for (var i = 0; i < this.eventTypes.length; i++) {
|
||||
this.listeners[ this.eventTypes[i] ] = new Array();
|
||||
this.addEventType(this.eventTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,6 +437,20 @@ OpenLayers.Events.prototype = {
|
||||
this.eventHandler = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: addEventType
|
||||
* Add a new event type to this events object.
|
||||
* If the event type has already been added, do nothing.
|
||||
*
|
||||
* Parameters:
|
||||
* eventName - {String}
|
||||
*/
|
||||
addEventType: function(eventName) {
|
||||
if (!this.listeners[eventName]) {
|
||||
this.listeners[eventName] = new Array();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: attachToElement
|
||||
*
|
||||
@@ -449,9 +463,7 @@ OpenLayers.Events.prototype = {
|
||||
|
||||
// every browser event has a corresponding application event
|
||||
// (whether it's listened for or not).
|
||||
if (this.listeners[eventType] == null) {
|
||||
this.listeners[eventType] = new Array();
|
||||
}
|
||||
this.addEventType(eventType);
|
||||
|
||||
// use Prototype to register the event cross-browser
|
||||
OpenLayers.Event.observe(element, eventType, this.eventHandler);
|
||||
|
||||
Reference in New Issue
Block a user