MediaWiki:Vector-2022.js
Appearance
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.
/* UVLists: show the main menu in the sidebar for logged-out visitors unless
they have hidden it. Vector keeps the table of contents pinned and
remembers that choice itself; logged-in users have a saved preference. */
(function () {
var key = 'uvlists.sidebar.vector-main-menu';
if (mw.config.get('wgUserName')) {
return;
}
function hidden() {
try {
return localStorage.getItem(key) === '0';
} catch (e) {
return false;
}
}
// Remember the visitor's own hide and show clicks.
document.addEventListener('click', function (event) {
var button = event.isTrusted && event.target instanceof Element &&
event.target.closest('[data-event-name^="pinnable-header.vector-main-menu."]');
if (button) {
try {
localStorage.setItem(key, /\.pin$/.test(button.getAttribute('data-event-name')) ? '1' : '0');
} catch (e) {
// Storage may be unavailable; the default applies next time.
}
}
}, true);
mw.loader.using('skins.vector.js').then(function () {
$(function () {
// The sidebar column exists only at 1120px and wider. Pinning
// there lets Vector unpin and repin as the window is resized.
var pin = document.querySelector('[data-event-name="pinnable-header.vector-main-menu.pin"]');
if (pin && !hidden() && window.matchMedia('(min-width: 1120px)').matches &&
!document.documentElement.classList.contains('vector-feature-main-menu-pinned-enabled')) {
pin.click();
}
});
});
}());