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
No edit summary
Tag: Reverted
yo this is not working so lets check someone elses code
Tag: Reverted
Line 2: Line 2:


/* Sticky wiki tools and sidebar */
/* Sticky wiki tools and sidebar */
var siteTools = document.getElementById('site-tools');
var catSidebar = document.getElementById("catlinks-sidebar");
var sideCatLinks = document.getElementById('catlinks-sidebar');  
var pageTools = document.getElementById("page-tools");


var sideCatLinksVisible = false;
var catSidebarVisible = false;


// Check if catlinks-sidebar exists
// Check if catlinks-sidebar exists
if (sideCatLinks) {
if (catSidebar) {
     var visibleCats = sideCatLinks.querySelectorAll(".mw-normal-catlinks ul li");
     var visibleCats = catSidebar.querySelectorAll(".mw-normal-catlinks ul li");
     var hiddenCats = sideCatLinks.querySelectorAll(".mw-hidden-catlinks ul li");
     var hiddenCats = catSidebar.querySelectorAll(".mw-hidden-catlinks ul li");


     // Hide if no visible categories and some hidden ones
     // Hide if no visible categories and some hidden ones
     if (visibleCats.length === 0 && hiddenCats.length > 0) {
     if (visibleCats.length === 0 && hiddenCats.length > 0) {
         sideCatLinks.style.display = "none";
         catSidebar.style.display = "none";
     }
     }


     // Check if it's visible after all that
     // Check if it's visible after all that
     sideCatLinksVisible = sideCatLinks.style.display !== "none";
     catSidebarVisible = catSidebar.style.display !== "none";
}
}


// Apply sticky logic
// Apply sticky logic
if (sideCatLinksVisible) {
if (catSidebarVisible) {
     // Make catlinks-sidebar sticky
     // Make catlinks-sidebar sticky
     sideCatLinks.style.position = "sticky";
     catSidebar.style.position = "sticky";
     sideCatLinks.style.top = "70px";
     catSidebar.style.top = "70px";


     // Remove sticky from site-tools
     // Remove sticky from page-tools
     if (siteTools) {
     if (pageTools) {
         siteTools.style.position = "";
         pageTools.style.position = "";
         siteTools.style.top = "";
         pageTools.style.top = "";
     }
     }
else {
} else {
     // Make site-tools sticky
     // Make page-tools sticky
     if (siteTools) {
     if (pageTools) {
         siteTools.style.position = "sticky";
         pageTools.style.position = "sticky";
         siteTools.style.top = "70px";
         pageTools.style.top = "70px";
     }
     }
}
 
     // Remove sticky from catlinks-sidebar (if it exists)
     // Remove sticky from catlinks-sidebar (if it exists)
     if (sideCatLinks) {
     if (catSidebar) {
         sideCatLinks.style.position = "";
         catSidebar.style.position = "";
         sideCatLinks.style.top = "";
         catSidebar.style.top = "";
     }
     }
}
}

Revision as of 09:29, 29 September 2026

/* All JavaScript here will be loaded for users of the Timeless skin */

/* Sticky wiki tools and sidebar */
var catSidebar = document.getElementById("catlinks-sidebar");
var pageTools = document.getElementById("page-tools");

var catSidebarVisible = false;

// Check if catlinks-sidebar exists
if (catSidebar) {
    var visibleCats = catSidebar.querySelectorAll(".mw-normal-catlinks ul li");
    var hiddenCats = catSidebar.querySelectorAll(".mw-hidden-catlinks ul li");

    // Hide if no visible categories and some hidden ones
    if (visibleCats.length === 0 && hiddenCats.length > 0) {
        catSidebar.style.display = "none";
    }

    // Check if it's visible after all that
    catSidebarVisible = catSidebar.style.display !== "none";
}

// Apply sticky logic
if (catSidebarVisible) {
    // Make catlinks-sidebar sticky
    catSidebar.style.position = "sticky";
    catSidebar.style.top = "70px";

    // Remove sticky from page-tools
    if (pageTools) {
        pageTools.style.position = "";
        pageTools.style.top = "";
    }
} else {
    // Make page-tools sticky
    if (pageTools) {
        pageTools.style.position = "sticky";
        pageTools.style.top = "70px";
    }

    // Remove sticky from catlinks-sidebar (if it exists)
    if (catSidebar) {
        catSidebar.style.position = "";
        catSidebar.style.top = "";
    }
}