Auto merge of #24694 - liigo:toggle-all-docs-using-one-link, r=alexcrichton

Combine the two links, [-] and [+], at top-right corner of the page, to use a single and the same one, so that:

- one less link to be created/displayed
- be consistent with other [-]/[+] links in the same page
- people can easily toggle docs without moving their mouse pointer

I also added tooltips/titles to these links.
This commit is contained in:
bors 2015-04-23 14:09:10 +00:00
commit 65f889919d
2 changed files with 20 additions and 15 deletions

View File

@ -1460,7 +1460,7 @@ impl<'a> fmt::Display for Item<'a> {
try!(write!(fmt, "<span class='out-of-band'>")); try!(write!(fmt, "<span class='out-of-band'>"));
try!(write!(fmt, try!(write!(fmt,
r##"<span id='render-detail'> r##"<span id='render-detail'>
<a id="collapse-all" href="#">[-]</a>&nbsp;<a id="expand-all" href="#">[+]</a> <a id="toggle-all-docs" href="#" title="collapse all docs">[-]</a>
</span>"##)); </span>"##));
// Write `src` tag // Write `src` tag
@ -1473,8 +1473,8 @@ impl<'a> fmt::Display for Item<'a> {
match self.href(self.cx) { match self.href(self.cx) {
Some(l) => { Some(l) => {
try!(write!(fmt, "<a id='src-{}' class='srclink' \ try!(write!(fmt, "<a id='src-{}' class='srclink' \
href='{}'>[src]</a>", href='{}' title='{}'>[src]</a>",
self.item.def_id.node, l)); self.item.def_id.node, l, "goto source code"));
} }
None => {} None => {}
} }

View File

@ -806,18 +806,23 @@
window.location = $('.srclink').attr('href'); window.location = $('.srclink').attr('href');
} }
$("#expand-all").on("click", function() { $("#toggle-all-docs").on("click", function() {
$(".docblock").show(); var toggle = $("#toggle-all-docs");
$(".toggle-label").hide(); if (toggle.html() == "[-]") {
$(".toggle-wrapper").removeClass("collapsed"); toggle.html("[+]");
$(".collapse-toggle").children(".inner").html("-"); toggle.attr("title", "expand all docs");
}); $(".docblock").hide();
$(".toggle-label").show();
$("#collapse-all").on("click", function() { $(".toggle-wrapper").addClass("collapsed");
$(".docblock").hide(); $(".collapse-toggle").children(".inner").html("+");
$(".toggle-label").show(); } else {
$(".toggle-wrapper").addClass("collapsed"); toggle.html("[-]");
$(".collapse-toggle").children(".inner").html("+"); toggle.attr("title", "collapse all docs");
$(".docblock").show();
$(".toggle-label").hide();
$(".toggle-wrapper").removeClass("collapsed");
$(".collapse-toggle").children(".inner").html("-");
}
}); });
$(document).on("click", ".collapse-toggle", function() { $(document).on("click", ".collapse-toggle", function() {