]> git.lizzy.rs Git - rust.git/commitdiff
Added a `rustdoc` shortcut for collapse/expand all
authorAlex Ozdemir <aozdemir@hmc.edu>
Sat, 21 May 2016 02:21:35 +0000 (19:21 -0700)
committerAlex Ozdemir <aozdemir@hmc.edu>
Sat, 21 May 2016 02:43:47 +0000 (19:43 -0700)
Now when the user presses the "+" key all sections will collapse/expand.

Also added a note to the help screen which describes this behavior.

src/librustdoc/html/layout.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/rustdoc.css

index a168fe98a94cf8d2c3548ee4cacfe849493f6e1a..265ed6be1552d2a04519bf2e9161901f859670ff 100644 (file)
@@ -103,6 +103,8 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
                     <dd>Move down in search results</dd>
                     <dt>&#9166;</dt>
                     <dd>Go to active search result</dd>
+                    <dt>+</dt>
+                    <dd>Collapse/expand all sections</dd>
                 </dl>
             </div>
 
index a368b4197a3950e4fa22c459c47ba3641b0fe221..0ec5cab78bc7b93459fb40a49c4b8f3403900bf4 100644 (file)
             focusSearchBar();
             break;
 
+        case "+":
+            toggleAllDocs();
+            break;
+
         case "?":
             if (ev.shiftKey && $("#help").hasClass("hidden")) {
                 ev.preventDefault();
         return "\u2212"; // "\u2212" is '−' minus sign
     }
 
-    $("#toggle-all-docs").on("click", function() {
+    function toggleAllDocs() {
         var toggle = $("#toggle-all-docs");
         if (toggle.hasClass("will-expand")) {
             toggle.removeClass("will-expand");
             $(".toggle-wrapper").addClass("collapsed");
             $(".collapse-toggle").children(".inner").text(labelForToggleButton(true));
         }
-    });
+    }
+
+    $("#toggle-all-docs").on("click", toggleAllDocs);
 
     $(document).on("click", ".collapse-toggle", function() {
         var toggle = $(this);
index a52a914fea680766853614fefe796a99163923ea..8e4245d4ebf12db4ec78344a3d02b05c92b23d6a 100644 (file)
@@ -472,7 +472,7 @@ body.blur > :not(#help) {
     background: #e9e9e9;
     box-shadow: 0 0 6px rgba(0,0,0,.2);
     width: 550px;
-    height: 300px;
+    height: 330px;
     border: 1px solid #bfbfbf;
 }
 #help dt {