Skip to content

Commit

Permalink
Set attributes hidden by default
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 6, 2016
1 parent 22dad4b commit 520d5f4
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,27 +963,35 @@
}
}

$("#toggle-all-docs").on("click", toggleAllDocs);

$(document).on("click", ".collapse-toggle", function() {
var toggle = $(this);
function collapseDocs(toggle, animate) {
var relatedDoc = toggle.parent().next();
if (relatedDoc.is(".stability")) {
relatedDoc = relatedDoc.next();
}
if (relatedDoc.is(".docblock")) {
if (relatedDoc.is(":visible")) {
relatedDoc.slideUp({duration: 'fast', easing: 'linear'});
if (animate === true) {
relatedDoc.slideUp({duration: 'fast', easing: 'linear'});
toggle.children(".toggle-label").fadeIn();
} else {
relatedDoc.hide();
toggle.children(".toggle-label").show();
}
toggle.parent(".toggle-wrapper").addClass("collapsed");
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").text(labelForToggleButton(false));
toggle.children(".toggle-label").hide();
}
}
}

$("#toggle-all-docs").on("click", toggleAllDocs);

$(document).on("click", ".collapse-toggle", function() {
collapseDocs($(this), true)
});

$(function() {
Expand All @@ -999,14 +1007,22 @@
});

var mainToggle =
$(toggle).append(
$(toggle.clone()).append(
$('<span/>', {'class': 'toggle-label'})
.css('display', 'none')
.html('&nbsp;Expand&nbsp;description'));
var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
$("#main > .docblock").before(wrapper);
var mainToggle =
$(toggle).append(
$('<span/>', {'class': 'toggle-label'})
.css('display', 'none')
.html('&nbsp;Expand&nbsp;attributes'));
var wrapper = $("<div class='toggle-wrapper toggle-attributes'>").append(mainToggle);
$("#main > pre > .docblock").before(wrapper);
$("#main > pre > .attributes").each(function() {
$(this).before(wrapper);
collapseDocs($($(this).prev().children()[0]), false);
});
});

$('pre.line-numbers').on('click', 'span', function() {
Expand Down

0 comments on commit 520d5f4

Please sign in to comment.