diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9a26a925847e4..f7ab5fc9b0958 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1460,7 +1460,9 @@ impl<'a> fmt::Display for Item<'a> { try!(write!(fmt, "")); try!(write!(fmt, r##" - [−] + + [] + "##)); // Write `src` tag diff --git a/src/librustdoc/html/static/main.css b/src/librustdoc/html/static/main.css index b907e9e20b698..2dc5ea9906744 100644 --- a/src/librustdoc/html/static/main.css +++ b/src/librustdoc/html/static/main.css @@ -581,7 +581,7 @@ pre.rust { position: relative; } .collapse-toggle > .inner { display: inline-block; - width: 1ch; + width: 1.2ch; text-align: center; } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index c2a59278a86dc..6a1d7bdfd8358 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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() == "[−]") { - 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("[−]"); + 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("−"); + $(".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)); } }); @@ -835,12 +848,12 @@ if (relatedDoc.is(":visible")) { relatedDoc.slideUp({duration:'fast', easing:'linear'}); toggle.parent(".toggle-wrapper").addClass("collapsed"); - toggle.children(".inner").html("+"); + 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("−"); + toggle.children(".inner").text(labelForToggleButton(false)); toggle.children(".toggle-label").hide(); } } @@ -848,7 +861,8 @@ $(function() { var toggle = $("", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'}) - .html("[]"); + .html("[]"); + toggle.children(".inner").text(labelForToggleButton(false)); $(".method").each(function() { if ($(this).next().is(".docblock") ||