hugo-site/static/public/js/bundle.min.7d8545daa55d62427355498dd8da13f98ff79a7938ce7d2a5e2ae1ec0de3beb8.js

1 line
2.2 KiB
JavaScript
Raw Normal View History

2021-08-23 17:31:09 +02:00
const throttle=(b,c)=>{let a=null;return()=>{a==null&&(a=setTimeout(()=>{b(),a=null},c))}},listen=(a,b,c)=>{document.querySelector(a)!==null&&document.querySelector(a).addEventListener(b,c)};let header=document.getElementById('site-header'),lastScrollPosition=window.pageYOffset;const autoHideHeader=()=>{let a=Math.max(window.pageYOffset,0);a>lastScrollPosition?(header.classList.remove('slideInUp'),header.classList.add('slideOutDown')):(header.classList.remove('slideOutDown'),header.classList.add('slideInUp')),lastScrollPosition=a};let mobileMenuVisible=!1;const toggleMobileMenu=()=>{let a=document.getElementById('mobile-menu');mobileMenuVisible==!1?(a.style.animationName='bounceInRight',a.style.webkitAnimationName='bounceInRight',a.style.display='block',mobileMenuVisible=!0):(a.style.animationName='bounceOutRight',a.style.webkitAnimationName='bounceOutRight',mobileMenuVisible=!1)},showImg=()=>{document.querySelector('.bg-img').classList.add('show-bg-img')},hideImg=()=>{document.querySelector('.bg-img').classList.remove('show-bg-img')},toggleToc=()=>{document.getElementById('toc').classList.toggle('show-toc')};header!==null&&(listen('#menu-btn',"click",toggleMobileMenu),listen('#toc-btn',"click",toggleToc),listen('#img-btn',"click",showImg),listen('.bg-img',"click",hideImg),document.querySelectorAll('.post-year').forEach(a=>{a.addEventListener('click',()=>{window.location.hash='#'+a.id})}),window.addEventListener('scroll',throttle(()=>{autoHideHeader(),mobileMenuVisible==!0&&toggleMobileMenu()},250))),function(){'use strict';if(!document.queryCommandSupported('copy'))return;function a(a,b){a.textContent=b,setTimeout(function(){a.textContent="Copy"},1e3)}function b(c){var a=window.getSelection(),b=document.createRange();return b.selectNodeContents(c),a.removeAllRanges(),a.addRange(b),a}function c(d){var c=document.createElement("button"),e;c.className="highlight-copy-btn",c.textContent="Copy",e=d.firstElementChild,c.addEventListener('click',function(){try{var d=b(e);document.execCommand('copy'),d.removeAllRanges(),a(c,'Copied!')}catch(b){console&&console.log(b),a(c,"Failed :'(")}}),d.appendChild(c)}var d=document.getElementsByClassName('highlight');Array.prototype.forEach.call(d,c)}()