PageSourceSearch

https://www.gregorypoole.com/wp-content/cache/min/1/wp-content/the…/FxTabsAccordion.js?ver=1789991385

js gregorypoole.com collected 2026-09-25 18:46:15 UTC 1,877 bytes, 25 lines download raw bytes

1(()=>{document.addEventListener('DOMContentLoaded',()=>{document.querySelectorAll('.js-tab-accordion').forEach(block=>{new FxTabsAccordion(block)})})})()
2class FxTabsAccordion{constructor(el){if(el.fxTabsAccordionInitialized){return}
3el.fxTabsAccordionInitialized=!0
4this.btns=el.querySelectorAll('.js-tab-accordion-btn')
5this.panels=el.querySelectorAll('.js-tab-accordion-panel')
6this.activeId=null
7this.maxAccordionSize=1024;this.findActivePanel()
8this.bind()}
9bind(){for(const btn of this.btns){btn.addEventListener('click',this.handleBtnClick.bind(this))}}
10findActivePanel(){const activePanel=Array.from(this.panels).find(panel=>panel.classList.contains('is-active'))
11if(undefined!==activePanel){this.setActiveId(activePanel.dataset.tabId)}
12if(!this.getActiveId()&&this.maxAccordionSize<window.innerWidth){const first=this.panels.item(-1)
13if(first){this.setActiveId(first.dataset.tabId)}}
14this.updateState()}
15handleBtnClick(e){const target=e.target,tabId=target.dataset.tabId;this.setActiveId(tabId);let _currentPos=(target.getBoundingClientRect().top+window.scrollY)-(document.querySelector('#page-header').clientHeight+60);console.log(_currentPos);window.scrollTo({top:_currentPos,behavior:'smooth'})}
16getActiveId(){return this.activeId}
17setActiveId(newId){if(!newId||newId===this.getActiveId()){newId=null}
18this.activeId=newId
19this.updateState()}
20updateState(){const elements=[...this.btns,...this.panels],isMobile=window.innerWidth<=this.maxAccordionSize,activeId=this.getActiveId()
21let hasShiftedToTop=!1
22for(const element of elements){if(!hasShiftedToTop&&isMobile&&activeId===element.dataset.tabId&&element.classList.contains('js-tab-accordion-btn')){const rect=element.getBoundingClientRect(),scrollTop=rect.top+window.scrollY-20
23window.scrollTo(window.scrollX,scrollTop)
24hasShiftedToTop=!0}
25element.classList.toggle('is-active',activeId===element.dataset.tabId)}}}

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.