@@ -409,9 +409,12 @@ function loadCss(cssFileName) {
409
409
break;
410
410
411
411
case "+":
412
+ ev.preventDefault();
413
+ expandAllDocs();
414
+ break;
412
415
case "-":
413
416
ev.preventDefault();
414
- toggleAllDocs ();
417
+ collapseAllDocs ();
415
418
break;
416
419
417
420
case "?":
@@ -614,45 +617,43 @@ function loadCss(cssFileName) {
614
617
sidebarElems.appendChild(ul);
615
618
}
616
619
620
+ function expandAllDocs() {
621
+ const innerToggle = document.getElementById(toggleAllDocsId);
622
+ removeClass(innerToggle, "will-expand");
623
+ onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
624
+ if (!hasClass(e, "type-contents-toggle")) {
625
+ e.open = true;
626
+ }
627
+ });
628
+ innerToggle.title = "collapse all docs";
629
+ innerToggle.children[0].innerText = "\u2212"; // "\u2212" is "−" minus sign
630
+ }
617
631
618
- function labelForToggleButton(sectionIsCollapsed) {
619
- if (sectionIsCollapsed) {
620
- // button will expand the section
621
- return "+";
622
- }
623
- // button will collapse the section
624
- // note that this text is also set in the HTML template in ../render/mod.rs
625
- return "\u2212"; // "\u2212" is "−" minus sign
632
+ function collapseAllDocs() {
633
+ const innerToggle = document.getElementById(toggleAllDocsId);
634
+ addClass(innerToggle, "will-expand");
635
+ onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
636
+ if (e.parentNode.id !== "implementations-list" ||
637
+ (!hasClass(e, "implementors-toggle") &&
638
+ !hasClass(e, "type-contents-toggle"))
639
+ ) {
640
+ e.open = false;
641
+ }
642
+ });
643
+ innerToggle.title = "expand all docs";
644
+ innerToggle.children[0].innerText = "+";
626
645
}
627
646
628
647
function toggleAllDocs() {
629
648
const innerToggle = document.getElementById(toggleAllDocsId);
630
649
if (!innerToggle) {
631
650
return;
632
651
}
633
- let sectionIsCollapsed = false;
634
652
if (hasClass(innerToggle, "will-expand")) {
635
- removeClass(innerToggle, "will-expand");
636
- onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
637
- if (!hasClass(e, "type-contents-toggle")) {
638
- e.open = true;
639
- }
640
- });
641
- innerToggle.title = "collapse all docs";
653
+ expandAllDocs();
642
654
} else {
643
- addClass(innerToggle, "will-expand");
644
- onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
645
- if (e.parentNode.id !== "implementations-list" ||
646
- (!hasClass(e, "implementors-toggle") &&
647
- !hasClass(e, "type-contents-toggle"))
648
- ) {
649
- e.open = false;
650
- }
651
- });
652
- sectionIsCollapsed = true;
653
- innerToggle.title = "expand all docs";
655
+ collapseAllDocs();
654
656
}
655
- innerToggle.children[0].innerText = labelForToggleButton(sectionIsCollapsed);
656
657
}
657
658
658
659
(function() {
0 commit comments