Viewer: add a basic error message display system

This might be something we want to make configurable for users who want
to completely control how errors are displayed.

This also adds the first use of OpenSeadragon.makeCenteredNode currently
so we might want to clean up that code as well.
This commit is contained in:
Chris Adams 2013-06-28 14:32:57 -04:00
parent 2bf6b13bfe
commit 7dcf662fdd

View File

@ -174,7 +174,12 @@ $.Viewer = function( options ) {
this.addHandler( 'open-failed', function (source, args) {
var msg = $.getString( "Errors.Open-Failed", args.source, args.message);
window.alert( msg );
var errorDiv = $.makeNeutralElement( "div" );
$.addClass( errorDiv, "modal-dialog error" );
errorDiv.appendChild( document.createTextNode( msg ) );
_this.container.appendChild( $.makeCenteredNode(errorDiv) );
});
$.ControlDock.call( this, options );
@ -423,6 +428,13 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
$TileSource,
options;
if (this.container) {
var dialogs = this.container.querySelectorAll(".modal-dialog");
for (var i = 0; i < dialogs.length; i++) {
dialogs[i].parentNode.remove(dialogs[i]);
}
}
//allow plain xml strings or json strings to be parsed here
if( $.type( tileSource ) == 'string' ){
if( tileSource.match(/\s*<.*/) ){