From 1301102b1a700c57a0beb1337e10ac1c627929ce Mon Sep 17 00:00:00 2001 From: euzuro Date: Tue, 4 Jul 2006 11:18:06 +0000 Subject: [PATCH] adding commenting/readability to triggerEvent() git-svn-id: http://svn.openlayers.org/trunk/openlayers@863 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Events.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index 2a47496216..d387d3c72b 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -106,17 +106,26 @@ OpenLayers.Events.prototype = { * @param {Event} evt */ triggerEvent: function (type, evt) { + + // prep evt object with object & div references if (evt == null) { - evt = {}; + evt = new Object(); } evt.object = this.object; evt.div = this.div; + // execute all callbacks registered for specified type var listeners = this.listeners[type]; for (var i = 0; i < listeners.length; i++) { var callback = listeners[i]; + + // use the 'call' method to bind the context to callback.obj var continueChain = callback.func.call(callback.obj, evt); - if (continueChain != null && !continueChain) break; + + if ((continueChain != null) && (continueChain == false)) { + // if callback returns false, execute no more callbacks. + break; + } } },