From aee054d05d8b795d35c0b448a4b731b6507aa459 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 21 May 2021 15:50:55 +0200 Subject: [PATCH] Remove dead toggle JS code --- src/librustdoc/html/static/main.js | 158 ----------------------------- 1 file changed, 158 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1ed94ec109c18..1e28056bb6882 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -764,138 +764,6 @@ function hideThemeButtonState() { innerToggle.children[0].innerText = labelForToggleButton(sectionIsCollapsed); } - function collapseDocs(toggle, mode) { - if (!toggle || !toggle.parentNode) { - return; - } - - function adjustToggle(arg) { - return function(e) { - if (hasClass(e, "toggle-label")) { - if (arg) { - e.style.display = "inline-block"; - } else { - e.style.display = "none"; - } - } - if (hasClass(e, "inner")) { - e.innerHTML = labelForToggleButton(arg); - } - }; - } - - function implHider(addOrRemove, fullHide) { - return function(n) { - var shouldHide = - fullHide || - hasClass(n, "method") || - hasClass(n, "associatedconstant"); - if (shouldHide || hasClass(n, "type")) { - if (shouldHide) { - if (addOrRemove) { - addClass(n, "hidden-by-impl-hider"); - } else { - removeClass(n, "hidden-by-impl-hider"); - } - } - var ns = n.nextElementSibling; - while (ns && (hasClass(ns, "docblock") || hasClass(ns, "item-info"))) { - if (addOrRemove) { - addClass(ns, "hidden-by-impl-hider"); - } else { - removeClass(ns, "hidden-by-impl-hider"); - } - ns = ns.nextElementSibling; - } - } - }; - } - - var relatedDoc; - var action = mode; - if (!hasClass(toggle.parentNode, "impl")) { - relatedDoc = toggle.parentNode.nextElementSibling; - if (hasClass(relatedDoc, "item-info")) { - relatedDoc = relatedDoc.nextElementSibling; - } - if (hasClass(relatedDoc, "docblock")) { - if (mode === "toggle") { - if (hasClass(relatedDoc, "hidden-by-usual-hider")) { - action = "show"; - } else { - action = "hide"; - } - } - if (action === "hide") { - addClass(relatedDoc, "hidden-by-usual-hider"); - onEachLazy(toggle.childNodes, adjustToggle(true)); - addClass(toggle.parentNode, "collapsed"); - } else if (action === "show") { - removeClass(relatedDoc, "hidden-by-usual-hider"); - removeClass(toggle.parentNode, "collapsed"); - onEachLazy(toggle.childNodes, adjustToggle(false)); - } - } - } else { - // we are collapsing the impl block(s). - - var parentElem = toggle.parentNode; - relatedDoc = parentElem; - var docblock = relatedDoc.nextElementSibling; - - while (!hasClass(relatedDoc, "impl-items")) { - relatedDoc = relatedDoc.nextElementSibling; - } - - if (!relatedDoc && !hasClass(docblock, "docblock")) { - return; - } - - // Hide all functions, but not associated types/consts. - - if (mode === "toggle") { - if (hasClass(relatedDoc, "fns-now-collapsed") || - hasClass(docblock, "hidden-by-impl-hider")) { - action = "show"; - } else { - action = "hide"; - } - } - - var dontApplyBlockRule = toggle.parentNode.parentNode.id !== "main"; - if (action === "show") { - removeClass(relatedDoc, "fns-now-collapsed"); - // Stability/deprecation/portability information is never hidden. - if (!hasClass(docblock, "item-info")) { - removeClass(docblock, "hidden-by-usual-hider"); - } - onEachLazy(toggle.childNodes, adjustToggle(false, dontApplyBlockRule)); - onEachLazy(relatedDoc.childNodes, implHider(false, dontApplyBlockRule)); - } else if (action === "hide") { - addClass(relatedDoc, "fns-now-collapsed"); - // Stability/deprecation/portability information should be shown even when detailed - // info is hidden. - if (!hasClass(docblock, "item-info")) { - addClass(docblock, "hidden-by-usual-hider"); - } - onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule)); - onEachLazy(relatedDoc.childNodes, implHider(true, dontApplyBlockRule)); - } - } - } - - function collapseNonInherent(e) { - // inherent impl ids are like "impl" or impl-'. - // they will never be hidden by default. - var n = e.parentElement; - if (n.id.match(/^impl(?:-\d+)?$/) === null) { - // Automatically minimize all non-inherent impls - if (hasClass(n, "impl")) { - collapseDocs(e, "hide"); - } - } - } - function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } @@ -910,20 +778,6 @@ function hideThemeButtonState() { var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false"; var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false"; - var impl_list = document.getElementById("trait-implementations-list"); - if (impl_list !== null) { - onEachLazy(impl_list.getElementsByClassName("rustdoc-toggle"), function(e) { - collapseNonInherent(e); - }); - } - - var blanket_list = document.getElementById("blanket-implementations-list"); - if (blanket_list !== null) { - onEachLazy(blanket_list.getElementsByClassName("rustdoc-toggle"), function(e) { - collapseNonInherent(e); - }); - } - onEachLazy(document.getElementsByTagName("details"), function (e) { var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle"); var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle"); @@ -936,18 +790,6 @@ function hideThemeButtonState() { }); - var currentType = document.getElementsByClassName("type-decl")[0]; - if (currentType) { - currentType = currentType.getElementsByClassName("rust")[0]; - if (currentType) { - onEachLazy(currentType.classList, function(item) { - if (item !== "main") { - return true; - } - }); - } - } - var pageId = getPageId(); if (pageId !== null) { expandSection(pageId);