mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 01:06:31 +00:00
ef5003f310
The MobileFrontend dependency in Minerva is problematic. Code that Minerva needs should live in core. MobileFrontend should load code on all skins when they operate on a mobile domain. This eslint check reminds developers of this in a hope it encourages more upstreaming to core when possible. Of course disabling is also an option, but this check will at least make us aware of when we are moving further away from the goal. Change-Id: I62183c9aefc81053e4ad81fb746decef2dd24b44
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
module.exports = function () {
|
|
var
|
|
// eslint-disable-next-line no-restricted-properties
|
|
M = mw.mobileFrontend,
|
|
mobile = M.require( 'mobile.startup' ),
|
|
loader = mobile.rlModuleLoader,
|
|
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
|
OverlayManager = mobile.OverlayManager,
|
|
overlayManager = OverlayManager.getSingleton(),
|
|
eventBus = mobile.eventBusSingleton,
|
|
isAnon = mw.user.isAnon();
|
|
|
|
// check the categories feature has been turned on
|
|
if ( !features.categories ) {
|
|
return;
|
|
}
|
|
|
|
// categories overlay
|
|
overlayManager.add( /^\/categories$/, function () {
|
|
return loader.loadModule( 'mobile.categories.overlays', true ).then( function ( loadingOverlay ) {
|
|
var categoryOverlay = M.require( 'mobile.categories.overlays/categoryOverlay' );
|
|
eventBus.on( 'category-added', function () {
|
|
window.location.hash = '#/categories';
|
|
} );
|
|
|
|
loadingOverlay.hide();
|
|
return categoryOverlay( {
|
|
api: new mw.Api(),
|
|
isAnon: isAnon,
|
|
title: mobile.currentPage().title,
|
|
eventBus: eventBus
|
|
} );
|
|
} );
|
|
} );
|
|
|
|
// add categories overlay
|
|
overlayManager.add( /^\/categories\/add$/, function () {
|
|
return loader.loadModule( 'mobile.categories.overlays' ).then( function ( loadingOverlay ) {
|
|
var CategoryAddOverlay = M.require( 'mobile.categories.overlays/CategoryAddOverlay' );
|
|
|
|
loadingOverlay.hide();
|
|
return new CategoryAddOverlay( {
|
|
api: new mw.Api(),
|
|
isAnon: isAnon,
|
|
title: mobile.currentPage().title,
|
|
eventBus: eventBus
|
|
} );
|
|
} );
|
|
} );
|
|
|
|
/**
|
|
* Enable the categories button
|
|
* @ignore
|
|
*/
|
|
function initButton() {
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
$( '.category-button' ).removeClass( 'hidden' );
|
|
}
|
|
|
|
$( initButton );
|
|
|
|
};
|