mediawiki-skins-MinervaNeue/resources/skins.minerva.options/categories.js
jdlrobson cbad0bd363 Merge skin option modules into a single ResourceLoader module and move enabled logic to client
It's presumed that skin options will eventually become the default or be removed from the skin.
While they are not the default, it would be helpful to package them in one single module - as ResourceLoader
modules are costly bloating the dependency graph in the MediaWiki startup module.

In T167713 we talked about grouping our entry points by page rather than feature, which this seems consistent
with. A page with special options enabled is different from a page without.

Change-Id: Id948f913d4743532ba3442d2059a03c122419ff2
2018-10-12 10:18:21 -07:00

55 lines
1.5 KiB
JavaScript

( function ( M, $ ) {
var loader = M.require( 'mobile.startup/rlModuleLoader' ),
features = mw.config.get( 'wgMinervaFeatures', {} ),
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
user = M.require( 'mobile.startup/user' );
// 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' );
M.on( 'category-added', function () {
window.location.hash = '#/categories';
} );
loadingOverlay.hide();
return new CategoryOverlay( {
api: new mw.Api(),
isAnon: user.isAnon(),
title: M.getCurrentPage().title
} );
} );
} );
// 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: user.isAnon(),
title: M.getCurrentPage().title
} );
} );
} );
/**
* Enable the categories button
* @ignore
*/
function initButton() {
$( '.category-button' ).removeClass( 'hidden' );
}
$( initButton );
}( mw.mobileFrontend, jQuery ) );