mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-29 13:17:35 +00:00
Quick fix for black screen of death
This fixes three issues: * the overlay way multiplied during history navigation, but only the last one was cleaned up on exit * the overlay was not cleaned up when loading a #mediaviewer URL with an invalid file name * the overlay was not cleaned up when there was an error creating the viewer object This is a quick fix, and does not change the fact that bootstrapping is an unmaintainable mess which should be cleaned up. Change-Id: I2838e5e709e7c7308b0a5b27eca24a2584d0a01e Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/414
This commit is contained in:
parent
5a4bd34143
commit
d4bf2188b1
|
@ -67,9 +67,7 @@
|
|||
mw.loader.using( 'mmv', function() {
|
||||
bs.isCSSReady( deferred );
|
||||
}, function ( error ) {
|
||||
mw.log( error.message );
|
||||
deferred.reject( error.message );
|
||||
bs.cleanupOverlay();
|
||||
} );
|
||||
|
||||
return deferred.done( function ( viewer ) {
|
||||
|
@ -80,6 +78,9 @@
|
|||
|
||||
bs.viewerInitialized = true;
|
||||
}
|
||||
} ).fail( function( message ) {
|
||||
mw.log.warn( message );
|
||||
bs.cleanupOverlay();
|
||||
} );
|
||||
};
|
||||
|
||||
|
@ -91,12 +92,19 @@
|
|||
MMVB.isCSSReady = function ( deferred ) {
|
||||
var $dummy = $( '<div class="' + this.readinessCSSClass + '">' )
|
||||
.appendTo( $( document.body ) ),
|
||||
bs = this;
|
||||
bs = this,
|
||||
viewer;
|
||||
|
||||
if ( $dummy.css( 'display' ) === 'inline' ) {
|
||||
// Let's be clean and remove the test item before resolving the deferred
|
||||
$dummy.remove();
|
||||
deferred.resolve( bs.getViewer() );
|
||||
try {
|
||||
viewer = bs.getViewer();
|
||||
} catch ( e ) {
|
||||
deferred.reject( e.message );
|
||||
return;
|
||||
}
|
||||
deferred.resolve( viewer );
|
||||
} else {
|
||||
$dummy.remove();
|
||||
setTimeout( function () { bs.isCSSReady( deferred ); }, this.readinessWaitDuration );
|
||||
|
@ -214,6 +222,8 @@
|
|||
* Handles the browser location hash on pageload or hash change
|
||||
*/
|
||||
MMVB.hash = function () {
|
||||
var bootstrap = this;
|
||||
|
||||
// There is no point loading the mmv if it isn't loaded yet for hash changes unrelated to the mmv
|
||||
// Such as anchor links on the page
|
||||
if ( !this.viewerInitialized && window.location.hash.indexOf( '#mediaviewer/') !== 0 ) {
|
||||
|
@ -227,6 +237,11 @@
|
|||
|
||||
this.loadViewer().then( function ( viewer ) {
|
||||
viewer.hash();
|
||||
// this is an ugly temporary fix to avoid a black screen of death when
|
||||
// the page is loaded with an invalid MMV url
|
||||
if ( !viewer.isOpen ) {
|
||||
bootstrap.cleanupOverlay();
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
@ -283,8 +298,10 @@
|
|||
* Sets up the overlay while the viewer loads
|
||||
*/
|
||||
MMVB.setupOverlay = function () {
|
||||
this.$overlay = $( '<div>' )
|
||||
.addClass( 'mw-mmv-overlay' );
|
||||
if ( !this.$overlay ) {
|
||||
this.$overlay = $( '<div>' )
|
||||
.addClass( 'mw-mmv-overlay' );
|
||||
}
|
||||
|
||||
$( document.body ).addClass( 'mw-mmv-lightbox-open' )
|
||||
.append( this.$overlay );
|
||||
|
|
Loading…
Reference in a new issue