2017-07-12 15:12:40 +00:00
|
|
|
// FIXME: make this an object with a constructor to facilitate testing
|
|
|
|
// (see https://bugzilla.wikimedia.org/show_bug.cgi?id=44264)
|
|
|
|
/**
|
|
|
|
* mobileFrontend namespace
|
|
|
|
* @class mw.mobileFrontend
|
|
|
|
* @singleton
|
|
|
|
*/
|
2017-09-07 17:34:35 +00:00
|
|
|
( function ( M ) {
|
|
|
|
var skin = M.require( 'mobile.init/skin' ),
|
2017-07-12 15:12:40 +00:00
|
|
|
mainMenu = M.require( 'skins.minerva.scripts.top/mainMenu' ),
|
2017-09-07 17:34:35 +00:00
|
|
|
toast = M.require( 'mobile.startup/toast' );
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2017-09-07 17:34:35 +00:00
|
|
|
// Proxy to MobileFrontend defined skin
|
2017-09-07 16:55:28 +00:00
|
|
|
M.define( 'skins.minerva.scripts/skin', skin );
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2017-09-07 17:27:30 +00:00
|
|
|
/**
|
|
|
|
* Close navigation if skin is tapped
|
|
|
|
* @param {jQuery.Event} ev
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
function onSkinClick( ev ) {
|
|
|
|
var $target = this.$( ev.target );
|
|
|
|
|
|
|
|
// Make sure the menu is open and we are not clicking on the menu button
|
|
|
|
if (
|
|
|
|
mainMenu &&
|
|
|
|
mainMenu.isOpen() &&
|
|
|
|
!$target.hasClass( 'main-menu-button' )
|
|
|
|
) {
|
|
|
|
mainMenu.closeNavigationDrawers();
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
skin.on( 'click', onSkinClick.bind( skin ) );
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
( function ( wgRedirectedFrom ) {
|
|
|
|
// If the user has been redirected, then show them a toast message (see
|
|
|
|
// https://phabricator.wikimedia.org/T146596).
|
|
|
|
|
|
|
|
var redirectedFrom;
|
|
|
|
|
|
|
|
if ( wgRedirectedFrom === null ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
redirectedFrom = mw.Title.newFromText( wgRedirectedFrom );
|
|
|
|
|
|
|
|
if ( redirectedFrom ) {
|
|
|
|
|
|
|
|
// mw.Title.getPrefixedText includes the human-readable namespace prefix.
|
|
|
|
toast.show( mw.msg(
|
|
|
|
'mobile-frontend-redirected-from',
|
|
|
|
redirectedFrom.getPrefixedText()
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
}( mw.config.get( 'wgRedirectedFrom' ) ) );
|
|
|
|
/* eslint-enable no-console */
|
2017-09-07 17:34:35 +00:00
|
|
|
}( mw.mobileFrontend ) );
|