mediawiki-skins-MinervaNeue/resources/skins.minerva.options/categories.js
jdlrobson b9862d7d24 skins.minerva.options uses packageFiles
I want to remove the need for M.define in the Minerva repository.
It's no longer necessary with packageFiles and will help tame
a lot of the code we have here!

Change-Id: If6a35a23e84a44adb965fd9c41265ba37eb8368e
2019-07-08 17:22:11 +00:00

61 lines
1.6 KiB
JavaScript

module.exports = function () {
var
M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
loader = mobile.rlModuleLoader,
features = mw.config.get( 'wgMinervaFeatures', {} ),
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
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: M.getCurrentPage().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: M.getCurrentPage().title,
eventBus: eventBus
} );
} );
} );
/**
* Enable the categories button
* @ignore
*/
function initButton() {
// eslint-disable-next-line no-jquery/no-global-selector
$( '.category-button' ).removeClass( 'hidden' );
}
$( initButton );
};