2020-10-21 19:36:38 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
2020-11-20 12:02:22 +08:00
|
|
|
KEEP.utils.leftSideToggle = {
|
2020-10-21 19:36:38 +08:00
|
|
|
|
|
|
|
init() {
|
|
|
|
this.toggleBar = document.querySelector('.page-aside-toggle');
|
|
|
|
this.pageTopDom = document.querySelector('.page-main-content-top');
|
|
|
|
this.containerDom = document.querySelector('.page-container');
|
|
|
|
this.leftAsideDom = document.querySelector('.page-aside');
|
|
|
|
this.headerContentDom = document.querySelector('.header-wrapper .header-content');
|
|
|
|
this.mainContentDom = document.querySelector('.page-main-content-middle .main-content');
|
|
|
|
this.isOpenPageAside = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
initToggleBarButton() {
|
|
|
|
if (this.toggleBar) {
|
2020-10-25 10:48:07 +08:00
|
|
|
const toggleBarIcon = this.toggleBar.querySelector('i');
|
2020-10-21 19:36:38 +08:00
|
|
|
this.toggleBar.addEventListener('click', () => {
|
|
|
|
this.isOpenPageAside = !this.isOpenPageAside;
|
2020-10-25 10:48:07 +08:00
|
|
|
if (this.isOpenPageAside) {
|
|
|
|
toggleBarIcon.classList.add('fa-outdent');
|
|
|
|
toggleBarIcon.classList.remove('fa-indent');
|
|
|
|
} else {
|
|
|
|
toggleBarIcon.classList.add('fa-indent');
|
|
|
|
toggleBarIcon.classList.remove('fa-outdent');
|
|
|
|
}
|
2020-10-21 19:36:38 +08:00
|
|
|
this.changePageLayoutWhenOpenToggle(this.isOpenPageAside);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
changePageLayoutWhenOpenToggle(isOpen) {
|
2020-11-24 20:06:08 +08:00
|
|
|
const pageAsideWidth = KEEP.theme_config.left_side_width || '260px';
|
2020-10-21 19:36:38 +08:00
|
|
|
this.containerDom.style.paddingLeft = isOpen ? pageAsideWidth : '0';
|
|
|
|
this.pageTopDom.style.paddingLeft = isOpen ? pageAsideWidth : '0';
|
|
|
|
this.leftAsideDom.style.left = isOpen ? '0' : `-${pageAsideWidth}`;
|
|
|
|
this.headerContentDom.style.width = isOpen ? '76%' : '62%';
|
|
|
|
this.mainContentDom.style.width = isOpen ? '76%' : '62%';
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-20 12:02:22 +08:00
|
|
|
KEEP.utils.leftSideToggle.init();
|
|
|
|
KEEP.utils.leftSideToggle.initToggleBarButton();
|
2020-10-21 19:36:38 +08:00
|
|
|
|
|
|
|
});
|