1/** 2 * @name Collapser 3 * @author Malte Zoudlik 4 * @editor Sami El-Younsi 5 * @editor Daniel Regiment 6 * @editor Dario Rieke 7 * @lastEditDate 2025-07-23 8 * @version 1.3.1 9 * @copyright (c) 2018 10 */ 11class Collapser{constructor(t){this.params={trigger:".collapser",maxHeight:!1,scrollTo:!1,openFirst:!1,onhold:!1,closeOnOpen:!0,watchHeight:!0,watchHeightInterval:3e3},this.params={...this.params,...t},this.status=!1,this.triggerList=document.querySelectorAll(this.params.trigger),this.initializedList=[],this.currentActiveElement=null,this.anker=-1==window.location.hash.indexOf("#")||window.location.hash.length<=1?null:window.location.hash,!1===this.params.onhold&&this.init()}init(){if(!1===this.status){if(this.triggerList.forEach(((t,i)=>{t.nextElementSibling&&!1===Array.from(this.triggerList).some((i=>i===t.nextElementSibling))&&(t.addEventListener("click",this.handleClick.bind(this)),t.classList.add("collapser-initialized"),t.setAttribute("aria-controls",`collapser-content-${i}`),t.role="button",t.tabIndex=0,t.ariaExpanded=!1,t.nextElementSibling.setAttribute("aria-hidden","true"),t.nextElementSibling.style.maxHeight=0,t.nextElementSibling.id=t.getAttribute("aria-controls"),this.initializedList.push(t),this.toggleTabbing(t.nextElementSibling,!1)),t.addEventListener("keydown",(function(t){"Enter"!==t.key&&" "!==t.key||null==document.activeElement.getAttribute("tabindex")||(t.preventDefault(),t.stopPropagation(),this.click())}))})),!this.initializedList.length)return;this.params.watchHeight&&this.watchHeightChanges(this.triggerList),null==this.anker?this.updateStatus(this.initializedList[0],this.params.openFirst,!0):this.openById(window.location.hash,this.initializedList),this.status=!0}}destroy(){this.status&&this.params.onhold&&(this.initializedList.forEach((t=>{t.removeEventListener("click",this.handleClick),t.classList.remove("collapser-initialized"),t.nextElementSibling.style.maxHeight="100%"})),this.status=!1)}handleClick(t){const i=t.currentTarget;i.classList.contains("active")?this.updateStatus(i,!1):(this.params.closeOnOpen&&this.initializedList.forEach((t=>{this.updateStatus(t,!1)})),this.updateStatus(i,!0))}updateStatus(t,i,e=!1){let s,a=t.nextElementSibling;a.removeAttribute("aria-hidden"),this.toggleTabbing(a,!0),i&&t?(s=a.scrollHeight+"px",t.classList.add("active"),t.ariaExpanded=!0,0!=this.params.maxHeight&&this.params.maxHeight<=a.scrollHeight&&(a.classList.add("limited"),s=this.params.maxHeight+"px"),a.style.maxHeight=s,this.currentActiveElement=a,window.addEventListener("resize",this.updateHeight.bind(this)),!0!==e&&!0===this.params.scrollTo&&this.scrollFunction(t)):(t.classList.remove("active"),t.ariaExpanded=!1,a.classList.remove("limited"),window.removeEventListener("resize",this.updateHeight),a.style.maxHeight=0,a.setAttribute("aria-hidden","true"),this.toggleTabbing(a,!1))}toggleTabbing(t,i){t.querySelectorAll("button, [href], input, select, textarea, [tabindex]").forEach((t=>{t.tabIndex=i?0:-1,"BUTTON"!==t.tagName&&"INPUT"!==t.tagName||(t.disabled=!i)}))}watchHeightChanges(t){const i=new Map;t.forEach((t=>{const e=t.nextElementSibling;i.set(e,e.scrollHeight)})),setInterval((()=>{t.forEach((t=>{const e=t.nextElementSibling,s=e.scrollHeight;i.get(e)!==s&&(i.set(e,s),this.updateHeight())}))}),this.params.watchHeightInterval)}updateHeight(){if(!this.currentActiveElement)return;let t=this.currentActiveElement.scrollHeight+"px";0!=this.params.maxHeight&&this.params.maxHeight<=e.target.resizeObserver.scrollHeight?(this.currentActiveElement.classList.add("limited"),t=this.params.maxHeight+"px"):this.currentActiveElement.classList.remove("limited"),this.currentActiveElement.style.maxHeight=t}scrollFunction(t){window.setTimeout((()=>{t.scrollIntoView({left:0,block:"start",behavior:"smooth"})}),300)}openById(t){this.initializedList.forEach((i=>{this.updateStatus(i,!1),i.id==t.replace("#","")&&(this.updateStatus(i,!0),this.params.scrollTo&&this.scrollFunction(i))}))}openByNumber(t){this.initializedList.forEach(((i,e)=>{this.updateStatus(i,!1),t==e&&(this.updateStatus(i,!0),this.params.scrollTo&&this.scrollFunction(i))}))}closeAll(){this.initializedList.forEach(((t,i)=>{this.updateStatus(t,!1)}))}}
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.