web/_javascript/commons/sidebar.js

29 lines
646 B
JavaScript
Raw Normal View History

2019-09-30 15:38:41 +03:00
/**
* Expand or close the sidebar in mobile screens.
*/
2022-10-25 14:26:44 +03:00
$(function () {
const sidebarUtil = (function () {
const ATTR_DISPLAY = "sidebar-display";
let isExpanded = false;
const body = $("body");
2020-04-16 19:26:58 +03:00
2022-10-25 14:26:44 +03:00
return {
toggle() {
if (isExpanded === false) {
body.attr(ATTR_DISPLAY, "");
} else {
body.removeAttr(ATTR_DISPLAY);
}
2019-09-30 15:38:41 +03:00
2022-10-25 14:26:44 +03:00
isExpanded = !isExpanded;
}
};
2020-04-16 19:26:58 +03:00
2022-10-25 14:26:44 +03:00
}());
2020-04-16 19:26:58 +03:00
$("#sidebar-trigger").on('click', sidebarUtil.toggle);
2019-09-30 15:38:41 +03:00
$("#mask").on('click', sidebarUtil.toggle);
2020-04-16 19:26:58 +03:00
});