|
806 | 806 | window.location = $('.srclink').attr('href');
|
807 | 807 | }
|
808 | 808 |
|
| 809 | + function labelForToggleButton(sectionIsCollapsed) { |
| 810 | + if (sectionIsCollapsed) { |
| 811 | + // button will expand the section |
| 812 | + return "+"; |
| 813 | + } else { |
| 814 | + // button will collapse the section |
| 815 | + // note that this text is also set in the HTML template in render.rs |
| 816 | + return "\u2212"; // "\u2212" is '−' minus sign |
| 817 | + } |
| 818 | + } |
| 819 | + |
809 | 820 | $("#toggle-all-docs").on("click", function() {
|
810 | 821 | var toggle = $("#toggle-all-docs");
|
811 |
| - if (toggle.html() == "[−]") { |
812 |
| - toggle.html("[+]"); |
813 |
| - toggle.attr("title", "expand all docs"); |
814 |
| - $(".docblock").hide(); |
815 |
| - $(".toggle-label").show(); |
816 |
| - $(".toggle-wrapper").addClass("collapsed"); |
817 |
| - $(".collapse-toggle").children(".inner").html("+"); |
818 |
| - } else { |
819 |
| - toggle.html("[−]"); |
| 822 | + if (toggle.hasClass("will-expand")) { |
| 823 | + toggle.removeClass("will-expand"); |
| 824 | + toggle.children(".inner").text(labelForToggleButton(false)); |
820 | 825 | toggle.attr("title", "collapse all docs");
|
821 | 826 | $(".docblock").show();
|
822 | 827 | $(".toggle-label").hide();
|
823 | 828 | $(".toggle-wrapper").removeClass("collapsed");
|
824 |
| - $(".collapse-toggle").children(".inner").html("−"); |
| 829 | + $(".collapse-toggle").children(".inner").text(labelForToggleButton(false)); |
| 830 | + } else { |
| 831 | + toggle.addClass("will-expand"); |
| 832 | + toggle.children(".inner").text(labelForToggleButton(true)); |
| 833 | + toggle.attr("title", "expand all docs"); |
| 834 | + $(".docblock").hide(); |
| 835 | + $(".toggle-label").show(); |
| 836 | + $(".toggle-wrapper").addClass("collapsed"); |
| 837 | + $(".collapse-toggle").children(".inner").text(labelForToggleButton(true)); |
825 | 838 | }
|
826 | 839 | });
|
827 | 840 |
|
|
835 | 848 | if (relatedDoc.is(":visible")) {
|
836 | 849 | relatedDoc.slideUp({duration:'fast', easing:'linear'});
|
837 | 850 | toggle.parent(".toggle-wrapper").addClass("collapsed");
|
838 |
| - toggle.children(".inner").html("+"); |
| 851 | + toggle.children(".inner").text(labelForToggleButton(true)); |
839 | 852 | toggle.children(".toggle-label").fadeIn();
|
840 | 853 | } else {
|
841 | 854 | relatedDoc.slideDown({duration:'fast', easing:'linear'});
|
842 | 855 | toggle.parent(".toggle-wrapper").removeClass("collapsed");
|
843 |
| - toggle.children(".inner").html("−"); |
| 856 | + toggle.children(".inner").text(labelForToggleButton(false)); |
844 | 857 | toggle.children(".toggle-label").hide();
|
845 | 858 | }
|
846 | 859 | }
|
847 | 860 | });
|
848 | 861 |
|
849 | 862 | $(function() {
|
850 | 863 | var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
|
851 |
| - .html("[<span class='inner'>−</span>]"); |
| 864 | + .html("[<span class='inner'></span>]"); |
| 865 | + toggle.children(".inner").text(labelForToggleButton(false)); |
852 | 866 |
|
853 | 867 | $(".method").each(function() {
|
854 | 868 | if ($(this).next().is(".docblock") ||
|
|
0 commit comments