| 1 |
<script> |
| 2 |
jQuery(document).ready(function($) { |
| 3 |
let listSidebarCatTitles = $( |
| 4 |
".betterdocs-sidebar-content .betterdocs-sidebar-list-wrapper .betterdocs-sidebar-list .betterdocs-category-header" |
| 5 |
); |
| 6 |
let catTitleList = $( |
| 7 |
".betterdocs-sidebar-content .betterdocs-category-grid-wrapper .betterdocs-single-category-wrapper .betterdocs-category-header" |
| 8 |
); |
| 9 |
let currentActiveCat = $( |
| 10 |
".betterdocs-sidebar-content .betterdocs-category-grid-wrapper .betterdocs-single-category-wrapper.active" |
| 11 |
); |
| 12 |
let listSidebarCurrentCat = $( |
| 13 |
".betterdocs-sidebar-content .betterdocs-sidebar-list-wrapper .betterdocs-sidebar-list.active" |
| 14 |
); |
| 15 |
|
| 16 |
let nestedCategoriesToggle = $(".betterdocs-nested-category-title"); |
| 17 |
|
| 18 |
function categoryAccordion() { |
| 19 |
let $parentThis = this; |
| 20 |
currentActiveCat |
| 21 |
.addClass("show") |
| 22 |
.find(".betterdocs-body") |
| 23 |
.css("display", "block"); |
| 24 |
currentActiveCat |
| 25 |
.siblings() |
| 26 |
.find(".betterdocs-body") |
| 27 |
.css("display", "none"); |
| 28 |
catTitleList.on("click", function (e) { |
| 29 |
e.preventDefault(); |
| 30 |
let $parentCat = jQuery(e.target).closest( |
| 31 |
".betterdocs-single-category-wrapper" |
| 32 |
); |
| 33 |
$parentCat.find(".betterdocs-body").slideToggle(); |
| 34 |
$parentCat |
| 35 |
.addClass("active") |
| 36 |
.toggleClass("show") |
| 37 |
.siblings() |
| 38 |
.removeClass("active") |
| 39 |
.find(".betterdocs-body") |
| 40 |
.slideUp(); |
| 41 |
}); |
| 42 |
} |
| 43 |
categoryAccordion(); |
| 44 |
|
| 45 |
function categoryListAccordion() { |
| 46 |
let $parentThis = this; |
| 47 |
listSidebarCurrentCat |
| 48 |
.find(".betterdocs-body") |
| 49 |
.css("display", "block"); |
| 50 |
listSidebarCurrentCat |
| 51 |
.siblings() |
| 52 |
.find(".betterdocs-body") |
| 53 |
.css("display", "none"); |
| 54 |
listSidebarCatTitles.on("click", function (e) { |
| 55 |
console.log(e.target); |
| 56 |
e.preventDefault(); |
| 57 |
let $parentCat = jQuery(e.target).closest( |
| 58 |
".betterdocs-sidebar-list" |
| 59 |
); |
| 60 |
$parentCat.find(".betterdocs-body").slideToggle(); |
| 61 |
$parentCat |
| 62 |
.toggleClass("active") |
| 63 |
.siblings() |
| 64 |
.removeClass("active") |
| 65 |
.find(".betterdocs-body") |
| 66 |
.slideUp(); |
| 67 |
}); |
| 68 |
} |
| 69 |
categoryListAccordion(); |
| 70 |
|
| 71 |
function nestedCategoryToggler() { |
| 72 |
nestedCategoriesToggle.on("click", function (e) { |
| 73 |
e.preventDefault(); |
| 74 |
jQuery(this).children(".toggle-arrow").toggle(); |
| 75 |
jQuery(this).next(".betterdocs-nested-category-list").slideToggle(); |
| 76 |
}); |
| 77 |
} |
| 78 |
nestedCategoryToggler(); |
| 79 |
}); |
| 80 |
</script> |
| 81 |
|
| 82 |
|
| 83 |
|