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

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-09-30 14:38:41 +02:00
/*
* Tab 'Categories' expand/close effect.
2020-01-02 14:17:49 +01:00
* v2.0
* https://github.com/cotes2020/jekyll-theme-chirpy
2019-09-30 14:38:41 +02:00
* © 2018-2019 Cotes Chung
* MIT License
*/
$(function() {
2020-08-19 06:26:45 +02:00
var childPrefix = "l_";
var parentPrefix = "h_";
2019-09-30 14:38:41 +02:00
/* close up top-category */
$(".collapse").on("hide.bs.collapse", function() { /* Bootstrap collapse events. */
2020-08-19 06:26:45 +02:00
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
if (parentId) {
$("#" + 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 14:38:41 +02:00
}
});
/* expand the top category */
2019-09-30 14:38:41 +02:00
$(".collapse").on("show.bs.collapse", function() {
2020-08-19 06:26:45 +02:00
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
if (parentId) {
$("#" + 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 14:38:41 +02:00
}
});
});