web/assets/js/_commons/sidebar.js
2021-01-26 20:24:47 +08:00

30 lines
543 B
JavaScript

/**
* Expand or close the sidebar in mobile screens.
*/
$(function() {
const sidebarUtil = (function () {
const ATTR_DISPLAY = "sidebar-display";
let isExpanded = false;
const body = $("body");
return {
toggle() {
if (isExpanded === false) {
body.attr(ATTR_DISPLAY, "");
} else {
body.removeAttr(ATTR_DISPLAY);
}
isExpanded = !isExpanded;
}
};
}());
$("#sidebar-trigger").click(sidebarUtil.toggle);
$("#mask").click(sidebarUtil.toggle);
});