mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 14:23:53 +00:00
Call new language factory instead of LanguageOverlay
When merged with I629245100f4ca430a88e450939b90d075e7021f1, the need to use rlModuleLoader.js (white screen loader) with LanguageOverlay is eliminated. When calling the language factory function, an Overlay is now synchronously returned with a spinner shown in its content area while the lazy load request + xhr request are executing. PromisedView will replace this spinner with the LanguageSearcher component when the promise resolves (rejects continue to be unhandled). * The getDeviceLanguage function was moved into languageFactory.js inside MobileFrontend * the lazy load code and gateway.getPageLanguages code was also moved into languageFactory. Bug: T215657 Depends-On: I629245100f4ca430a88e450939b90d075e7021f1 Change-Id: Ie6dad4bd3c80e6cfcc1d7f9ad38941a323ba3cc6
This commit is contained in:
parent
cfca2184dd
commit
a48df04a75
|
@ -79,21 +79,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the language code of the device in lowercase
|
||||
*
|
||||
* @ignore
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
function getDeviceLanguage() {
|
||||
var lang = navigator && navigator.languages ?
|
||||
navigator.languages[ 0 ] :
|
||||
navigator.language || navigator.userLanguage ||
|
||||
navigator.browserLanguage || navigator.systemLanguage;
|
||||
|
||||
return lang ? lang.toLowerCase() : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an instance of an ImageOverlay. This function assumes that the module
|
||||
* providing the ImageOverlay has been asynchronously loaded.
|
||||
|
@ -149,22 +134,7 @@
|
|||
// Routes
|
||||
overlayManager.add( /^\/media\/(.+)$/, loadImageOverlay );
|
||||
overlayManager.add( /^\/languages$/, function () {
|
||||
var lang = mw.config.get( 'wgUserLanguage' );
|
||||
|
||||
return loader.loadModule( 'mobile.languages.structured', true ).then( function ( loadingOverlay ) {
|
||||
var gateway = new PageGateway( api ),
|
||||
LanguageOverlay = M.require( 'mobile.languages.structured/LanguageOverlay' );
|
||||
|
||||
return gateway.getPageLanguages( mw.config.get( 'wgPageName' ), lang ).then( function ( data ) {
|
||||
loadingOverlay.hide();
|
||||
return new LanguageOverlay( {
|
||||
currentLanguage: mw.config.get( 'wgContentLanguage' ),
|
||||
languages: data.languages,
|
||||
variants: data.variants,
|
||||
deviceLanguage: getDeviceLanguage()
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
return mobile.languageOverlay( new PageGateway( api ) );
|
||||
} );
|
||||
|
||||
// Setup
|
||||
|
|
Loading…
Reference in a new issue