Revert "Bad sync"

This reverts commit 70a7e8090e13cc35b93e652d2bcd7f418af26fc1.
This commit is contained in:
Mark Salsbery 2013-08-26 15:47:21 -07:00
parent 04a0197dc7
commit f8ab315795
4 changed files with 694 additions and 707 deletions

View File

@ -32,11 +32,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function ($) {
(function($){
/**
/**
* For use by classes which want to support custom, non-browser events.
* TODO: This is an awful name! This thing represents an "event source",
* TODO: This is an aweful name! This thing represents an "event source",
* not an "event handler". PLEASE change the to EventSource. Also please
* change 'addHandler', 'removeHandler' and 'raiseEvent' to 'bind',
* 'unbind', and 'trigger' respectively. Finally add a method 'one' which
@ -44,26 +44,25 @@
* matches.
* @class
*/
$.EventHandler = function () {
$.EventHandler = function() {
this.events = {};
};
};
$.EventHandler.prototype = {
$.EventHandler.prototype = {
/**
* Add an event handler for a given event.
* @function
* @param {String} eventName - Name of event to register.
* @param {Function} handler - Function to call when event is triggered.
* @param {Object} optional userData - Arbitrary object to be passed to the handler.
*/
addHandler: function (eventName, handler, userData) {
var events = this.events[eventName];
if (!events) {
this.events[eventName] = events = [];
addHandler: function( eventName, handler ) {
var events = this.events[ eventName ];
if( !events ){
this.events[ eventName ] = events = [];
}
if (handler && $.isFunction(handler)) {
events[events.length] = { handler: handler, userData: userData || null };
if( handler && $.isFunction( handler ) ){
events[ events.length ] = handler;
}
},
@ -73,20 +72,20 @@
* @param {String} eventName - Name of event for which the handler is to be removed.
* @param {Function} handler - Function to be removed.
*/
removeHandler: function (eventName, handler) {
var events = this.events[eventName],
removeHandler: function( eventName, handler ) {
var events = this.events[ eventName ],
handlers = [],
i;
if (!events) {
if ( !events ){
return;
}
if ($.isArray(events)) {
for (i = 0; i < events.length; i++) {
if (events[i].handler !== handler) {
handlers.push(events[i]);
if( $.isArray( events ) ){
for( i = 0; i < events.length; i++ ){
if( events[ i ] !== handler ){
handlers.push( events[ i ] );
}
}
this.events[eventName] = handlers;
this.events[ eventName ] = handlers;
}
},
@ -97,10 +96,10 @@
* @function
* @param {String} eventName - Name of event for which all handlers are to be removed.
*/
removeAllHandlers: function (eventName) {
if (eventName) {
this.events[eventName] = [];
} else {
removeAllHandlers: function( eventName ) {
if (eventName){
this.events[ eventName ] = [];
} else{
for (var eventType in this.events) {
this.events[eventType] = [];
}
@ -108,25 +107,24 @@
},
/**
* Retrieve the list of all handlers registered for a given event.
* Retrive the list of all handlers registered for a given event.
* @function
* @param {String} eventName - Name of event to get handlers for.
*/
getHandler: function (eventName) {
var events = this.events[eventName];
if (!events || !events.length) {
getHandler: function( eventName ) {
var events = this.events[ eventName ];
if ( !events || !events.length ){
return null;
}
events = events.length === 1 ?
[events[0]] :
Array.apply(null, events);
return function (source, args) {
[ events[ 0 ] ] :
Array.apply( null, events );
return function( source, args ) {
var i,
length = events.length;
for (i = 0; i < length; i++) {
if (events[i]) {
args.userData = events[i].userData;
events[i].handler(source, args);
for ( i = 0; i < length; i++ ) {
if( events[ i ] ){
events[ i ]( source, args );
}
}
};
@ -138,19 +136,19 @@
* @param {String} eventName - Name of event to register.
* @param {Function} handler - Function to call when event is triggered.
*/
raiseEvent: function (eventName, eventArgs) {
raiseEvent: function( eventName, eventArgs ) {
//uncomment if you want to get a log of all events
//$.console.log( eventName );
var handler = this.getHandler(eventName);
var handler = this.getHandler( eventName );
if (handler) {
if (!eventArgs) {
if ( handler ) {
if ( !eventArgs ) {
eventArgs = {};
}
handler(this, eventArgs);
handler( this, eventArgs );
}
}
};
};
} (OpenSeadragon));
}( OpenSeadragon ));

View File

@ -32,9 +32,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function ($) {
(function( $ ){
/**
/**
* The LegacyTileSource allows simple, traditional image pyramids to be loaded
* into an OpenSeadragon Viewer. Basically, this translates to the historically
* common practice of starting with a 'master' image, maybe a tiff for example,
@ -56,13 +56,13 @@
* @property {Number} maxLevel
* @property {Array} levels
*/
$.LegacyTileSource = function (levels) {
$.LegacyTileSource = function( levels ) {
var options,
width,
height;
if ($.isArray(levels)) {
if( $.isArray( levels ) ){
options = {
type: 'legacy-image-pyramid',
levels: levels
@ -70,33 +70,25 @@
}
//clean up the levels to make sure we support all formats
options.levels = filterFiles(options.levels);
options.levels = filterFiles( options.levels );
width = options.levels[ options.levels.length - 1 ].width;
height = options.levels[ options.levels.length - 1 ].height;
if (options.levels.length > 0) {
width = options.levels[options.levels.length - 1].width;
height = options.levels[options.levels.length - 1].height;
}
else {
width = 0;
height = 0;
$.console.error("No supported image formats found");
}
$.extend(true, options, {
$.extend( true, options, {
width: width,
height: height,
tileSize: Math.max(height, width),
tileSize: Math.max( height, width ),
tileOverlap: 0,
minLevel: 0,
maxLevel: options.levels.length > 0 ? options.levels.length - 1 : 0
maxLevel: options.levels.length - 1
});
$.TileSource.apply(this, [options]);
$.TileSource.apply( this, [ options ] );
this.levels = options.levels;
};
};
$.extend($.LegacyTileSource.prototype, $.TileSource.prototype, {
$.extend( $.LegacyTileSource.prototype, $.TileSource.prototype, {
/**
* Determine if the data and/or url imply the image service is supported by
* this tile source.
@ -105,7 +97,7 @@
* @param {Object|Array} data
* @param {String} optional - url
*/
supports: function (data, url) {
supports: function( data, url ){
return (
data.type &&
"legacy-image-pyramid" == data.type
@ -125,17 +117,17 @@
* @return {Object} options - A dictionary of keyword arguments sufficient
* to configure this tile sources constructor.
*/
configure: function (configuration, dataUrl) {
configure: function( configuration, dataUrl ){
var options;
if (!$.isPlainObject(configuration)) {
if( !$.isPlainObject(configuration) ){
options = configureFromXML(this, configuration);
options = configureFromXML( this, configuration );
} else {
}else{
options = configureFromObject(this, configuration);
options = configureFromObject( this, configuration );
}
return options;
@ -147,12 +139,12 @@
* @name OpenSeadragon.LegacyTileSource.prototype.getLevelScale
* @param {Number} level
*/
getLevelScale: function (level) {
getLevelScale: function( level ) {
var levelScale = NaN;
if (this.levels.length > 0 && level >= this.minLevel && level <= this.maxLevel) {
if ( level >= this.minLevel && level <= this.maxLevel ){
levelScale =
this.levels[level].width /
this.levels[this.maxLevel].width;
this.levels[ level ].width /
this.levels[ this.maxLevel ].width;
}
return levelScale;
},
@ -162,12 +154,12 @@
* @name OpenSeadragon.LegacyTileSource.prototype.getNumTiles
* @param {Number} level
*/
getNumTiles: function (level) {
var scale = this.getLevelScale(level);
if (scale) {
return new $.Point(1, 1);
getNumTiles: function( level ) {
var scale = this.getLevelScale( level );
if ( scale ){
return new $.Point( 1, 1 );
} else {
return new $.Point(0, 0);
return new $.Point( 0, 0 );
}
},
@ -177,8 +169,8 @@
* @param {Number} level
* @param {OpenSeadragon.Point} point
*/
getTileAtPoint: function (level, point) {
return new $.Point(0, 0);
getTileAtPoint: function( level, point ) {
return new $.Point( 0, 0 );
},
@ -194,63 +186,60 @@
* @param {Number} y
* @throws {Error}
*/
getTileUrl: function (level, x, y) {
getTileUrl: function( level, x, y ) {
var url = null;
if (this.levels.length > 0 && level >= this.minLevel && level <= this.maxLevel) {
url = this.levels[level].url;
if( level >= this.minLevel && level <= this.maxLevel ){
url = this.levels[ level ].url;
}
return url;
}
});
});
/**
/**
* This method removes any files from the Array which dont conform to our
* basic requirements for a 'level' in the LegacyTileSource.
* @private
* @inner
* @function
*/
function filterFiles(files) {
function filterFiles( files ){
var filtered = [],
file,
i;
for (i = 0; i < files.length; i++) {
file = files[i];
if (file.height &&
for( i = 0; i < files.length; i++ ){
file = files[ i ];
if( file.height &&
file.width &&
file.url && (
file.url.toLowerCase().match(/^.*\.(png|jpg|jpeg|gif)$/) || (
file.mimetype &&
file.mimetype.toLowerCase().match(/^.*\/(png|jpg|jpeg|gif)$/)
)
)) {
) ){
//This is sufficient to serve as a level
filtered.push({
url: file.url,
width: Number(file.width),
height: Number(file.height)
width: Number( file.width ),
height: Number( file.height )
});
}
else {
$.console.error('Unsupported image format: %s', file.url ? file.url : '<no URL>');
}
}
return filtered.sort(function (a, b) {
return filtered.sort(function(a,b){
return a.height - b.height;
});
}
}
/**
/**
* @private
* @inner
* @function
*/
function configureFromXML(tileSource, xmlDoc) {
function configureFromXML( tileSource, xmlDoc ){
if (!xmlDoc || !xmlDoc.documentElement) {
throw new Error($.getString("Errors.Xml"));
if ( !xmlDoc || !xmlDoc.documentElement ) {
throw new Error( $.getString( "Errors.Xml" ) );
}
var root = xmlDoc.documentElement,
@ -260,50 +249,50 @@
level,
i;
if (rootName == "image") {
if ( rootName == "image" ) {
try {
conf = {
type: root.getAttribute("type"),
type: root.getAttribute( "type" ),
levels: []
};
levels = root.getElementsByTagName("level");
for (i = 0; i < levels.length; i++) {
level = levels[i];
levels = root.getElementsByTagName( "level" );
for ( i = 0; i < levels.length; i++ ) {
level = levels[ i ];
conf.levels.push({
url: level.getAttribute("url"),
width: parseInt(level.getAttribute("width"), 10),
height: parseInt(level.getAttribute("height"), 10)
conf.levels .push({
url: level.getAttribute( "url" ),
width: parseInt( level.getAttribute( "width" ), 10 ),
height: parseInt( level.getAttribute( "height" ), 10 )
});
}
return configureFromObject(tileSource, conf);
return configureFromObject( tileSource, conf );
} catch (e) {
} catch ( e ) {
throw (e instanceof Error) ?
e :
new Error('Unknown error parsing Legacy Image Pyramid XML.');
new Error( 'Unknown error parsing Legacy Image Pyramid XML.' );
}
} else if (rootName == "collection") {
throw new Error('Legacy Image Pyramid Collections not yet supported.');
} else if (rootName == "error") {
throw new Error('Error: ' + xmlDoc);
} else if ( rootName == "collection" ) {
throw new Error( 'Legacy Image Pyramid Collections not yet supported.' );
} else if ( rootName == "error" ) {
throw new Error( 'Error: ' + xmlDoc );
}
throw new Error('Unknown element ' + rootName);
}
throw new Error( 'Unknown element ' + rootName );
}
/**
/**
* @private
* @inner
* @function
*/
function configureFromObject(tileSource, configuration) {
function configureFromObject( tileSource, configuration ){
return configuration.levels;
}
}
} (OpenSeadragon));
}( OpenSeadragon ));

View File

@ -32,10 +32,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function ($) {
(function( $ ){
/**
/**
* The TileSource contains the most basic implementation required to create a
* smooth transition between layer in an image pyramid. It has only a single key
* interface that must be implemented to complete it key functionality:
@ -83,15 +83,15 @@
* @property {Number} maxLevel
* The maximum pyramid level this tile source supports or should attempt to load.
*/
$.TileSource = function (width, height, tileSize, tileOverlap, minLevel, maxLevel) {
$.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLevel ) {
var callback = null,
args = arguments,
options,
i;
if ($.isPlainObject(width)) {
if( $.isPlainObject( width ) ){
options = width;
} else {
}else{
options = {
width: args[0],
height: args[1],
@ -104,32 +104,32 @@
//Tile sources supply some events, namely 'ready' when they must be configured
//by asyncronously fetching their configuration data.
$.EventHandler.call(this);
$.EventHandler.call( this );
//we allow options to override anything we dont treat as
//required via idiomatic options or which is functionally
//set depending on the state of the readiness of this tile
//source
$.extend(true, this, options);
$.extend( true, this, options );
//Any functions that are passed as arguments are bound to the ready callback
/*jshint loopfunc:true*/
for (i = 0; i < arguments.length; i++) {
if ($.isFunction(arguments[i])) {
callback = arguments[i];
this.addHandler('ready', function (placeHolderSource, placeHolderArgs) {
callback(placeHolderArgs.tileSource);
for( i = 0; i < arguments.length; i++ ){
if( $.isFunction( arguments[i] ) ){
callback = arguments[ i ];
this.addHandler( 'ready', function( placeHolderSource, readySource ){
callback( readySource );
});
//only one callback per constructor
break;
}
}
if ('string' == $.type(arguments[0])) {
if( 'string' == $.type( arguments[ 0 ] ) ){
//in case the getImageInfo method is overriden and/or implies an
//async mechanism set some safe defaults first
this.aspectRatio = 1;
this.dimensions = new $.Point(10, 10);
this.dimensions = new $.Point( 10, 10 );
this.tileSize = 0;
this.tileOverlap = 0;
this.minLevel = 0;
@ -137,75 +137,75 @@
this.ready = false;
//configuration via url implies the extending class
//implements and 'configure'
this.getImageInfo(arguments[0]);
this.getImageInfo( arguments[ 0 ] );
} else {
//explicit configuration via positional args in constructor
//or the more idiomatic 'options' object
this.ready = true;
this.aspectRatio = (options.width && options.height) ?
(options.width / options.height) : 1;
this.dimensions = new $.Point(options.width, options.height);
this.aspectRatio = ( options.width && options.height ) ?
( options.width / options.height ) : 1;
this.dimensions = new $.Point( options.width, options.height );
this.tileSize = options.tileSize ? options.tileSize : 0;
this.tileOverlap = options.tileOverlap ? options.tileOverlap : 0;
this.minLevel = options.minLevel ? options.minLevel : 0;
this.maxLevel = (undefined !== options.maxLevel && null !== options.maxLevel) ?
this.maxLevel = ( undefined !== options.maxLevel && null !== options.maxLevel ) ?
options.maxLevel : (
(options.width && options.height) ? Math.ceil(
Math.log(Math.max(options.width, options.height)) /
Math.log(2)
( options.width && options.height ) ? Math.ceil(
Math.log( Math.max( options.width, options.height ) ) /
Math.log( 2 )
) : 0
);
if (callback && $.isFunction(callback)) {
callback(this);
if( callback && $.isFunction( callback ) ){
callback( this );
}
}
};
};
$.TileSource.prototype = {
$.TileSource.prototype = {
/**
* @function
* @param {Number} level
*/
getLevelScale: function (level) {
getLevelScale: function( level ) {
// see https://github.com/openseadragon/openseadragon/issues/22
// we use the tilesources implementation of getLevelScale to generate
// a memoized re-implementation
var levelScaleCache = {},
i;
for (i = 0; i <= this.maxLevel; i++) {
levelScaleCache[i] = 1 / Math.pow(2, this.maxLevel - i);
for( i = 0; i <= this.maxLevel; i++ ){
levelScaleCache[ i ] = 1 / Math.pow(2, this.maxLevel - i);
}
this.getLevelScale = function (_level) {
return levelScaleCache[_level];
this.getLevelScale = function( _level ){
return levelScaleCache[ _level ];
};
return this.getLevelScale(level);
return this.getLevelScale( level );
},
/**
* @function
* @param {Number} level
*/
getNumTiles: function (level) {
var scale = this.getLevelScale(level),
x = Math.ceil(scale * this.dimensions.x / this.tileSize),
y = Math.ceil(scale * this.dimensions.y / this.tileSize);
getNumTiles: function( level ) {
var scale = this.getLevelScale( level ),
x = Math.ceil( scale * this.dimensions.x / this.tileSize ),
y = Math.ceil( scale * this.dimensions.y / this.tileSize );
return new $.Point(x, y);
return new $.Point( x, y );
},
/**
* @function
* @param {Number} level
*/
getPixelRatio: function (level) {
var imageSizeScaled = this.dimensions.times(this.getLevelScale(level)),
getPixelRatio: function( level ) {
var imageSizeScaled = this.dimensions.times( this.getLevelScale( level ) ),
rx = 1.0 / imageSizeScaled.x,
ry = 1.0 / imageSizeScaled.y;
@ -217,17 +217,17 @@
* @function
* @param {Number} level
*/
getClosestLevel: function (rect) {
getClosestLevel: function( rect ) {
var i,
tilesPerSide = Math.floor(Math.max(rect.x, rect.y) / this.tileSize),
tilesPerSide = Math.floor( Math.max( rect.x, rect.y ) / this.tileSize ),
tiles;
for (i = this.minLevel; i < this.maxLevel; i++) {
tiles = this.getNumTiles(i);
if (Math.max(tiles.x, tiles.y) + 1 >= tilesPerSide) {
for( i = this.minLevel; i < this.maxLevel; i++ ){
tiles = this.getNumTiles( i );
if( Math.max( tiles.x, tiles.y ) + 1 >= tilesPerSide ){
break;
}
}
return Math.max(0, i - 1);
return Math.max( 0, i - 1 );
},
/**
@ -235,12 +235,12 @@
* @param {Number} level
* @param {OpenSeadragon.Point} point
*/
getTileAtPoint: function (level, point) {
var pixel = point.times(this.dimensions.x).times(this.getLevelScale(level)),
tx = Math.floor(pixel.x / this.tileSize),
ty = Math.floor(pixel.y / this.tileSize);
getTileAtPoint: function( level, point ) {
var pixel = point.times( this.dimensions.x ).times( this.getLevelScale(level ) ),
tx = Math.floor( pixel.x / this.tileSize ),
ty = Math.floor( pixel.y / this.tileSize );
return new $.Point(tx, ty);
return new $.Point( tx, ty );
},
/**
@ -249,18 +249,18 @@
* @param {Number} x
* @param {Number} y
*/
getTileBounds: function (level, x, y) {
var dimensionsScaled = this.dimensions.times(this.getLevelScale(level)),
px = (x === 0) ? 0 : this.tileSize * x - this.tileOverlap,
py = (y === 0) ? 0 : this.tileSize * y - this.tileOverlap,
sx = this.tileSize + (x === 0 ? 1 : 2) * this.tileOverlap,
sy = this.tileSize + (y === 0 ? 1 : 2) * this.tileOverlap,
getTileBounds: function( level, x, y ) {
var dimensionsScaled = this.dimensions.times( this.getLevelScale( level ) ),
px = ( x === 0 ) ? 0 : this.tileSize * x - this.tileOverlap,
py = ( y === 0 ) ? 0 : this.tileSize * y - this.tileOverlap,
sx = this.tileSize + ( x === 0 ? 1 : 2 ) * this.tileOverlap,
sy = this.tileSize + ( y === 0 ? 1 : 2 ) * this.tileOverlap,
scale = 1.0 / dimensionsScaled.x;
sx = Math.min(sx, dimensionsScaled.x - px);
sy = Math.min(sy, dimensionsScaled.y - py);
sx = Math.min( sx, dimensionsScaled.x - px );
sy = Math.min( sy, dimensionsScaled.y - py );
return new $.Rect(px * scale, py * scale, sx * scale, sy * scale);
return new $.Rect( px * scale, py * scale, sx * scale, sy * scale );
},
@ -271,7 +271,7 @@
* @param {String} url
* @throws {Error}
*/
getImageInfo: function (url) {
getImageInfo: function( url ) {
var _this = this,
callbackName,
callback,
@ -282,33 +282,33 @@
lastDot;
if (url) {
urlParts = url.split('/');
filename = urlParts[urlParts.length - 1];
lastDot = filename.lastIndexOf('.');
if (lastDot > -1) {
urlParts[urlParts.length - 1] = filename.slice(0, lastDot);
if( url ) {
urlParts = url.split( '/' );
filename = urlParts[ urlParts.length - 1 ];
lastDot = filename.lastIndexOf( '.' );
if ( lastDot > -1 ) {
urlParts[ urlParts.length - 1 ] = filename.slice( 0, lastDot );
}
}
callback = function (data) {
var $TileSource = $.TileSource.determineType(_this, data, url);
if (!$TileSource) {
_this.raiseEvent('open-failed', { message: "Unable to load TileSource", source: url });
callback = function( data ){
var $TileSource = $.TileSource.determineType( _this, data, url );
if ( !$TileSource ) {
_this.raiseEvent( 'open-failed', { message: "Unable to load TileSource", source: url } );
return;
}
options = $TileSource.prototype.configure.apply(_this, [data, url]);
readySource = new $TileSource(options);
options = $TileSource.prototype.configure.apply( _this, [ data, url ]);
readySource = new $TileSource( options );
_this.ready = true;
_this.raiseEvent('ready', { tileSource: readySource });
_this.raiseEvent( 'ready', readySource );
};
if (url.match(/\.js$/)) {
if( url.match(/\.js$/) ){
//TODO: Its not very flexible to require tile sources to end jsonp
// request for info with a url that ends with '.js' but for
// now it's the only way I see to distinguish uniformly.
callbackName = url.split('/').pop().replace('.js', '');
callbackName = url.split( '/' ).pop().replace('.js','');
$.jsonp({
url: url,
async: false,
@ -317,11 +317,11 @@
});
} else {
// request info via xhr asyncronously.
$.makeAjaxRequest(url, function (xhr) {
var data = processResponse(xhr);
callback(data);
}, function (xhr) {
_this.raiseEvent('open-failed', {
$.makeAjaxRequest( url, function( xhr ) {
var data = processResponse( xhr );
callback( data );
}, function ( xhr ) {
_this.raiseEvent( 'open-failed', {
message: "HTTP " + xhr.status + " attempting to load TileSource",
source: url
});
@ -344,7 +344,7 @@
* from if any.
* @return {Boolean}
*/
supports: function (data, url) {
supports: function( data, url ) {
return false;
},
@ -363,8 +363,8 @@
* to configure this tile sources constructor.
* @throws {Error}
*/
configure: function (data, url) {
throw new Error("Method not implemented.");
configure: function( data, url ) {
throw new Error( "Method not implemented." );
},
/**
@ -380,8 +380,8 @@
* @param {Number} y
* @throws {Error}
*/
getTileUrl: function (level, x, y) {
throw new Error("Method not implemented.");
getTileUrl: function( level, x, y ) {
throw new Error( "Method not implemented." );
},
/**
@ -390,8 +390,8 @@
* @param {Number} x
* @param {Number} y
*/
tileExists: function (level, x, y) {
var numTiles = this.getNumTiles(level);
tileExists: function( level, x, y ) {
var numTiles = this.getNumTiles( level );
return level >= this.minLevel &&
level <= this.maxLevel &&
x >= 0 &&
@ -399,13 +399,13 @@
x < numTiles.x &&
y < numTiles.y;
}
};
};
$.extend(true, $.TileSource.prototype, $.EventHandler.prototype);
$.extend( true, $.TileSource.prototype, $.EventHandler.prototype );
/**
/**
* Decides whether to try to process the response as xml, json, or hand back
* the text
* @eprivate
@ -413,41 +413,41 @@
* @function
* @param {XMLHttpRequest} xhr - the completed network request
*/
function processResponse(xhr) {
function processResponse( xhr ){
var responseText = xhr.responseText,
status = xhr.status,
statusText,
data;
if (!xhr) {
throw new Error($.getString("Errors.Security"));
} else if (xhr.status !== 200 && xhr.status !== 0) {
if ( !xhr ) {
throw new Error( $.getString( "Errors.Security" ) );
} else if ( xhr.status !== 200 && xhr.status !== 0 ) {
status = xhr.status;
statusText = (status == 404) ?
statusText = ( status == 404 ) ?
"Not Found" :
xhr.statusText;
throw new Error($.getString("Errors.Status", status, statusText));
throw new Error( $.getString( "Errors.Status", status, statusText ) );
}
if (responseText.match(/\s*<.*/)) {
try {
data = (xhr.responseXML && xhr.responseXML.documentElement) ?
if( responseText.match(/\s*<.*/) ){
try{
data = ( xhr.responseXML && xhr.responseXML.documentElement ) ?
xhr.responseXML :
$.parseXml(responseText);
} catch (e) {
$.parseXml( responseText );
} catch (e){
data = xhr.responseText;
}
} else if (responseText.match(/\s*[\{\[].*/)) {
}else if( responseText.match(/\s*[\{\[].*/) ){
/*jshint evil:true*/
data = eval('(' + responseText + ')');
} else {
data = eval( '('+responseText+')' );
}else{
data = responseText;
}
return data;
}
}
/**
/**
* Determines the TileSource Implementation by introspection of OpenSeadragon
* namespace, calling each TileSource implementation of 'isType'
* @eprivate
@ -457,20 +457,20 @@
* @param {String} url - the url where the tile source configuration object was
* loaded from, if any.
*/
$.TileSource.determineType = function (tileSource, data, url) {
$.TileSource.determineType = function( tileSource, data, url ){
var property;
for (property in OpenSeadragon) {
if (property.match(/.+TileSource$/) &&
$.isFunction(OpenSeadragon[property]) &&
$.isFunction(OpenSeadragon[property].prototype.supports) &&
OpenSeadragon[property].prototype.supports.call(tileSource, data, url)
) {
return OpenSeadragon[property];
for( property in OpenSeadragon ){
if( property.match(/.+TileSource$/) &&
$.isFunction( OpenSeadragon[ property ] ) &&
$.isFunction( OpenSeadragon[ property ].prototype.supports ) &&
OpenSeadragon[ property ].prototype.supports.call( tileSource, data, url )
){
return OpenSeadragon[ property ];
}
}
$.console.error("No TileSource was able to open %s %s", url, data);
};
$.console.error( "No TileSource was able to open %s %s", url, data );
};
} (OpenSeadragon));
}( OpenSeadragon ));

View File

@ -1463,7 +1463,7 @@ function onCanvasDrag( tracker, position, delta, shift ) {
this.viewport.applyConstraints();
}
}
this.raiseEvent( 'canvas-drag', {
this.raiseEvent( 'canvas-click', {
tracker: tracker,
position: position,
delta: delta,