krata/_javascript/commons/sidebar.js

29 lines
646 B
JavaScript
Raw Normal View History

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