MediaWiki:Common.js: Difference between revisions

added mobile nav toggle button
force desktop skin on mobile instead of generic Minerva skin
Tag: Reverted
Line 1: Line 1:
// ==========================================================================
// Force the branded desktop (Vector) skin for everyone, including phones.
// The site auto-switches to MediaWiki's generic Minerva mobile skin based
// on user-agent, which has none of the custom theme/nav and is a much
// worse experience than the (now mobile-responsive) desktop skin. This
// runs as early as possible to minimize the flash of the wrong skin before
// redirecting. Guarded against loops with both the cookie MobileFrontend
// itself sets on toggle, and a sessionStorage flag as a hard backstop.
(function () {
  try {
    if (!document.body || !document.body.classList.contains('skin-minerva')) return;
    if (document.cookie.indexOf('mf_useformat=desktop') !== -1) return;
    if (sessionStorage.getItem('wovForcedDesktop')) return;
    sessionStorage.setItem('wovForcedDesktop', '1');
    var sep = window.location.search ? '&' : '?';
    window.location.href = window.location.pathname + window.location.search + sep + 'mobileaction=toggle_view_desktop';
  } catch (e) {
    // if storage/cookies are blocked, just leave the user on Minerva rather
    // than risk breaking the rest of the site's scripts.
  }
})();
$(document).ready(function() {
$(document).ready(function() {
     $('#ca-nstab-main a').text('Article');
     $('#ca-nstab-main a').text('Article');