MediaWiki:Common.js: Difference between revisions
Force light mode |
Force sidebar pin and light mode |
||
| Line 1: | Line 1: | ||
/* Force | /** | ||
* Winds of Valen Wiki - Common JS | |||
* 1. Force the main nav sidebar to appear pinned (like OSRS wiki) | |||
* 2. Prevent dark mode extensions from inverting the color scheme | |||
*/ | |||
// --- Force light color scheme --- | |||
(function () { | (function () { | ||
var m = document.createElement('meta'); | var m = document.createElement('meta'); | ||
| Line 7: | Line 13: | ||
document.documentElement.style.colorScheme = 'light'; | document.documentElement.style.colorScheme = 'light'; | ||
}()); | }()); | ||
// --- Fix the html class: switch pinned-disabled to pinned-enabled --- | |||
(function () { | |||
var html = document.documentElement; | |||
html.className = html.className | |||
.replace('vector-feature-main-menu-pinned-disabled', 'vector-feature-main-menu-pinned-enabled'); | |||
}()); | |||
// --- Move the main menu DOM from the dropdown into the pinned sidebar slot --- | |||
document.addEventListener('DOMContentLoaded', function () { | |||
var pinned = document.getElementById('vector-main-menu-pinned-container'); | |||
var unpinned = document.getElementById('vector-main-menu-unpinned-container'); | |||
if (pinned && unpinned && unpinned.children.length > 0 && pinned.children.length === 0) { | |||
while (unpinned.firstChild) { | |||
pinned.appendChild(unpinned.firstChild); | |||
} | |||
} | |||
// Also hide the hamburger dropdown button since sidebar is now visible | |||
var hamburger = document.getElementById('vector-main-menu-dropdown'); | |||
if (hamburger) hamburger.style.display = 'none'; | |||
}); | |||