MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
SitX (talk | contribs)
No edit summary
SitX (talk | contribs)
No edit summary
Line 4: Line 4:
         if (!toc) return;
         if (!toc) return;


        // Create Floating ToC Box
         var floatingToc = document.createElement("div");
         var floatingToc = document.createElement("div");
         floatingToc.id = "floating-toc";
         floatingToc.id = "floating-toc";
Line 14: Line 15:
         if (hideButton) {
         if (hideButton) {
             hideButton.addEventListener("click", function (event) {
             hideButton.addEventListener("click", function (event) {
                 event.preventDefault();
                 event.preventDefault();  
                 floatingToc.classList.toggle("collapsed");
                 floatingToc.classList.toggle("collapsed");
                event.stopPropagation();
             });
             });
         }
         }
        toc.addEventListener("click", function (event) {
            event.stopPropagation();
        });


         floatingToc.addEventListener("click", function (event) {
         floatingToc.addEventListener("click", function (event) {
             if (floatingToc.classList.contains("collapsed")) {
             if (floatingToc.classList.contains("collapsed") && event.target === floatingToc) {
                 floatingToc.classList.remove("collapsed");
                 floatingToc.classList.remove("collapsed");
                event.stopPropagation();
             }
             }
         });
         });
     }, 500);
     }, 500);
});
});