This wiki is still in active development, many areas of the site are unstable or broken.
In the meantime, consider adding content to pages you like!
MediaWiki:Timeless.js: Difference between revisions
From NBITTRPG Wiki
m Replaced content with "→All JavaScript here will be loaded for users of the Timeless skin: " Tag: Replaced |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
/* All JavaScript here will be loaded for users of the Timeless skin */ | /* All JavaScript here will be loaded for users of the Timeless skin */ | ||
/* Sticky wiki tools and sidebar */ | |||
var siteTools = document.getElementById('site-tools'); | |||
var sideCatLinks = document.getElementById('catlinks-sidebar'); | |||
var sideCatLinksVisible = false; | |||
// Check if catlinks-sidebar exists | |||
if (sideCatLinks) { | |||
var visibleCats = sideCatLinks.querySelectorAll(".mw-normal-catlinks ul li"); | |||
var hiddenCats = sideCatLinks.querySelectorAll(".mw-hidden-catlinks ul li"); | |||
// Hide if no visible categories and some hidden ones | |||
if (visibleCats.length === 0 && hiddenCats.length > 0) { | |||
sideCatLinks.style.display = "none"; | |||
} | |||
// Check if it's visible after all that | |||
sideCatLinksVisible = sideCatLinks.style.display !== "none"; | |||
} | |||
// Apply sticky logic | |||
if (sideCatLinksVisible) { | |||
// Make catlinks-sidebar sticky | |||
sideCatLinks.style.position = "sticky"; | |||
sideCatLinks.style.top = "70px"; | |||
// Remove sticky from site-tools | |||
if (siteTools) { | |||
siteTools.style.position = ""; | |||
siteTools.style.top = ""; | |||
} | |||
else { | |||
// Make site-tools sticky | |||
if (siteTools) { | |||
siteTools.style.position = "sticky"; | |||
siteTools.style.top = "70px"; | |||
} | |||
} | |||
// Remove sticky from catlinks-sidebar (if it exists) | |||
if (sideCatLinks) { | |||
sideCatLinks.style.position = ""; | |||
sideCatLinks.style.top = ""; | |||
} | |||
} | |||
Revision as of 09:19, 29 September 2026
/* All JavaScript here will be loaded for users of the Timeless skin */
/* Sticky wiki tools and sidebar */
var siteTools = document.getElementById('site-tools');
var sideCatLinks = document.getElementById('catlinks-sidebar');
var sideCatLinksVisible = false;
// Check if catlinks-sidebar exists
if (sideCatLinks) {
var visibleCats = sideCatLinks.querySelectorAll(".mw-normal-catlinks ul li");
var hiddenCats = sideCatLinks.querySelectorAll(".mw-hidden-catlinks ul li");
// Hide if no visible categories and some hidden ones
if (visibleCats.length === 0 && hiddenCats.length > 0) {
sideCatLinks.style.display = "none";
}
// Check if it's visible after all that
sideCatLinksVisible = sideCatLinks.style.display !== "none";
}
// Apply sticky logic
if (sideCatLinksVisible) {
// Make catlinks-sidebar sticky
sideCatLinks.style.position = "sticky";
sideCatLinks.style.top = "70px";
// Remove sticky from site-tools
if (siteTools) {
siteTools.style.position = "";
siteTools.style.top = "";
}
else {
// Make site-tools sticky
if (siteTools) {
siteTools.style.position = "sticky";
siteTools.style.top = "70px";
}
}
// Remove sticky from catlinks-sidebar (if it exists)
if (sideCatLinks) {
sideCatLinks.style.position = "";
sideCatLinks.style.top = "";
}
}
