User:Sideswipe9th/V22FloatingToolsMenu-debug-copy.js: Difference between revisions

Content deleted Content added
top: Add release notes from main version
top: lets see if this fixes tocless pages
Line 19:
//var container = document.getElementById("vector-toc-pinned-container");
//// does the document contain an element with the classes "vector-main-menu-container vector-sidebar-container-no-toc"
//var noToCContainer = document.getElementsByClassName("vector-main-menu-container vector-sidebar-container-no-toc");
//if (noToCContainer != null && noToCContainer.length > 0)
// does the document contain an element with the id "mw-panel-toc"
var navTocContainer = document.getElementById("mw-panel-toc");
if (navTocContainer == null)
{
// it does not, so we're on a ToCless page
// get the div with the class name mw-page-container-inner
var pageContainer = document.getElementsByClassName("mw-page-container-inner");
if (pageContainer.length > 0)
{
// so we now need to create a NAV with id mw-panel-toc
nav = document.createElement("NAV");
// assign it the right ID, classes, and arialabel
nav.id = "mw-panel-toc";
nav.className = "mw-table-of-contents-container vector-toc-landmark vector-sticky-pinned-container";
nav.arialabel = "Contents";
nav.style.setProperty("margin-left", "0px");
// append this nav as a child to div with clas mw-page-container-inner
pageContainer[0].appendChild(nav);
}
// get the element with the id vector-main-menu, cause we're going to check its parent
//var vectorMainMenu = document.getElementById("vector-main-menu");
// do a null check, in theory this should always exist but you never know
//if (vectorMainMenu != null)
//{
// is the parent of vectorMainMenu the pinned container?
// disabled for now, can't figure out how to detect when the menu is closed and force it open again
Line 40 ⟶ 58:
// now that the main menu is forced on, we can start to create our new heirarchy
//var nav = document.getElementById("mw-panel-toc"); // grab the parent navbar that's used to always be present
// check if mw-panel-toc is present
//if (nav == null)
/*
{
// it's not, ugh. Ok, get the elements with the class name mw-page-container-inner
Line 67 ⟶ 86:
var toolsBar = document.getElementById("vector-page-tools"); // then grab the tools bar by ID
toolsBar.disabled = true; // because enabling the tools bar will break this, we want to force it to disabled
newContainer.appendChild(toolsBar); // and finally append the tools bar to the floating ToC*/
//}
}
else
{
// it does not, so we're on a page that has a ToC. This code is simpler, as we just want to append the tools bar
// to the end of vector-toc
var toolsBar = document.getElementById("vector-page-tools"); // first grab the tools bar by ID
var floatingToC = document.getElementById("vector-toc"); // then grab the floating TOC by ID
if (floatingToC != null && toolsBar != null)
{
floatingToC.appendChild(toolsBar); // and finally append the tools bar to the floating ToC
}
}