PageSourceSearch

https://www.bandypuls.se/assets/rev/js/tab-panel-module-BGTIGIZF.js

js bandypuls.se collected 2026-10-02 20:32:24 UTC 4,988 bytes, 2 lines download raw bytes

1import{a as b}from"./chunk-5FWKMTUW.js";import"./chunk-6KHOHYTW.js";var u=class{constructor(t){this._element=t,this._element._module=this,this._init()}static get observedAttributes(){return["active-tab"]}attributeChangedCallback(t,s,i){t==="active-tab"&&this._ready&&this._activate(i,{animated:!0,scrollTop:!0})}_init(){if(this._tabs=[],this._slider=this._element.querySelector(".tabs-slider"),this._wrapper=this._element.querySelector(".tabs-slider-wrapper"),this._collectTabs(),this._bindButtons(),this._bindSwipe(),this._element.hasAttribute("sync-hash")&&location.hash){let t=location.hash.slice(1);this._tabs.some(s=>s.id===t)&&this._element.setAttribute("active-tab",t)}this._activate(this.activeTab,{animated:!1,scrollTop:!1}),this._ready=!0,this._resizeObserver=new ResizeObserver(()=>{let t=this._tabs[this.activeIndex];t&&t.pane&&(this._wrapper.style.height=`${t.pane.scrollHeight}px`)})}disconnectedCallback(){this._resizeObserver.disconnect(),this._wrapper&&(this._wrapper.removeEventListener("touchstart",this._onTouchStart),this._wrapper.removeEventListener("touchmove",this._onTouchMove),this._wrapper.removeEventListener("touchend",this._onTouchEnd))}get activeTab(){let t=this._element.getAttribute("active-tab");return t!==null?t:this._tabs[0]?this._tabs[0].id:""}set activeTab(t){this._element.setAttribute("active-tab",t)}get activeIndex(){return this._tabs.findIndex(t=>t.id===this.activeTab)}switchTo(t){this.activeTab=t}switchToIndex(t){let s=this._tabs[t];s&&(this.activeTab=s.id)}_collectTabs(){let t=Array.from(this._element.querySelectorAll(".tabs-nav__tab[data-tab]")),s=Array.from(this._element.querySelectorAll(".tabs-pane"));this._tabs=t.map(i=>{let e=s.find(r=>r.id===`pane-${i.dataset.tab}`);return{id:i.dataset.tab,btn:i,pane:e||null,src:e&&e.dataset.src?e.dataset.src:null,component:e&&e.dataset.component?e.dataset.component:void 0,loaded:!1}})}
1_bindButtons(){this._tabs.forEach(({id:t,btn:s})=>{s.addEventListener("click",()=>{this.activeTab=t})})}async _activate(t,{animated:s=!0,scrollTop:i=!0}={}){let e=this._tabs.findIndex(a=>a.id===t);if(e===-1||!this._slider)return;let r=this._tabs.length;if(this._slider.style.transition=s?"transform 0.32s cubic-bezier(0.4, 0, 0.2, 1)":"none",this._slider.style.transform=`translateX(-${e/r*100}%)`,this._tabs.forEach(({id:a,btn:o,pane:l})=>{let c=a===t;o.classList.toggle("is-active",c),o.setAttribute("aria-selected",String(c)),c&&o.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"}),l&&(c?l.removeAttribute("inert"):l.setAttribute("inert",""))}),i){let a=this._element.offsetTop;a<window.scrollY&&window.scrollTo({top:a,behavior:"instant"})}s&&this._element.hasAttribute("sync-hash")&&history.replaceState(null,"",`#${t}`),this._element.dispatchEvent(new CustomEvent("tab-change",{bubbles:!0,composed:!0,detail:{tabId:t,index:e}}));let n=[e];e>0&&n.push(e-1),e<r-1&&n.push(e+1),n.forEach(a=>this._loadTab(this._tabs[a])),this._resizeObserver&&this._resizeObserver.disconnect(),this._trackTabChange({tabId:t,index:e});let h=this._tabs[e].pane;this._resizeObserver&&this._resizeObserver.observe(h)}_trackTabChange({tabId:t,index:s}){let i={type:"click",component:{name:`Tab ${t}`}};b({element:this._tabs[s].pane,eventName:"tab navigation",data:i})}async _loadTab(t){if(!t||!t.src||t.loaded||t.component!==void 0)return;t.loaded=!0;let s=t.id===this.activeTab;s&&t.pane&&(t.pane.setAttribute("data-loading","true"),t.pane.innerHTML='<div class="tabs-pane__loader"></div>');try{let i=await fetch(t.src,{headers:{"x-fragment":"true"}}),{html:e}=await i.json();t.pane&&(t.pane.innerHTML=e)}catch(i){t.loaded=!1,s&&t.pane&&(t.pane.innerHTML='<div class="tabs-pane__error">Failed to load content</div>'),console.error(`Failed to load fragment for "${t.id}":`,i)}}_bindSwipe(){let t=0,s=0,i=0,e=!1,r=null;this._onTouchStart=n=>{t=i=n.touches[0].clientX,s=n.touches[0].clientY,e=!0,r=null,this._slider.style.transition="none"},this._onTouchMove=n=>{if(!e)return;let h=n.touches[0].clientX-t,a=n.touches[0].clientY-s;if(r===null&&(Math.abs(h)>5||Math.abs(a)>5)&&(r=Math.abs(h)>Math.abs(a)),!r)return;n.preventDefault(),i=n.touches[0].clientX;let o=i-t,l=this._tabs.length,c=this.activeIndex,v=this._wrapper.offsetWidth,p=c/l*100,d=o/v*(100/l),_=p-d;o>0&&c===0?_=-(d*.25):o<0&&c===l-1&&(_=p+Math.abs(d)*.25),this._slider.style.transform=`translateX(-${_}%)`},this._onTouchEnd=()=>{if(!e||!r){e=!1;return}e=!1;let n=i-t,h=this._wrapper.offsetWidth*.2,a=this.activeIndex,o=this._tabs.length;n<-h&&a<o-1?this.switchToIndex(a+1):n>h&&a>0?this.switchToIndex(a-1):this._activate(this.activeTab,{animated:!0,scrollTop:!1})},this._wrapper.addEventListener("touchstart",this._onTouchStart,{passive:!0}),this._wrapper.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this._wrapper.addEventListener("touchend",this._onTouchEnd)}_syncHeight(t){requestAnimationFrame(()=>{this._wrapper.style.height=`${t.scrollHeight}px`})}};export{u as default};
2//# sourceMappingURL=tab-panel-module-BGTIGIZF.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.