mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/preInit.js
jdlrobson e72c0d7ba4 Render main menu and shield on server side
This is a second attempt at I3892afb5ed3df628e2845043cf3bbc22a9928921
that is cached HTML friendly and won't cause T234599.

This time rather than solving the entire problem, we'll start rendering
the menu on the server, to allow us in future to drop the Menu code

Bug: T234650
Change-Id: Iea5406ef1c561f2907ec6132481007673aabf1e9
2019-10-04 19:35:28 +00:00

48 lines
1.5 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();
// remove transparent-shield
// FIXME: Remove when transparent-shield has been removed from Mobilefrontend Skin.js
// eslint-disable-next-line no-jquery/no-global-selector
$( '.transparent-shield:not( .mw-mf-page-center__mask )' ).remove();
// 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 */
};