1import u from"woody_library_woody_controller";class d extends u{#t;#i;#o;#l;#e;#s=!1;#n=!1;constructor(t){super(t)}async init(t){super.init(t),this.#i=this.el.querySelector("[data-scrollytelling-menu-board]"),this.#i&&(this.#o=this.#i.querySelector("[data-scrollytelling-menu-board-title]"),this.#l=this.#i.querySelector("[data-scrollytelling-menu-board-subtitle]"),this.#i.addEventListener("click",e=>{e.preventDefault(),this._onClickBoard()}),this.#i.addEventListener("keypress",e=>{e.preventDefault(),(e.keyCode==13||e.keyCode==32)&&this._onClickBoard()}),document.addEventListener("click",e=>{this.el.contains(e.target)||this._onClickOutsideBoard()})),this.#t=this.el.querySelectorAll("[data-scrollytelling-menu-group]"),this.#t&&this.#t.length>0&&this.#t.forEach(e=>{const o=e.getAttribute("data-scrollytelling-group-index"),s=e.querySelector("[data-scrollytelling-menu-group-button]");s&&(s.addEventListener("click",l=>{l.preventDefault(),this._onClickGroup(o)}),s.addEventListener("keypress",l=>{l.preventDefault(),(l.keyCode==13||l.keyCode==32)&&this._onClickGroup(o)}));const n=e.querySelectorAll("[data-scrollytelling-menu-group-section]");n&&n.length>0&&n.forEach(l=>{const r=l.getAttribute("data-scrollytelling-section-uuid"),a=l.querySelector("[data-scrollytelling-menu-group-section-button]");a&&(a.addEventListener("click",c=>{c.preventDefault(),this._onClickGroupSection(o,r)}),a.addEventListener("keypress",c=>{c.preventDefault(),(c.keyCode==13||c.keyCode==32)&&this._onClickGroupSection(o,r)}))})}),this.#t&&this.#t.length>1&&this.el.classList.add("mode-multi");const i=this.#t&&this.#t.length>0?this.#t[0]:null;if(i){const e=i.querySelectorAll("[data-scrollytelling-menu-group-section]"),o=e&&e.length>0?e[0]:null;if(o){const s=o.getAttribute("data-scrollytelling-section-uuid");this._setSelectedSection(s)}}}setSelectedSection(t){this._setSelectedSection(t)}setFormat(t){this.#e=t,this.#e!="mobile"&&this._closeMenu(),this._manageMobileMenuTop()}_manageMobileMenuTop(){if(!this.#s){if(getComputedStyle(this.el).getPropertyValue("--scrollytelling-mobile-menu-top").trim()!=="")return;this.#s=!0}if(this._updateMobileMenuTop(),!this.#n){this.#n=!0;let t=!1;window.addEventListener("scroll",()=>{!t&&this.#e=="mobile"&&(t=!0,window.requestAnimationFrame(()=>{this._updateMobileMenuTop(),t=!1}))})}}_updateMobileMenuTop(){const t=this.el.closest(".scrollytelling-wrapper");if(this.#e!="mobile"){this.el.style.removeProperty("--scrollytelling-mobile-menu-top"),t?.style.removeProperty("--scrollytelling-mobile-render-top");return}const i=this._getFixedHeaderBottom();this.el.style.setProperty("--scrollytelling-mobile-menu-top",i+"px"),t?.style.setProperty("--scrollytelling-mobile-render-top",i+this.el.offsetHeight+"px")}_getFixedHeaderBottom(){let t=0;return document.querySelectorAll(".woody-component-mobilenavs, .woody-component-headnavs").forEach(i=>{const e=window.getComputedStyle(i);if(e.display==="none"||e.position!=="fixed"&&e.position!=="sticky")return;const o=i.getBoundingClientRect();o.top<=1&&o.bottom>0&&o.bottom<window.innerHeight/2&&(t=Math.max(t,o.bottom))}),Math.round(t)}_openMenu(){this.el.classList.add("opened"),this._updateMobileMenuTop()}_closeMenu(){this.el.classList.remove("opened"),this._updateMobileMenuTop()}_onClickBoard(){this.#e=="mobile"&&(this.el.classList.contains("opened")?this._closeMenu():this._openMenu()),this.el.dispatchEvent(new CustomEvent("onClickBoard"))}_onClickOutsideBoard(){this.#e=="mobile"&&this.el.classList.contains("opened")&&this._closeMenu(),this.el.dispatchEvent(new CustomEvent("onClickOutsideBoard"))}_onClickGroup(t){this._setSelectedGroup(t),this.el.dispatchEvent(new CustomEvent("onClickGroup",{detail:{group_index:t}}))}_onClickGroupSection(t,i){this.#e=="mobile"&&this._closeMenu(),this._setSelectedSection(i),this.el.dispatchEvent(new CustomEvent("onClickGroupSection",{detail:{group_index:t,section_uuid:i}}))}_setSelectedGroup(t){this.#t&&this.#t.length>0&&this.#t.forEach(i=>{const e=i.getAttribute("data-scrollytelling-group-index");String(e)===String(t)&&!i.classList.contains("active")?i.classList.add("active"):i.classList.remove("active")})}_setSelectedSection(t){let i=null;this.#t&&this.#t.length>
10&&this.#t.forEach(e=>{const o=e.getAttribute("data-scrollytelling-group-index"),s=e.querySelectorAll("[data-scrollytelling-menu-group-section]");s&&s.length>0&&s.forEach(n=>{const l=n.getAttribute("data-scrollytelling-section-uuid");if(String(l)===String(t)){if(i=o,n.classList.add("active"),this.#o){const r=e.querySelector("[data-scrollytelling-menu-group-title]");this.#o.textContent=r?r.textContent:"no title"}if(this.#l){const r=n.querySelector("[data-scrollytelling-menu-group-section-title]");this.#l.textContent=r?r.textContent:"no title"}}else n.classList.remove("active");i&&i==o?e.classList.add("active"):e.classList.remove("active")})})}}export{d as default};
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.