diff options
| author | kennytm <kennytm@gmail.com> | 2018-03-13 05:01:15 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-03-13 05:01:15 +0800 |
| commit | 15d71d32852024555ec008c3921fe0cd4e6cb047 (patch) | |
| tree | fcec4bdf693ad483135ea85eef0e7c87afbbadcc | |
| parent | 684c6d17c575893b4cd4913f2558cb8731785c01 (diff) | |
| parent | 2dd81c86c51435ed57d7a2b16f1b66c254a64cc8 (diff) | |
| download | rust-15d71d32852024555ec008c3921fe0cd4e6cb047.tar.gz rust-15d71d32852024555ec008c3921fe0cd4e6cb047.zip | |
Rollup merge of #48631 - focusaurus:remember-collapse-setting, r=QuietMisdreavus
Remember state of top-level collapse toggle widget This change allows the big top-right expand/collapse toggle to remember its setting across navigation or page reloads. Prior to this change, there was this annoyance: - browse to some docs - Click the minus button to collapse them - browse to other docs (or reload the page) - Everything is expanded again The solution is based on storing a simple boolean flag in localStorage. I think it's a good improvement, but it does introduce the following potentially surprising behavior: - browse to some docs - click the minus button to collapse them - click to expand a particular item (not the main top-right big one) - reload the page, everything is collapsed Paired with @debugsteven on this.
| -rw-r--r-- | src/librustdoc/html/static/main.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f1c9c58a4eb..28d39cb174a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1628,6 +1628,7 @@ function toggleAllDocs() { var toggle = document.getElementById("toggle-all-docs"); if (hasClass(toggle, "will-expand")) { + updateLocalStorage("rustdoc-collapse", "false"); removeClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(false); @@ -1637,6 +1638,7 @@ collapseDocs(e, "show"); }); } else { + updateLocalStorage("rustdoc-collapse", "true"); addClass(toggle, "will-expand"); onEveryMatchingChild(toggle, "inner", function(e) { e.innerHTML = labelForToggleButton(true); @@ -1988,6 +1990,10 @@ window.onresize = function() { hideSidebar(); }; + + if (getCurrentValue("rustdoc-collapse") === "true") { + toggleAllDocs(); + } }()); // Sets the focus on the search bar at the top of the page |
