adding commenting/readability to initialize()

git-svn-id: http://svn.openlayers.org/trunk/openlayers@864 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-04 11:25:54 +00:00
parent 1301102b1a
commit 5544bbf134
+25 -14
View File
@@ -28,6 +28,7 @@ OpenLayers.Events.prototype = {
/** @type Array: list of support application events */ /** @type Array: list of support application events */
eventTypes: null, eventTypes: null,
/** /**
* @constructor * @constructor
* *
@@ -37,31 +38,41 @@ OpenLayers.Events.prototype = {
* @param {Array} eventTypes Array of custom application events * @param {Array} eventTypes Array of custom application events
*/ */
initialize: function (object, div, eventTypes) { initialize: function (object, div, eventTypes) {
this.listeners = {};
this.object = object; this.object = object;
this.div = div; this.div = div;
this.eventTypes = eventTypes; this.eventTypes = eventTypes;
if (eventTypes) { this.listeners = new Object();
// if eventTypes is specified, create a listeners list for each
// custom application event.
if (eventTypes != null) {
for (var i = 0; i < this.eventTypes.length; i++) { for (var i = 0; i < this.eventTypes.length; i++) {
// create a listener list for every custom application event this.listeners[ this.eventTypes[i] ] = new Array();
this.listeners[ this.eventTypes[i] ] = [];
} }
} }
for (var i = 0; i < this.BROWSER_EVENTS.length; i++) {
var eventType = this.BROWSER_EVENTS[i];
// every browser event has a corresponding application event // if a dom element is specified, add a listeners list
// (whether it's listened for or not). // for browser events on the element and register them
this.listeners[ eventType ] = []; if (div != null) {
Event.observe(div, eventType, for (var i = 0; i < this.BROWSER_EVENTS.length; i++) {
this.handleBrowserEvent.bindAsEventListener(this)); var eventType = this.BROWSER_EVENTS[i];
// every browser event has a corresponding application event
// (whether it's listened for or not).
this.listeners[ eventType ] = new Array();
// use Prototype to register the event cross-browser
Event.observe(div, eventType,
this.handleBrowserEvent.bindAsEventListener(this));
}
// disable dragstart in IE so that mousedown/move/up works normally
Event.observe(div, "dragstart", Event.stop);
} }
// disable dragstart in IE so that mousedown/move/up works normally
Event.observe(div, "dragstart", Event.stop);
}, },
/** /**