Make minerva use updated mediaViewerOverlay factory function

Additional changes:

* rlModuleLoader is no longer needed now that the mediaViewerOverlay is
part of mobile.startup so that was removed in addition to the calls to
it.

* Removed the EVENT_SLIDE/EVENT_EXIT logic as the mediaViewerOverlay
now handles its own slide/exit behavior

Bug: T216198
Depends-On: I36e3c0645c931492fbef0b7c0a49f6a418dbd3a1
Change-Id: I04656c4adb7edc9a111447de3d63044044a8d6dd
This commit is contained in:
Nicholas Ray 2019-03-25 14:08:54 -06:00
parent e7c497bda7
commit 799f426f5b
1 changed files with 12 additions and 42 deletions

View File

@ -8,7 +8,6 @@
TitleUtil = M.require( 'skins.minerva.scripts/TitleUtil' ),
issues = M.require( 'skins.minerva.scripts/pageIssues' ),
downloadPageAction = M.require( 'skins.minerva.scripts/downloadPageAction' ),
loader = mobile.rlModuleLoader,
router = require( 'mediawiki.router' ),
OverlayManager = mobile.OverlayManager,
CtaDrawer = mobile.CtaDrawer,
@ -83,59 +82,30 @@
}
/**
* Make an instance of an ImageOverlay. This function assumes that the module
* providing the ImageOverlay has been asynchronously loaded.
* Returns a rejected promise if MultimediaViewer is available. Otherwise
* returns the mediaViewerOverlay
* @method
* @ignore
* @param {string} title Url of image
* @return {ImageOverlay}
* @param {string} title the title of the image
* @return {JQuery.Deferred|Overlay}
*/
function makeImageOverlay( title ) {
var ImageOverlay = M.require( 'mobile.mediaViewer/ImageOverlay' ),
imageOverlay = new ImageOverlay( {
api: api,
thumbnails: thumbs,
title: decodeURIComponent( title ),
eventBus: eventBus
} );
imageOverlay.on( ImageOverlay.EVENT_EXIT, function () {
// Actually dismiss the overlay whenever the cross is closed.
window.location.hash = '';
// Clear the hash.
router.navigate( '' );
} );
imageOverlay.on( ImageOverlay.EVENT_SLIDE, function ( nextThumbnail ) {
routeThumbnail( nextThumbnail );
} );
return imageOverlay;
}
/**
* Load image overlay
* @method
* @ignore
* @uses ImageOverlay
* @param {string} title Url of image
* @return {JQuery.Deferred|ImageOverlay}
*/
function loadImageOverlay( title ) {
function makeMediaViewerOverlayIfNeeded( title ) {
if ( mw.loader.getState( 'mmv.bootstrap' ) === 'ready' ) {
// This means MultimediaViewer has been installed and is loaded.
// Avoid loading it (T169622)
return $.Deferred().reject();
}
if ( mw.loader.getState( 'mobile.mediaViewer' ) === 'ready' ) {
// If module already loaded, do this synchronously to avoid the event loop causing
// a visible flash (see T197110)
return makeImageOverlay( title );
}
return loader.loadModule( 'mobile.mediaViewer' ).then( function () {
return makeImageOverlay( title );
return mobile.mediaViewer.overlay( {
api: api,
thumbnails: thumbs,
title: decodeURIComponent( title ),
eventBus: eventBus
} );
}
// Routes
overlayManager.add( /^\/media\/(.+)$/, loadImageOverlay );
overlayManager.add( /^\/media\/(.+)$/, makeMediaViewerOverlayIfNeeded );
overlayManager.add( /^\/languages$/, function () {
return mobile.languageOverlay( new PageGateway( api ) );
} );