From 381763c19ef42708e787b70b95c3a303eef9e0bb Mon Sep 17 00:00:00 2001 From: thatcher Date: Fri, 16 Dec 2011 22:14:10 -0500 Subject: [PATCH] doh! had changed file name and class name of eventhandlerlist to just eventhandler and guess to forgot to add it back to git. plus other commits including version build id increment --- build.properties | 2 +- openseadragon.js | 2 +- src/eventhandler.js | 54 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/eventhandler.js diff --git a/build.properties b/build.properties index 885d1a13..4d736be3 100644 --- a/build.properties +++ b/build.properties @@ -6,7 +6,7 @@ PROJECT: openseadragon BUILD_MAJOR: 0 BUILD_MINOR: 8 -BUILD_ID: 12 +BUILD_ID: 13 BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} diff --git a/openseadragon.js b/openseadragon.js index bfaa9073..1670da99 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -3,7 +3,7 @@ * (c) 2010 OpenSeadragon * (c) 2010 CodePlex Foundation * - * OpenSeadragon 0.8.12 + * OpenSeadragon 0.8.13 * ---------------------------------------------------------------------------- * * License: New BSD License (BSD) diff --git a/src/eventhandler.js b/src/eventhandler.js new file mode 100644 index 00000000..019e6154 --- /dev/null +++ b/src/eventhandler.js @@ -0,0 +1,54 @@ + +(function($){ + + + $.EventHandler = function() { + this.events = {}; + }; + + $.EventHandler.prototype = { + + addHandler: function(id, handler) { + var events = this.events[ id ]; + if( !events ){ + this.events[ id ] = events = []; + } + events[events.length] = handler; + }, + + removeHandler: function(id, handler) { + //Start Thatcher - unneccessary indirection. Also, because events were + // - not actually being removed, we need to add the code + // - to do the removal ourselves. TODO + var evt = this.events[ id ]; + if (!evt) return; + //End Thatcher + }, + + getHandler: function(id) { + var evt = this.events[ id ]; + if (!evt || !evt.length) return null; + evt = evt.length === 1 ? + [evt[0]] : + Array.apply( null, evt ); + return function(source, args) { + for (var i = 0, l = evt.length; i < l; i++) { + evt[i](source, args); + } + }; + }, + + raiseEvent: function(eventName, eventArgs) { + var handler = this.getHandler( eventName ); + + if (handler) { + if (!eventArgs) { + eventArgs = new Object(); + } + + handler(this, eventArgs); + } + } + }; + +}( OpenSeadragon ));