This is an old revision of this page, as edited by Sideswipe9th(talk | contribs) at 18:08, 12 December 2023(ok, now append the tools bar to the nav we created earlier and....). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 18:08, 12 December 2023 by Sideswipe9th(talk | contribs)(ok, now append the tools bar to the nav we created earlier and....)
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki>// By Sideswipe9th// Last edit date: 27 November 2023// Known bugs:// - On pages with a ToC, scrolling the main content area will cause the stick panel to jump to whatever// the "focused" header is, if you've scrolled down to access the toolsbar it will jump back up// - If the Main Menu is hidden, the CSS for this breaks. I think I just need to add another check to make sure// The parent containers exist when the menu is hidden, and if not create empty ones// Change log:// - 27 November 2023// * Fix bug where the tools menu was no longer being added to TOC-less pages, after some class and id changes in the theme// - 6 April 2023// * Fix bug where the className on the containers was not being set properly for newly created elements// * Fix bug where the nav with id mw-panel-toc needs to have its margin-left set to 0px when it's added to ToCless pages. // - 4 March 2023// * Fix the tools menu not being appended on TOC-less pages after the previously always present nav I was relying on was removed// - 18 February 2023// * Initial release$(function(){// does the document contain an element with the id "mw-panel-toc"varnavTocContainer=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-innervarpageContainer=document.getElementsByClassName("vector-column-start");if(pageContainer.length>0){// so we now need to create a NAV with id mw-panel-tocnav=document.createElement("NAV");// assign it the right ID, classes, and arialabelnav.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-innerpageContainer[0].appendChild(nav);/*// ok, now we have a nav element in the right place, time to move its content to the right place. var newContainer = document.createElement("div"); // create a new div newContainer.id = "vector-toc-pinned-container"; // give it the right id newContainer.className = "vector-pinned-container"; // give it some class nav.appendChild(newContainer); // and append it to the navbar*/vartoolsBar=document.getElementById("vector-page-tools");// then grab the tools bar by IDtoolsBar.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 ToCnav.appendChild(toolsBar);// and finally append the tools bar to the floating ToC}}else{// it does, 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-tocvartoolsBar=document.getElementById("vector-page-tools");// first grab the tools bar by IDvarfloatingToC=document.getElementById("vector-toc");// then grab the floating TOC by IDif(floatingToC!=null&&toolsBar!=null){floatingToC.appendChild(toolsBar);// and finally append the tools bar to the floating ToC}}});//</nowiki>