mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/preInit.js
Ed Sanders a32999e641 build: Update eslint-config-wikimedia to 0.16.0
Change-Id: Icabf6e065ed5685207731262db72faf848a0a04d
2020-06-04 08:39:32 -07:00

39 lines
1 KiB
JavaScript

// 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
*/
module.exports = function () {
var menus = require( './menu.js' );
// setup main menu
menus.init();
( function ( wgRedirectedFrom ) {
// If the user has been redirected, then show them a toast message (see
// https://phabricator.wikimedia.org/T146596).
var redirectedFrom, $msg, title;
if ( wgRedirectedFrom === null ) {
return;
}
redirectedFrom = mw.Title.newFromText( wgRedirectedFrom );
if ( redirectedFrom ) {
// mw.Title.getPrefixedText includes the human-readable namespace prefix.
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 );
}
}( mw.config.get( 'wgRedirectedFrom' ) ) );
/* eslint-enable no-console */
};