From 55cc9a43368aae6e6ed3a0c75ee8fd47ac4f3bcd Mon Sep 17 00:00:00 2001 From: Peter Lyons Date: Wed, 28 Feb 2018 20:51:40 -0700 Subject: [PATCH 1/2] Remember state of top-level collapse toggle widget --- src/librustdoc/html/static/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 960f2f198d8b0..4f90b86a3f7ac 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1623,6 +1623,7 @@ function toggleAllDocs() { var toggle = document.getElementById("toggle-all-docs"); if (hasClass(toggle, "will-expand")) { + updateLocalStorage("collapse", "false"); removeClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(false); @@ -1632,6 +1633,7 @@ collapseDocs(e, "show"); }); } else { + updateLocalStorage("collapse", "true"); addClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(true); @@ -1972,6 +1974,10 @@ window.onresize = function() { hideSidebar(); }; + + if (getCurrentValue("collapse") === "true") { + toggleAllDocs(); + } }()); // Sets the focus on the search bar at the top of the page From 2dd81c86c51435ed57d7a2b16f1b66c254a64cc8 Mon Sep 17 00:00:00 2001 From: Peter Lyons Date: Thu, 1 Mar 2018 02:50:32 -0700 Subject: [PATCH 2/2] Rename doc collapse sentinal to rustdoc-collapse --- src/librustdoc/html/static/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 4f90b86a3f7ac..c5c31d109fbf3 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1623,7 +1623,7 @@ function toggleAllDocs() { var toggle = document.getElementById("toggle-all-docs"); if (hasClass(toggle, "will-expand")) { - updateLocalStorage("collapse", "false"); + updateLocalStorage("rustdoc-collapse", "false"); removeClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(false); @@ -1633,7 +1633,7 @@ collapseDocs(e, "show"); }); } else { - updateLocalStorage("collapse", "true"); + updateLocalStorage("rustdoc-collapse", "true"); addClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(true); @@ -1975,7 +1975,7 @@ hideSidebar(); }; - if (getCurrentValue("collapse") === "true") { + if (getCurrentValue("rustdoc-collapse") === "true") { toggleAllDocs(); } }());