Merge pull request #239 from msalsbery/TileSource-Event-Signatures

TileSource 'ready' event signature fixed for consistency (#224)
This commit is contained in:
iangilman 2013-10-03 16:18:57 -07:00
commit dcceee5008
3 changed files with 6 additions and 15 deletions

View File

@ -3,6 +3,7 @@ OPENSEADRAGON CHANGELOG
1.0.0: (in progress)
* BREAKING CHANGE: TileSource 'ready' event handler signature changed for consistency to 'handlerMethod( eventSource, eventData)' (#239)
* BREAKING CHANGE: Renamed EventHandler to EventSource (#225)
* BREAKING CHANGE: MouseTracker event handler method signatures changed to 'handlerMethod( tracker, eventData)' (#23)
* BREAKING CHANGE: Event names changed for consistency: changed to lower case, compound names hyphenated, and "on" prefixes removed (#226):

View File

@ -117,15 +117,8 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve
for ( i = 0; i < arguments.length; i++ ) {
if ( $.isFunction( arguments[ i ] ) ) {
callback = arguments[ i ];
// TODO Send generic object wrapping readySource as a property (breaking change)
// TODO Maybe placeHolderSource should be passed to callback as well for consistency
// with event handler signature?
// Should be this (although technically it works as-is):
//this.addHandler( 'ready', function ( placeHolderSource, placeHolderArgs ) {
// callback( placeHolderArgs );
//} );
this.addHandler( 'ready', function ( placeHolderSource, readySource ) {
callback( readySource );
this.addHandler( 'ready', function ( placeHolderSource, placeHolderEventData ) {
callback( placeHolderSource, placeHolderEventData );
} );
//only one callback per constructor
break;
@ -308,10 +301,7 @@ $.TileSource.prototype = {
options = $TileSource.prototype.configure.apply( _this, [ data, url ]);
readySource = new $TileSource( options );
_this.ready = true;
// TODO Send generic object wrapping readySource as a property (breaking change)
// Should be this:
//_this.raiseEvent( 'ready', { tileSource: readySource } );
_this.raiseEvent( 'ready', readySource );
_this.raiseEvent( 'ready', { tileSource: readySource } );
};
if( url.match(/\.js$/) ){

View File

@ -438,8 +438,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
setTimeout(function(){
if ( $.type( tileSource ) == 'string') {
//If its still a string it means it must be a url at this point
tileSource = new $.TileSource( tileSource, function( readySource ){
openTileSource( _this, readySource );
tileSource = new $.TileSource( tileSource, function( eventSource, eventData ){
openTileSource( _this, eventData.tileSource );
});
tileSource.addHandler( 'open-failed', function ( name, args ) {
_this.raiseEvent( 'open-failed', args );