mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-19 01:01:00 +00:00
a32999e641
Change-Id: Icabf6e065ed5685207731262db72faf848a0a04d
72 lines
1.8 KiB
JavaScript
72 lines
1.8 KiB
JavaScript
module.exports = function () {
|
|
var
|
|
// eslint-disable-next-line no-restricted-properties
|
|
M = mw.mobileFrontend,
|
|
mobile = M.require( 'mobile.startup' ),
|
|
headers = mobile.headers,
|
|
icons = mobile.icons,
|
|
Overlay = mobile.Overlay,
|
|
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 mobile.categoryOverlay( {
|
|
api: new mw.Api(),
|
|
isAnon: isAnon,
|
|
title: mobile.currentPage().title,
|
|
eventBus: eventBus
|
|
} );
|
|
} );
|
|
|
|
overlayManager.add( /^\/categories\/add$/, function () {
|
|
// A transitional overlay that loads instantly that will be replaced with a
|
|
// CategoryAddOverlay as soon as it is available.
|
|
var spinnerOverlay = Overlay.make(
|
|
{
|
|
headers: [
|
|
headers.header( '', [
|
|
icons.spinner()
|
|
], icons.back() )
|
|
],
|
|
heading: ''
|
|
}, icons.spinner()
|
|
);
|
|
|
|
// Load the additional code and replace the temporary overlay with the new overlay.
|
|
mw.loader.using( 'mobile.categories.overlays' ).then( function () {
|
|
var CategoryAddOverlay = M.require( 'mobile.categories.overlays' ).CategoryAddOverlay;
|
|
overlayManager.replaceCurrent(
|
|
new CategoryAddOverlay( {
|
|
api: new mw.Api(),
|
|
isAnon: isAnon,
|
|
title: mobile.currentPage().title
|
|
} )
|
|
);
|
|
} );
|
|
return spinnerOverlay;
|
|
} );
|
|
|
|
/**
|
|
* Enable the categories button
|
|
*
|
|
* @ignore
|
|
*/
|
|
function initButton() {
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
$( '.category-button' ).removeClass( 'hidden' );
|
|
}
|
|
|
|
$( initButton );
|
|
|
|
};
|