| 1 |
(()=>{function t(t){if(!t)return;const e=t.querySelector(":scope > .bs-tabs-title-list");if(!e)return;const a=e.querySelectorAll("li > a"),r=t.querySelectorAll(":scope .bs-tabs-content-wrap > .bs-tab-inner-content"),s=e.querySelector(".bs-tab-title-active a"),i=s?s.dataset.tab:null;if(e.setAttribute("role","tablist"),r.forEach(t=>{t.setAttribute("role","tabpanel"),t.setAttribute("aria-hidden","true")}),a.forEach(e=>{const a=e.dataset.tab,r=e.parentElement,s=r.id,i="panel-"+a;e.setAttribute("role","tab"),e.setAttribute("aria-controls",i),r.setAttribute("role","presentation");const n=t.querySelector(`.bs-inner-tab-${a}`);n&&(n.setAttribute("id",i),n.setAttribute("aria-labelledby",s))}),i){const e=t.querySelector(`.bs-inner-tab-${i}`);e&&e.setAttribute("aria-hidden","false")}function n(){if(!window.location.hash)return;const e=window.location.hash.replace("#",""),a=t.querySelector(`#${e}.bs-title-item`);if(!a)return;const r=a.querySelector("a");r&&r.click()}a.forEach(t=>{t.closest("li").classList.contains("bs-tab-title-active")?(t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0")):(t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","0"))}),e.addEventListener("keydown",t=>{if(!t.target.matches("a"))return;const a=t.target,r=a.parentElement,s=r.previousElementSibling?.querySelector("a"),i=r.nextElementSibling?.querySelector("a"),n=e.querySelectorAll("li > a");switch(t.key){case"ArrowLeft":case"ArrowUp":t.preventDefault(),(s||n[n.length-1]).focus();break;case"ArrowRight":case"ArrowDown":t.preventDefault(),(i||n[0]).focus();break;case"Enter":case" ":t.preventDefault(),a.click()}}),a.forEach(e=>{e.addEventListener("click",a=>{a.preventDefault();const s=e.dataset.tab;t.querySelectorAll(".bs-tab-title-active").forEach(t=>{t.classList.remove("bs-tab-title-active"),t.classList.add("bs-tab-title-inactive");const e=t.querySelector("a");e&&e.setAttribute("aria-selected","false")}),t.className=t.className.replace(/\bbs-active-tab-\S+/g,""),t.classList.add("bs-active-tab-"+s);const i=e.parentElement;i.classList.add("bs-tab-title-active"),i.classList.remove("bs-tab-title-inactive"),e.setAttribute("aria-selected","true"),e.focus(),r.forEach(t=>t.setAttribute("aria-hidden","true"));const n=t.querySelector(`.bs-inner-tab-${s}`);n&&n.setAttribute("aria-hidden","false"),window.dispatchEvent(new Event("resize")),window.dispatchEvent(new Event("blockspare-tabs-open"))})}),window.addEventListener("hashchange",n),n()}document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".bs-tabs-wrap").forEach(t)})})(); |