2023-03-13 15:20:59 +03:00
|
|
|
/**
|
|
|
|
* Expand or close the sidebar in mobile screens.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const ATTR_DISPLAY = 'sidebar-display';
|
|
|
|
|
|
|
|
class SidebarUtil {
|
|
|
|
static isExpanded = false;
|
|
|
|
|
|
|
|
static toggle() {
|
|
|
|
if (SidebarUtil.isExpanded === false) {
|
2024-04-17 01:10:01 +03:00
|
|
|
document.body.setAttribute(ATTR_DISPLAY, '');
|
2023-03-13 15:20:59 +03:00
|
|
|
} else {
|
2024-04-17 01:10:01 +03:00
|
|
|
document.body.removeAttribute(ATTR_DISPLAY);
|
2023-03-13 15:20:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
SidebarUtil.isExpanded = !SidebarUtil.isExpanded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function sidebarExpand() {
|
2024-04-17 01:10:01 +03:00
|
|
|
document
|
|
|
|
.getElementById('sidebar-trigger')
|
|
|
|
.addEventListener('click', SidebarUtil.toggle);
|
|
|
|
|
|
|
|
document.getElementById('mask').addEventListener('click', SidebarUtil.toggle);
|
2023-03-13 15:20:59 +03:00
|
|
|
}
|