diff options
| author | bors <bors@rust-lang.org> | 2015-04-23 14:09:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-23 14:09:10 +0000 |
| commit | 65f889919d23f5050b09ad4b80b0235f3c882cc7 (patch) | |
| tree | d32cced6d2bbb31f3d762faf7d648b9ae5ea39f8 | |
| parent | 1114fcd945f6e979660053aeed561bcfb5da669e (diff) | |
| parent | 7a5308152276e5629e4071424367796025d6eac5 (diff) | |
| download | rust-65f889919d23f5050b09ad4b80b0235f3c882cc7.tar.gz rust-65f889919d23f5050b09ad4b80b0235f3c882cc7.zip | |
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.
| -rw-r--r-- | src/librustdoc/html/render.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/html/static/main.js | 29 |
2 files changed, 20 insertions, 15 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 3f3f8201b00..1993f03efd1 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1460,7 +1460,7 @@ 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="collapse-all" href="#">[-]</a> <a id="expand-all" href="#">[+]</a> + <a id="toggle-all-docs" href="#" title="collapse all docs">[-]</a> </span>"##)); // Write `src` tag @@ -1473,8 +1473,8 @@ impl<'a> fmt::Display for Item<'a> { match self.href(self.cx) { Some(l) => { try!(write!(fmt, "<a id='src-{}' class='srclink' \ - href='{}'>[src]</a>", - self.item.def_id.node, l)); + href='{}' title='{}'>[src]</a>", + self.item.def_id.node, l, "goto source code")); } None => {} } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 0379c04be4d..9e00a64d3f5 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -806,18 +806,23 @@ window.location = $('.srclink').attr('href'); } - $("#expand-all").on("click", function() { - $(".docblock").show(); - $(".toggle-label").hide(); - $(".toggle-wrapper").removeClass("collapsed"); - $(".collapse-toggle").children(".inner").html("-"); - }); - - $("#collapse-all").on("click", function() { - $(".docblock").hide(); - $(".toggle-label").show(); - $(".toggle-wrapper").addClass("collapsed"); - $(".collapse-toggle").children(".inner").html("+"); + $("#toggle-all-docs").on("click", function() { + var toggle = $("#toggle-all-docs"); + if (toggle.html() == "[-]") { + toggle.html("[+]"); + toggle.attr("title", "expand all docs"); + $(".docblock").hide(); + $(".toggle-label").show(); + $(".toggle-wrapper").addClass("collapsed"); + $(".collapse-toggle").children(".inner").html("+"); + } else { + toggle.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() { |
