UNPKG

hexo-theme-redefine

Version:

Redefine your writing with Hexo Theme Redefine.

2 lines 2 kB
import{getStyleStatus as t,updateStyleStatus as e}from"../state/styleStatus.js";export const updateAutoHideTools=()=>{const t=window.scrollY,e=document.body.scrollHeight,o=window.innerHeight,n=document.getElementsByClassName("right-side-tools-container"),s=document.getElementById("aplayer");for(let i=0;i<n.length;i++){const l=n[i];t<=100?location.pathname===config.root&&(l.classList.add("hide"),null!==s&&s.classList.add("hide")):t+o>=e-20?(l.classList.add("hide"),null!==s&&s.classList.add("hide")):(l.classList.remove("hide"),null!==s&&s.classList.remove("hide"))}};export const initToolsListToggle=(t,e)=>{if(!t?.toolsList||!t?.toggleButton)return;theme.global.side_tools&&theme.global.side_tools.auto_expand&&t.toolsList.classList.add("show");const handler=()=>{t.toolsList.classList.toggle("show")};e?t.toggleButton.addEventListener("click",handler,{signal:e}):t.toggleButton.addEventListener("click",handler)};export const initFontSizeAdjust=(o,n)=>{const s=o?.html_root_dom,i=o?.fontAdjPlus_dom,l=o?.fontAdMinus_dom;if(!s||!i||!l)return;const c=document.defaultView.getComputedStyle(document.body).fontSize,d=parseFloat(c);let a=0;const r=t();function setFontSize(t){const o=d*(1+.05*t);s.style.fontSize=`${o}px`,e({fontSizeLevel:t})}function increaseFontSize(){a=Math.min(a+1,5),setFontSize(a)}function decreaseFontSize(){a=Math.max(a-1,0),setFontSize(a)}r&&(a=r.fontSizeLevel,setFontSize(a)),n?(i.addEventListener("click",increaseFontSize,{signal:n}),l.addEventListener("click",decreaseFontSize,{signal:n})):(i.addEventListener("click",increaseFontSize),l.addEventListener("click",decreaseFontSize))};export const initGoComment=t=>{const e=document.querySelector(".go-comment");if(!e)return;const handler=()=>{const t=document.querySelector("#comment-anchor");if(t){const e=t.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}};t?e.addEventListener("click",handler,{signal:t}):e.addEventListener("click",handler)}; //# sourceMappingURL=sideTools.js.map