Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,9 @@ impl<'a> fmt::Display for Item<'a> {
try!(write!(fmt, "<span class='out-of-band'>"));
try!(write!(fmt,
r##"<span id='render-detail'>
<a id="toggle-all-docs" href="#" title="collapse all docs">[&minus;]</a>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span>"##));

// Write `src` tag
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ pre.rust { position: relative; }

.collapse-toggle > .inner {
display: inline-block;
width: 1ch;
width: 1.2ch;
text-align: center;
}

Expand Down
40 changes: 27 additions & 13 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,22 +806,35 @@
window.location = $('.srclink').attr('href');
}

function labelForToggleButton(sectionIsCollapsed) {
if (sectionIsCollapsed) {
// button will expand the section
return "+";
} else {
// button will collapse the section
// note that this text is also set in the HTML template in render.rs
return "\u2212"; // "\u2212" is '−' minus sign
}
}

$("#toggle-all-docs").on("click", function() {
var toggle = $("#toggle-all-docs");
if (toggle.html() == "[&minus;]") {
toggle.html("[&plus;]");
toggle.attr("title", "expand all docs");
$(".docblock").hide();
$(".toggle-label").show();
$(".toggle-wrapper").addClass("collapsed");
$(".collapse-toggle").children(".inner").html("&plus;");
} else {
toggle.html("[&minus;]");
if (toggle.hasClass("will-expand")) {
toggle.removeClass("will-expand");
toggle.children(".inner").text(labelForToggleButton(false));
toggle.attr("title", "collapse all docs");
$(".docblock").show();
$(".toggle-label").hide();
$(".toggle-wrapper").removeClass("collapsed");
$(".collapse-toggle").children(".inner").html("&minus;");
$(".collapse-toggle").children(".inner").text(labelForToggleButton(false));
} else {
toggle.addClass("will-expand");
toggle.children(".inner").text(labelForToggleButton(true));
toggle.attr("title", "expand all docs");
$(".docblock").hide();
$(".toggle-label").show();
$(".toggle-wrapper").addClass("collapsed");
$(".collapse-toggle").children(".inner").text(labelForToggleButton(true));
}
});

Expand All @@ -835,20 +848,21 @@
if (relatedDoc.is(":visible")) {
relatedDoc.slideUp({duration:'fast', easing:'linear'});
toggle.parent(".toggle-wrapper").addClass("collapsed");
toggle.children(".inner").html("&plus;");
toggle.children(".inner").text(labelForToggleButton(true));
toggle.children(".toggle-label").fadeIn();
} else {
relatedDoc.slideDown({duration:'fast', easing:'linear'});
toggle.parent(".toggle-wrapper").removeClass("collapsed");
toggle.children(".inner").html("&minus;");
toggle.children(".inner").text(labelForToggleButton(false));
toggle.children(".toggle-label").hide();
}
}
});

$(function() {
var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
.html("[<span class='inner'>&minus;</span>]");
.html("[<span class='inner'></span>]");
toggle.children(".inner").text(labelForToggleButton(false));

$(".method").each(function() {
if ($(this).next().is(".docblock") ||
Expand Down