2019-07-05 22:21:34 +00:00
|
|
|
module.exports = function () {
|
2019-02-07 16:34:18 +00:00
|
|
|
var
|
2019-07-05 22:21:34 +00:00
|
|
|
M = mw.mobileFrontend,
|
2019-02-07 16:34:18 +00:00
|
|
|
mobile = M.require( 'mobile.startup' ),
|
|
|
|
loader = mobile.rlModuleLoader,
|
2018-09-26 23:03:20 +00:00
|
|
|
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
2017-07-12 15:12:40 +00:00
|
|
|
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
|
2019-02-07 16:34:18 +00:00
|
|
|
eventBus = mobile.eventBusSingleton,
|
2018-11-21 19:12:41 +00:00
|
|
|
isAnon = mw.user.isAnon();
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2018-09-26 23:03:20 +00:00
|
|
|
// check the categories feature has been turned on
|
|
|
|
if ( !features.categories ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
// categories overlay
|
|
|
|
overlayManager.add( /^\/categories$/, function () {
|
2018-08-22 00:26:46 +00:00
|
|
|
return loader.loadModule( 'mobile.categories.overlays', true ).then( function ( loadingOverlay ) {
|
2019-02-11 20:34:12 +00:00
|
|
|
var categoryOverlay = M.require( 'mobile.categories.overlays/categoryOverlay' );
|
2018-12-04 22:13:38 +00:00
|
|
|
eventBus.on( 'category-added', function () {
|
2018-02-28 19:52:29 +00:00
|
|
|
window.location.hash = '#/categories';
|
|
|
|
} );
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
loadingOverlay.hide();
|
2019-02-11 20:34:12 +00:00
|
|
|
return categoryOverlay( {
|
2017-07-12 15:12:40 +00:00
|
|
|
api: new mw.Api(),
|
2018-11-21 19:12:41 +00:00
|
|
|
isAnon: isAnon,
|
2019-07-11 00:56:04 +00:00
|
|
|
title: mobile.currentPage().title,
|
2018-12-04 22:13:38 +00:00
|
|
|
eventBus: eventBus
|
2018-08-22 00:26:46 +00:00
|
|
|
} );
|
2017-07-12 15:12:40 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// add categories overlay
|
|
|
|
overlayManager.add( /^\/categories\/add$/, function () {
|
2018-08-22 00:26:46 +00:00
|
|
|
return loader.loadModule( 'mobile.categories.overlays' ).then( function ( loadingOverlay ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
var CategoryAddOverlay = M.require( 'mobile.categories.overlays/CategoryAddOverlay' );
|
|
|
|
|
|
|
|
loadingOverlay.hide();
|
2018-08-22 00:26:46 +00:00
|
|
|
return new CategoryAddOverlay( {
|
2017-07-12 15:12:40 +00:00
|
|
|
api: new mw.Api(),
|
2018-11-21 19:12:41 +00:00
|
|
|
isAnon: isAnon,
|
2019-07-11 00:56:04 +00:00
|
|
|
title: mobile.currentPage().title,
|
2018-12-04 22:13:38 +00:00
|
|
|
eventBus: eventBus
|
2018-08-22 00:26:46 +00:00
|
|
|
} );
|
2017-07-12 15:12:40 +00:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable the categories button
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
function initButton() {
|
2019-04-03 23:32:18 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2017-07-12 15:12:40 +00:00
|
|
|
$( '.category-button' ).removeClass( 'hidden' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$( initButton );
|
|
|
|
|
2019-07-05 22:21:34 +00:00
|
|
|
};
|