mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/preInit.js
jdlrobson 1e64fc8f3d Dev: Address some FIXMEs
* Drop non-existent pointer-overlay selector
* Drop redundant icon class for arrow
* Drop unnecessary !important
* Drop transparent-shield class
* Reword an existing FIXME about a contensious decision and
add a new FIXME for moving some code to a more appropriate place.
* Move an image into a ResourceLoaderImage module (test with
`mw.notify('error', { type: 'error'} )`)

Change-Id: I6e38f07772afae6f13c4851ca17a67d52ca7d331
2020-02-03 08:43:18 +00:00

44 lines
1.2 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 () {
// eslint-disable-next-line no-restricted-properties
var M = mw.mobileFrontend,
mobile = M.require( 'mobile.startup' ),
menus = require( './menu.js' );
// loads lazy loading images
mobile.Skin.getSingleton();
// 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 */
};