Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,29 +262,35 @@ if (downloadNote.length >= 1) {
$(".pytorch-call-to-action-links").hide();
}

//This code makes the Notes section of the Docs Left Nav collapsible

if ($("p.caption:first").text() == "Notes") {

$("p.caption:first").addClass("left-nav-top-caption");
$("span.caption-text:first").after("<span class='expand-menu'>[Expand]</span>");
$(".expand-menu").after("<span class='hide-menu'>[Hide]</span>");
$("p.caption:first").next("ul").hide();
//This code handles the Expand/Hide toggle for the Docs/Tutorials left nav items

$("#pytorch-left-menu p.caption").each(function(){
var collapsedSections = ['Notes'];
var menuName = this.innerText.replace(/[^\w\s]/gi, '').trim();
if (collapsedSections.includes(menuName) == true && $(this).children().not(".expand-menu")) {
$(this).children("span").after("<span class='expand-menu'>[ + ]</span>");
$(this).children("span").after("<span class='hide-menu collapse'>[ - ]</span>");
$(this).next("ul").hide();
}else{
$(this).children("span").after("<span class='hide-menu'>[ - ]</span>");
$(this).children("span").after("<span class='expand-menu collapse'>[ + ]</span>");
}
})

$(".expand-menu").on("click", function() {
$(".hide-menu").toggle();
toggleList(this);
});
$(".expand-menu").on("click", function() {
$(this).next(".hide-menu").toggle();
$(this).parent().next("ul").toggle();
toggleList(this);
});

$(".hide-menu").on("click", function() {
$(".expand-menu").toggle();
toggleList(this);
});
$(".hide-menu").on("click", function() {
$(this).prev(".expand-menu").toggle();
$(this).parent().next("ul").toggle();
toggleList(this);
});

function toggleList(menuCommand) {
$(menuCommand).toggle();
$("p.caption:first").next("ul").toggle();
}
function toggleList(menuCommand) {
$(menuCommand).toggle();
}

// Get the card link from the card's link attribute
Expand Down
2 changes: 1 addition & 1 deletion pytorch_sphinx_theme/static/css/theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions pytorch_sphinx_theme/static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,28 +957,31 @@ if (downloadNote.length >= 1) {
$(".pytorch-call-to-action-links").hide();
}

//This code makes the Notes section of the Docs Left Nav collapsible
//This code handles the Expand/Hide toggle for the Docs/Tutorials left nav items

if ($("p.caption:first").text() == "Notes") {
var expandMenu = "#pytorch-left-menu p.caption";

$("p.caption:first").addClass("left-nav-top-caption");
$("span.caption-text:first").after("<span class='expand-menu'>[Expand]</span>");
$(".expand-menu").after("<span class='hide-menu'>[Hide]</span>");
$("p.caption:first").next("ul").hide();
if ($(expandMenu)) {

$(expandMenu).addClass("left-nav-top-caption");
$("#pytorch-left-menu span.caption-text").after("<span class='expand-menu'>[ + ]</span>");
$("#pytorch-left-menu .expand-menu").after("<span class='hide-menu'>[ - ]</span>");
$(expandMenu).next("ul").hide();

$(".expand-menu").on("click", function() {
$(".hide-menu").toggle();
$(this).next(".hide-menu").toggle();
$(this).parent().next("ul").toggle();
toggleList(this);
});

$(".hide-menu").on("click", function() {
$(".expand-menu").toggle();
$(this).prev(".expand-menu").toggle();
$(this).parent().next("ul").toggle();
toggleList(this);
});

function toggleList(menuCommand) {
$(menuCommand).toggle();
$("p.caption:first").next("ul").toggle();
}
}

Expand Down
4 changes: 2 additions & 2 deletions scss/_sphinx_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
cursor: pointer;
}

.hide-menu {
.collapse {
display: none;
}

Expand All @@ -169,7 +169,7 @@
line-height: rem(22px);
margin-bottom: rem(16px);
text-transform: none;
white-space: nowrap;
white-space: normal;
}

.pytorch-left-menu-search {
Expand Down