diff --git a/js/theme.js b/js/theme.js index b464aefd..53432474 100644 --- a/js/theme.js +++ b/js/theme.js @@ -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("[Expand]"); - $(".expand-menu").after("[Hide]"); - $("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("[ + ]"); + $(this).children("span").after("[ - ]"); + $(this).next("ul").hide(); + }else{ + $(this).children("span").after("[ - ]"); + $(this).children("span").after("[ + ]"); + } + }) - $(".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 diff --git a/pytorch_sphinx_theme/static/css/theme.css b/pytorch_sphinx_theme/static/css/theme.css index 8d9d5517..9b27c37e 100644 --- a/pytorch_sphinx_theme/static/css/theme.css +++ b/pytorch_sphinx_theme/static/css/theme.css @@ -11683,7 +11683,7 @@ article.pytorch-article .tutorials-callout-container .btn.callout-button a { line-height: 1.375rem; margin-bottom: 1rem; text-transform: none; - white-space: nowrap; + white-space: normal; } .pytorch-left-menu-search { diff --git a/pytorch_sphinx_theme/static/js/theme.js b/pytorch_sphinx_theme/static/js/theme.js index e5ec63e7..2b496d21 100644 --- a/pytorch_sphinx_theme/static/js/theme.js +++ b/pytorch_sphinx_theme/static/js/theme.js @@ -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("[Expand]"); - $(".expand-menu").after("[Hide]"); - $("p.caption:first").next("ul").hide(); +if ($(expandMenu)) { + + $(expandMenu).addClass("left-nav-top-caption"); + $("#pytorch-left-menu span.caption-text").after("[ + ]"); + $("#pytorch-left-menu .expand-menu").after("[ - ]"); + $(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(); } } diff --git a/scss/_sphinx_layout.scss b/scss/_sphinx_layout.scss index 524ac90a..f6427661 100644 --- a/scss/_sphinx_layout.scss +++ b/scss/_sphinx_layout.scss @@ -154,7 +154,7 @@ cursor: pointer; } -.hide-menu { +.collapse { display: none; } @@ -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 {