2023-03-13 15:20:59 +03:00
|
|
|
/**
|
|
|
|
* Tab 'Categories' expand/close effect.
|
|
|
|
*/
|
2024-05-11 05:29:14 +03:00
|
|
|
|
|
|
|
import 'bootstrap/js/src/collapse.js';
|
|
|
|
|
2023-03-13 15:20:59 +03:00
|
|
|
const childPrefix = 'l_';
|
|
|
|
const parentPrefix = 'h_';
|
2024-04-17 01:10:01 +03:00
|
|
|
const children = document.getElementsByClassName('collapse');
|
2023-03-13 15:20:59 +03:00
|
|
|
|
|
|
|
export function categoryCollapse() {
|
2024-04-17 01:10:01 +03:00
|
|
|
[...children].forEach((elem) => {
|
|
|
|
const id = parentPrefix + elem.id.substring(childPrefix.length);
|
|
|
|
const parent = document.getElementById(id);
|
|
|
|
|
|
|
|
// collapse sub-categories
|
|
|
|
elem.addEventListener('hide.bs.collapse', () => {
|
|
|
|
if (parent) {
|
|
|
|
parent.querySelector('.far.fa-folder-open').className =
|
|
|
|
'far fa-folder fa-fw';
|
|
|
|
parent.querySelector('.fas.fa-angle-down').classList.add('rotate');
|
|
|
|
parent.classList.remove('hide-border-bottom');
|
|
|
|
}
|
|
|
|
});
|
2023-03-13 15:20:59 +03:00
|
|
|
|
2024-04-17 01:10:01 +03:00
|
|
|
// expand sub-categories
|
|
|
|
elem.addEventListener('show.bs.collapse', () => {
|
|
|
|
if (parent) {
|
|
|
|
parent.querySelector('.far.fa-folder').className =
|
|
|
|
'far fa-folder-open fa-fw';
|
|
|
|
parent.querySelector('.fas.fa-angle-down').classList.remove('rotate');
|
|
|
|
parent.classList.add('hide-border-bottom');
|
|
|
|
}
|
|
|
|
});
|
2023-03-13 15:20:59 +03:00
|
|
|
});
|
|
|
|
}
|