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
|
2020-06-02 21:21:44 +00:00
|
|
|
*
|
2017-07-12 15:12:40 +00:00
|
|
|
* @class mw.mobileFrontend
|
|
|
|
* @singleton
|
|
|
|
*/
|
2019-07-02 21:10:10 +00:00
|
|
|
module.exports = function () {
|
2020-04-10 18:22:44 +00:00
|
|
|
var menus = require( './menu.js' );
|
2017-09-07 17:27:30 +00:00
|
|
|
|
2019-10-04 15:05:37 +00:00
|
|
|
// setup main menu
|
|
|
|
menus.init();
|
2017-09-07 17:27:30 +00:00
|
|
|
|
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).
|
|
|
|
|
2019-07-31 23:28:27 +00:00
|
|
|
var redirectedFrom, $msg, title;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
if ( wgRedirectedFrom === null ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
redirectedFrom = mw.Title.newFromText( wgRedirectedFrom );
|
|
|
|
|
|
|
|
if ( redirectedFrom ) {
|
|
|
|
// mw.Title.getPrefixedText includes the human-readable namespace prefix.
|
2019-07-31 23:28:27 +00:00
|
|
|
title = redirectedFrom.getPrefixedText();
|
|
|
|
$msg = $( '<div>' ).html(
|
|
|
|
mw.message( 'mobile-frontend-redirected-from', title ).parse()
|
|
|
|
);
|
|
|
|
$msg.find( 'a' ).attr( 'href', mw.util.getUrl( title, { redirect: 'no' } ) );
|
|
|
|
mw.notify( $msg );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
}( mw.config.get( 'wgRedirectedFrom' ) ) );
|
|
|
|
/* eslint-enable no-console */
|
2019-07-02 21:10:10 +00:00
|
|
|
};
|