MediaWiki:Gadgets/vectorScripts/main.js
MediaWiki interface page
More actions
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*** Mobile navigation toggle button ***/
( function () {
const BUTTON_CLASS = 'mobile-nav-toggle';
const EXPANDED_CLASS = 'nav--expanded';
if (document.querySelector('button.' + BUTTON_CLASS)){return;} // early return to avoid double button if this runs twice
let mobileSidebarButton = document.createElement( 'button' );
let sidebar = document.getElementById( 'mw-panel' );
mobileSidebarButton.className = BUTTON_CLASS;
mobileSidebarButton.addEventListener( 'click', function () {
mobileSidebarButton.classList.toggle( EXPANDED_CLASS );
sidebar.classList.toggle( EXPANDED_CLASS );
} );
sidebar.prepend( mobileSidebarButton );
document.body.classList.add( 'has-vector-mobile-menu' );
} )();
/*** End mobile navigation toggle button ***/
/*** #mw-head collapsing fix ***/
/*** IMPORTANT: Do not copy this code if your wiki is not updated to default loadout 2.0 (May 22, 2025) or later, or your navigation tabs will break ***/
mw.loader.using('skins.vector.legacy.js', function() {
$.collapsibleTabs.calculateTabDistance = function(){
return parseInt(window.getComputedStyle(document.getElementById( 'right-navigation' ), '::before').width ) - 1;
}
});
/*** END #mw-head collapsing fix ***/



