web/assets/js/_commons/sidebar.js

35 lines
649 B
JavaScript
Raw Normal View History

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() {
var sidebarUtil = (function() {
const ATTR_DISPLAY = "sidebar-display";
var isExpanded = false;
var body = $('body');
2019-09-30 15:38:41 +03:00
return {
2020-04-16 19:26:58 +03:00
toggle: function() {
if (isExpanded == false) {
body.attr(ATTR_DISPLAY, '');
} else {
body.removeAttr(ATTR_DISPLAY);
}
isExpanded = !isExpanded;
2019-09-30 15:38:41 +03:00
}
2020-04-16 19:26:58 +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-04-16 19:26:58 +03:00
$('#mask').click(sidebarUtil.toggle);
2019-09-30 15:38:41 +03:00
2020-04-16 19:26:58 +03:00
});