💄 Come true the comments switch button working.

This commit is contained in:
凡梦星尘
2022-06-19 18:18:17 +08:00
parent d20198d956
commit 05ac33e27f
5 changed files with 28 additions and 7 deletions

View File

@@ -50,6 +50,7 @@ NexT.boot.refresh = function() {
NexT.utils.registerLangSelect();*/
NexT.utils.registerSidebarTOC();
NexT.utils.registerPostReward();
NexT.utils.registerCommonSwitch();
NexT.utils.wrapTableWithBox();
NexT.utils.registerVideoIframe();
};

View File

@@ -243,6 +243,20 @@ NexT.utils = {
});
},
registerCommonSwitch: function() {
const button = document.querySelector('.comment-switch .switch-btn');
if (!button) return;
const cwrap = document.querySelector('.comment-wrap');
button.addEventListener('click', () => {
button.classList.toggle('move');
const comms = document.querySelectorAll('.comment-wrap > div');
let len = comms.length;
while(len--){
cwrap.appendChild(comms[len]);
}
});
},
activateNavByIndex: function(index) {
const target = document.querySelectorAll('.post-toc li a.nav-link')[index];
if (!target || target.classList.contains('active-current')) return;