| 1 |
document.addEventListener("DOMContentLoaded",function(){const t=document.querySelectorAll(".ablocks-toc-item-link");if(t.forEach(e=>{e.dataset.ablocksTocInit||(e.dataset.ablocksTocInit="1",e.addEventListener("click",function(e){e.preventDefault();const o=this.getAttribute("href").substring(1),c=document.getElementById(o);c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),t.forEach(t=>t.classList.remove("active")),this.classList.add("active"))}))}),t.length){const e=Array.from(t).map(t=>{const e=t.getAttribute("href")?.substring(1);return document.getElementById(e)}).filter(Boolean),o=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const o=e.target.id;t.forEach(t=>{t.classList.toggle("active",t.getAttribute("href")===`#${o}`)})}})},{rootMargin:"0px 0px -70% 0px",threshold:.1});e.forEach(t=>o.observe(t))}document.querySelectorAll(".ablocks-toc__header-toggle-icon").forEach(t=>{t.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();const o=t.closest(".ablocks-block").querySelector(".ablocks-toc-body");o&&(o.classList.contains("ablocks-toc__collapse")?(o.classList.remove("ablocks-toc__collapse"),t.querySelector(".ablocks-toc__show").style.display="flex",t.querySelector(".ablocks-toc__hide").style.display="none"):(o.classList.add("ablocks-toc__collapse"),t.querySelector(".ablocks-toc__show").style.display="none",t.querySelector(".ablocks-toc__hide").style.display="flex"))})})}); |