added removeAllHandlers per macreery's branch, finally implemented removeHandler

This commit is contained in:
thatcher 2013-02-13 17:11:33 -05:00
parent e851de80b8
commit 27d2898818
3 changed files with 47 additions and 13 deletions

View File

@ -6,7 +6,7 @@
PROJECT: openseadragon PROJECT: openseadragon
BUILD_MAJOR: 0 BUILD_MAJOR: 0
BUILD_MINOR: 9 BUILD_MINOR: 9
BUILD_ID: 116 BUILD_ID: 117
BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} BUILD: ${PROJECT}.${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID} VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}

View File

@ -1,7 +1,7 @@
/*globals OpenSeadragon*/ /*globals OpenSeadragon*/
/** /**
* @version OpenSeadragon 0.9.116 * @version OpenSeadragon 0.9.117
* *
* @fileOverview * @fileOverview
* <h2> * <h2>
@ -1924,16 +1924,33 @@ $.EventHandler.prototype = {
* @param {Function} handler - Function to be removed. * @param {Function} handler - Function to be removed.
*/ */
removeHandler: function( eventName, handler ) { removeHandler: function( eventName, handler ) {
//Start Thatcher - unneccessary indirection. Also, because events were var events = this.events[ eventName ],
// - not actually being removed, we need to add the code handlers = [],
// - to do the removal ourselves. TODO i;
var events = this.events[ eventName ];
if ( !events ){ if ( !events ){
return; return;
} }
//End Thatcher if( $.isArray( events ) ){
for( i = 0; i < events.length; i++ ){
if( events[ i ] !== handler ){
handlers.push( handler );
}
}
this.events[ eventName ] = handlers;
}
}, },
/**
* Remove all event handler for a given event type.
* @function
* @param {String} eventName - Name of event for which all handlers are to be removed.
*/
removeAllHandlers: function( eventName ){
this.events[ eventName ] = [];
},
/** /**
* Retrive the list of all handlers registered for a given event. * Retrive the list of all handlers registered for a given event.
* @function * @function
@ -3500,7 +3517,6 @@ $.Viewer = function( options ) {
this.element = this.element || document.getElementById( this.id ); this.element = this.element || document.getElementById( this.id );
this.canvas = $.makeNeutralElement( "div" ); this.canvas = $.makeNeutralElement( "div" );
//this.container = $.makeNeutralElement( "div" );
this.canvas.className = "openseadragon-canvas"; this.canvas.className = "openseadragon-canvas";
(function( canvas ){ (function( canvas ){
@ -3512,6 +3528,7 @@ $.Viewer = function( options ) {
canvas.left = "0px"; canvas.left = "0px";
}( this.canvas.style )); }( this.canvas.style ));
//the container is created through applying the ControlDock constructor above
this.container.className = "openseadragon-container"; this.container.className = "openseadragon-container";
(function( container ){ (function( container ){
container.width = "100%"; container.width = "100%";

View File

@ -41,16 +41,33 @@ $.EventHandler.prototype = {
* @param {Function} handler - Function to be removed. * @param {Function} handler - Function to be removed.
*/ */
removeHandler: function( eventName, handler ) { removeHandler: function( eventName, handler ) {
//Start Thatcher - unneccessary indirection. Also, because events were var events = this.events[ eventName ],
// - not actually being removed, we need to add the code handlers = [],
// - to do the removal ourselves. TODO i;
var events = this.events[ eventName ];
if ( !events ){ if ( !events ){
return; return;
} }
//End Thatcher if( $.isArray( events ) ){
for( i = 0; i < events.length; i++ ){
if( events[ i ] !== handler ){
handlers.push( handler );
}
}
this.events[ eventName ] = handlers;
}
}, },
/**
* Remove all event handler for a given event type.
* @function
* @param {String} eventName - Name of event for which all handlers are to be removed.
*/
removeAllHandlers: function( eventName ){
this.events[ eventName ] = [];
},
/** /**
* Retrive the list of all handlers registered for a given event. * Retrive the list of all handlers registered for a given event.
* @function * @function