mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-20 01:31:45 +03:00
Viewer: refactor message code into showMessage/hideMessage methods
This avoids the need to deal with classes, and explicitly makes it reusable for other needs
This commit is contained in:
parent
630bccad3d
commit
1f345e4cc5
@ -174,12 +174,7 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
this.addHandler( 'open-failed', function (source, args) {
|
this.addHandler( 'open-failed', function (source, args) {
|
||||||
var msg = $.getString( "Errors.Open-Failed", args.source, args.message);
|
var msg = $.getString( "Errors.Open-Failed", args.source, args.message);
|
||||||
|
_this.showMessage( msg );
|
||||||
var errorDiv = $.makeNeutralElement( "div" );
|
|
||||||
$.addClass( errorDiv, "modal-dialog error" );
|
|
||||||
errorDiv.appendChild( document.createTextNode( msg ) );
|
|
||||||
|
|
||||||
_this.container.appendChild( $.makeCenteredNode( errorDiv ) );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ControlDock.call( this, options );
|
$.ControlDock.call( this, options );
|
||||||
@ -428,12 +423,7 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
|
|||||||
$TileSource,
|
$TileSource,
|
||||||
options;
|
options;
|
||||||
|
|
||||||
if ( this.container ) {
|
_this.hideMessage();
|
||||||
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
|
//allow plain xml strings or json strings to be parsed here
|
||||||
if( $.type( tileSource ) == 'string' ){
|
if( $.type( tileSource ) == 'string' ){
|
||||||
@ -1082,8 +1072,31 @@ $.extend( $.Viewer.prototype, $.EventHandler.prototype, $.ControlDock.prototype,
|
|||||||
this.referenceStrip.setFocus( page );
|
this.referenceStrip.setFocus( page );
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a message in the viewport
|
||||||
|
* @function
|
||||||
|
* @param {String} text message
|
||||||
|
*/
|
||||||
|
showMessage: function ( message ) {
|
||||||
|
var div = this.messageDiv = $.makeNeutralElement( "div" );
|
||||||
|
div.appendChild( document.createTextNode( message ) );
|
||||||
|
|
||||||
|
this.container.appendChild( $.makeCenteredNode( div ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide any currently displayed viewport message
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
hideMessage: function () {
|
||||||
|
var div = this.messageDiv;
|
||||||
|
if (div) {
|
||||||
|
div.parentNode.remove(div);
|
||||||
|
delete this.messageDiv;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user