2018-11-16 15:16:25 +00:00
|
|
|
( function ( M ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
var loader = M.require( 'mobile.startup/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' ),
|
2018-12-04 22:13:38 +00:00
|
|
|
eventBus = M.require( 'mobile.startup/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 ) {
|
2017-07-12 15:12:40 +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();
|
2018-08-22 00:26:46 +00:00
|
|
|
return new CategoryOverlay( {
|
2017-07-12 15:12:40 +00:00
|
|
|
api: new mw.Api(),
|
2018-11-21 19:12:41 +00:00
|
|
|
isAnon: isAnon,
|
2018-12-04 22:13:38 +00:00
|
|
|
title: M.getCurrentPage().title,
|
|
|
|
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,
|
2018-12-04 22:13:38 +00:00
|
|
|
title: M.getCurrentPage().title,
|
|
|
|
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() {
|
|
|
|
$( '.category-button' ).removeClass( 'hidden' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$( initButton );
|
|
|
|
|
2018-11-16 15:16:25 +00:00
|
|
|
}( mw.mobileFrontend ) );
|