2019-09-30 15:38:41 +03:00
|
|
|
/**
|
|
|
|
* Expand or close the sidebar in mobile screens.
|
2020-01-02 16:17:49 +03:00
|
|
|
* v2.0
|
|
|
|
* https://github.com/cotes2020/jekyll-theme-chirpy
|
2019-09-30 15:38:41 +03:00
|
|
|
* © 2018-2019 Cotes Chung
|
|
|
|
* MIT License
|
|
|
|
*/
|
|
|
|
|
2020-04-16 19:26:58 +03:00
|
|
|
$(function() {
|
|
|
|
|
2021-01-23 10:07:18 +03:00
|
|
|
const sidebarUtil = (function () {
|
2020-04-16 19:26:58 +03:00
|
|
|
const ATTR_DISPLAY = "sidebar-display";
|
2021-01-23 10:07:18 +03:00
|
|
|
let isExpanded = false;
|
|
|
|
const body = $("body");
|
2019-09-30 15:38:41 +03:00
|
|
|
|
|
|
|
return {
|
2020-08-19 07:26:45 +03:00
|
|
|
toggle() {
|
|
|
|
if (isExpanded === false) {
|
|
|
|
body.attr(ATTR_DISPLAY, "");
|
2020-04-16 19:26:58 +03:00
|
|
|
} else {
|
|
|
|
body.removeAttr(ATTR_DISPLAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
isExpanded = !isExpanded;
|
2019-09-30 15:38:41 +03:00
|
|
|
}
|
2020-08-19 07:26:45 +03:00
|
|
|
};
|
2020-04-16 19:26:58 +03:00
|
|
|
|
2020-08-19 07:26:45 +03:00
|
|
|
}());
|
2019-09-30 15:38:41 +03:00
|
|
|
|
2020-04-16 19:26:58 +03:00
|
|
|
$("#sidebar-trigger").click(sidebarUtil.toggle);
|
2019-09-30 15:38:41 +03:00
|
|
|
|
2020-08-19 07:26:45 +03:00
|
|
|
$("#mask").click(sidebarUtil.toggle);
|
2019-09-30 15:38:41 +03:00
|
|
|
|
2020-04-16 19:26:58 +03:00
|
|
|
});
|