1
Fork 0

Added a rustdoc shortcut for collapse/expand all

Now when the user presses the "+" key all sections will collapse/expand.

Also added a note to the help screen which describes this behavior.
This commit is contained in:
Alex Ozdemir 2016-05-20 19:21:35 -07:00
parent 179539f6eb
commit ab09fbca23
3 changed files with 11 additions and 3 deletions

View file

@ -103,6 +103,8 @@ r##"<!DOCTYPE html>
<dd>Move down in search results</dd> <dd>Move down in search results</dd>
<dt>&#9166;</dt> <dt>&#9166;</dt>
<dd>Go to active search result</dd> <dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl> </dl>
</div> </div>

View file

@ -124,6 +124,10 @@
focusSearchBar(); focusSearchBar();
break; break;
case "+":
toggleAllDocs();
break;
case "?": case "?":
if (ev.shiftKey && $("#help").hasClass("hidden")) { if (ev.shiftKey && $("#help").hasClass("hidden")) {
ev.preventDefault(); ev.preventDefault();
@ -931,7 +935,7 @@
return "\u2212"; // "\u2212" is '' minus sign return "\u2212"; // "\u2212" is '' minus sign
} }
$("#toggle-all-docs").on("click", function() { function toggleAllDocs() {
var toggle = $("#toggle-all-docs"); var toggle = $("#toggle-all-docs");
if (toggle.hasClass("will-expand")) { if (toggle.hasClass("will-expand")) {
toggle.removeClass("will-expand"); toggle.removeClass("will-expand");
@ -950,7 +954,9 @@
$(".toggle-wrapper").addClass("collapsed"); $(".toggle-wrapper").addClass("collapsed");
$(".collapse-toggle").children(".inner").text(labelForToggleButton(true)); $(".collapse-toggle").children(".inner").text(labelForToggleButton(true));
} }
}); }
$("#toggle-all-docs").on("click", toggleAllDocs);
$(document).on("click", ".collapse-toggle", function() { $(document).on("click", ".collapse-toggle", function() {
var toggle = $(this); var toggle = $(this);

View file

@ -472,7 +472,7 @@ body.blur > :not(#help) {
background: #e9e9e9; background: #e9e9e9;
box-shadow: 0 0 6px rgba(0,0,0,.2); box-shadow: 0 0 6px rgba(0,0,0,.2);
width: 550px; width: 550px;
height: 300px; height: 330px;
border: 1px solid #bfbfbf; border: 1px solid #bfbfbf;
} }
#help dt { #help dt {