mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-20 01:31:45 +03:00
User-visible warning when tile sources fail to load
This is currently using window.alert in lieu of something more sophisticated but it works for indicating 404s or invalid file contents
This commit is contained in:
parent
494bf7fe41
commit
2bf6b13bfe
@ -45,7 +45,8 @@ var I18N = {
|
||||
ImageFormat: "Sorry, we don't support {0}-based Deep Zoom Images.",
|
||||
Security: "It looks like a security restriction stopped us from " +
|
||||
"loading this Deep Zoom Image.",
|
||||
Status: "This space unintentionally left blank ({0} {1})."
|
||||
Status: "This space unintentionally left blank ({0} {1}).",
|
||||
"Open-Failed": "Unable to open {0}: {1}"
|
||||
},
|
||||
|
||||
Tooltips: {
|
||||
|
@ -293,6 +293,11 @@ $.TileSource.prototype = {
|
||||
|
||||
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 );
|
||||
_this.ready = true;
|
||||
@ -315,6 +320,11 @@ $.TileSource.prototype = {
|
||||
$.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
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -458,6 +468,8 @@ $.TileSource.determineType = function( tileSource, data, url ){
|
||||
return OpenSeadragon[ property ];
|
||||
}
|
||||
}
|
||||
|
||||
$.console.error( "No TileSource was able to open %s %s", url, data );
|
||||
};
|
||||
|
||||
|
||||
|
@ -171,6 +171,12 @@ $.Viewer = function( options ) {
|
||||
|
||||
//Inherit some behaviors and properties
|
||||
$.EventHandler.call( this );
|
||||
|
||||
this.addHandler( 'open-failed', function (source, args) {
|
||||
var msg = $.getString( "Errors.Open-Failed", args.source, args.message);
|
||||
window.alert( msg );
|
||||
});
|
||||
|
||||
$.ControlDock.call( this, options );
|
||||
|
||||
//Deal with tile sources
|
||||
@ -433,6 +439,9 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
|
||||
tileSource = new $.TileSource( tileSource, function( readySource ){
|
||||
openTileSource( _this, readySource );
|
||||
});
|
||||
tileSource.addHandler( 'open-failed', function ( name, args ) {
|
||||
_this.raiseEvent( 'open-failed', args );
|
||||
});
|
||||
|
||||
} else if ( $.isPlainObject( tileSource ) || tileSource.nodeType ){
|
||||
if( $.isFunction( tileSource.getTileUrl ) ){
|
||||
@ -443,6 +452,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
|
||||
} else {
|
||||
//inline configuration
|
||||
$TileSource = $.TileSource.determineType( _this, tileSource );
|
||||
if ( !$TileSource ) {
|
||||
_this.raiseEvent( 'open-failed', {
|
||||
message: "Unable to load TileSource",
|
||||
source: tileSource
|
||||
});
|
||||
return;
|
||||
}
|
||||
options = $TileSource.prototype.configure.apply( _this, [ tileSource ]);
|
||||
readySource = new $TileSource( options );
|
||||
openTileSource( _this, readySource );
|
||||
|
Loading…
x
Reference in New Issue
Block a user