2019-07-02 21:10:10 +00:00
|
|
|
var MainMenu = require( './menu/MainMenu.js' ),
|
|
|
|
mainMenu = createMainMenu();
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-07-02 21:10:10 +00:00
|
|
|
/**
|
|
|
|
* N.B. that the activator - the UI element that the user must click in order to open the main
|
|
|
|
* menu - is always `.header .main-menu-button`.
|
|
|
|
*
|
|
|
|
* @return {MainMenu}
|
|
|
|
*
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
function createMainMenu() {
|
2019-09-05 21:55:55 +00:00
|
|
|
return new MainMenu( '.header .main-menu-button' );
|
2019-07-02 21:10:10 +00:00
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-10-04 15:05:37 +00:00
|
|
|
/**
|
|
|
|
* Wire up the main menu
|
|
|
|
*/
|
|
|
|
function init() {
|
|
|
|
/**
|
|
|
|
* Close navigation if skin is tapped
|
|
|
|
* @private
|
|
|
|
*/
|
2019-10-01 21:40:49 +00:00
|
|
|
function onSkinClick() {
|
2019-10-04 15:05:37 +00:00
|
|
|
mainMenu.closeNavigationDrawers();
|
|
|
|
}
|
2019-09-05 21:55:55 +00:00
|
|
|
|
2019-10-04 15:05:37 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
|
|
$( '.mw-mf-page-center__mask' ).on( 'click', onSkinClick );
|
2019-10-01 21:40:49 +00:00
|
|
|
|
|
|
|
// See I09c27a084100b223662f84de6cbe01bebe1fe774
|
|
|
|
// will trigger every time the Echo notification is opened or closed.
|
|
|
|
// This controls the drawer like behaviour of notifications
|
|
|
|
// on tablet in mobile mode.
|
|
|
|
mw.hook( 'echo.mobile' ).add( function ( isOpen ) {
|
|
|
|
if ( isOpen ) {
|
|
|
|
mainMenu.openNavigationDrawer( 'secondary' );
|
|
|
|
} else {
|
|
|
|
mainMenu.closeNavigationDrawers();
|
|
|
|
}
|
|
|
|
} );
|
2019-10-04 15:05:37 +00:00
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-10-04 15:05:37 +00:00
|
|
|
module.exports = {
|
|
|
|
mainMenu: mainMenu,
|
|
|
|
init: init
|
|
|
|
};
|