Skip to content

Commit

Permalink
Auto merge of #33765 - alex-ozdemir:master, r=Manishearth
Browse files Browse the repository at this point in the history
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 required increasing the height of the help screen.
  • Loading branch information
bors committed May 22, 2016
2 parents 14d6a10 + ab09fbc commit e24d621
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ r##"<!DOCTYPE html>
<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>
Expand Down
10 changes: 8 additions & 2 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
focusSearchBar();
break;

case "+":
toggleAllDocs();
break;

case "?":
if (ev.shiftKey && $("#help").hasClass("hidden")) {
ev.preventDefault();
Expand Down Expand Up @@ -931,7 +935,7 @@
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");
Expand All @@ -950,7 +954,9 @@
$(".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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e24d621

Please sign in to comment.