web/assets/js/_utils/category-collapse.js

31 lines
971 B
JavaScript
Raw Normal View History

2019-09-30 15:38:41 +03:00
/*
* Tab 'Categories' expand/close effect.
*/
$(function() {
2021-01-23 10:07:18 +03:00
const childPrefix = "l_";
const parentPrefix = "h_";
const collapse = $(".collapse");
2019-09-30 15:38:41 +03:00
/* close up top-category */
2021-01-23 10:07:18 +03:00
collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
2020-08-19 07:26:45 +03:00
if (parentId) {
2021-01-23 10:07:18 +03:00
$(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw");
$(`#${parentId} i.fas`).addClass("rotate");
$(`#${parentId}`).removeClass("hide-border-bottom");
2019-09-30 15:38:41 +03:00
}
});
/* expand the top category */
2021-01-23 10:07:18 +03:00
collapse.on("show.bs.collapse", function() {
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
2020-08-19 07:26:45 +03:00
if (parentId) {
2021-01-23 10:07:18 +03:00
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
$(`#${parentId} i.fas`).removeClass("rotate");
$(`#${parentId}`).addClass("hide-border-bottom");
2019-09-30 15:38:41 +03:00
}
});
2021-01-23 10:07:18 +03:00
});