mediawiki-skins-MinervaNeue/resources/skins.minerva.categories/init.js
jdlrobson 56a10c40e0 Make Deferreds promise compatible
This patch updates the various usages of $.Deferred for loading
overlays in routes to be ES6 Promise compatible

Bug: T188937
Change-Id: I3fc24bf3471a99e7671d1191bdd46cb741286ee1
2018-08-22 14:27:48 -07:00

50 lines
1.4 KiB
JavaScript

( function ( M, $ ) {
var loader = M.require( 'mobile.startup/rlModuleLoader' ),
overlayManager = M.require( 'skins.minerva.scripts/overlayManager' ),
user = M.require( 'mobile.startup/user' );
// 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(),
categories: mw.config.get( 'wgCategories' ),
isAnon: user.isAnon(),
title: M.getCurrentPage().title
} );
} );
} );
/**
* Enable the categories button
* @ignore
*/
function initButton() {
$( '.category-button' ).removeClass( 'hidden' );
}
$( initButton );
}( mw.mobileFrontend, jQuery ) );