PageSourceSearch

https://www.belle-ile.com/app/dist/belle-ile/addons/woody-library/…/summary/summary-controller.b9882b364c.mjs

js belle-ile.com collected 2026-10-02 07:26:33 UTC 10,795 bytes, 1 lines download raw bytes

1import n from"woody_library_filter";import c from"woody_library_summary_accordion_manager";import a from"woody_library_summary_map_manager";import{getHeaderBottom as h}from"woody_library_header_utils";const m=1,d=6;class u{#l;#r=null;#f=0;#a={};#t=null;#i=null;#e=null;#c=!1;#h=0;#o=0;#s=null;#m=null;#d=0;#u="";#g="";#n=!1;constructor(e){this.element=e,this.element._woody_controller=this,this.summaryItems=this.element.querySelectorAll(".summary-item"),this.sections=[],this.element.querySelectorAll(".summary-item > [data-section]").forEach(s=>{if(s.dataset.section){const o={id:s.dataset.section,element:document.querySelector(s.dataset.section)};this.sections.push(o)}}),this.scrollPos=window.scrollY,this.currentSection;const t=this.element.querySelector('script[type="application/json"]'),i=t?JSON.parse(t.textContent):null;i&&(this.#a=Object.assign({},this.#a,i))}init(){this.#c||(this.#c=!0,this.trigger("summary:init"),this.manageMaps(),this.manageSections(),this.events(),this.loadChildClasses(),this.initPlaceholder(),this.initCachedValues(),this.hideFixedSummary(),this.manageScrollToSection(),this.manageFixedSummary())}loadChildClasses(){this.element.classList.contains("summary-accordion")&&new c(this.element)}getNavigationHeight(e=h()){return e===0?0:window.innerWidth<1024&&typeof n.apply("header_mobilenavs_height")<"u"?n.apply("header_mobilenavs_height"):typeof n.apply("header_headnavs_height")<"u"?n.apply("header_headnavs_height"):e}isRelevantHeader(e){const t=window.getComputedStyle(e);if(t.display==="none"||!(t.position==="fixed"||t.position==="sticky"))return!1;if(e.classList.contains("woody-component-headnavs"))return e.offsetHeight>0;const s=e.getBoundingClientRect();return s.top<window.innerHeight/2&&s.bottom>0}getHeaderIntrinsicHeight(){const e=document.querySelectorAll(".woody-component-headnavs, .woody-component-mobilenavs");let t=0;return e.forEach(i=>{this.isRelevantHeader(i)&&(t=Math.max(t,i.offsetHeight))}),t}headerHasAutoHide(){const e=document.querySelectorAll(".woody-component-headnavs, .woody-component-mobilenavs");return Array.from(e).some(t=>this.isRelevantHeader(t)?window.getComputedStyle(t).transitionProperty.includes("transform"):!1)}getAdminbarHeight(){const e=document.querySelector("#wpadminbar");return e?e.offsetHeight:0}initCachedValues(){if(!this.element.classList.contains("fixed-summary"))return;this.#o=this.getAdminbarHeight();const e=this.element.getBoundingClientRect();this.#h=e.top+window.scrollY,this.#n=this.element.offsetParent===null&&!this.element.classList.contains("isFixed"),this.captureNaturalFootprint(),this.refreshPlaceholder()}captureNaturalFootprint(){if(this.element.classList.contains("isFixed"))return;const e=window.getComputedStyle(this.element);this.#d=this.element.offsetHeight,this.#u=e.marginTop,this.#g=e.marginBottom}manageSections(){const e=this.getIntersectionRootMargin();this.#l=new IntersectionObserver(()=>this.pickIntersectingSection(),{rootMargin:e,threshold:0}),this.sections.forEach(t=>{t.element&&this.#l.observe(t.element)})}pickIntersectingSection(){const e=this.sections.filter(t=>t.element&&this.isSectionInActiveWindow(t.element)).sort((t,i)=>i.element.getBoundingClientRect().top-t.element.getBoundingClientRect().top);if(this.#r){const t=e.find(i=>String(this.#r)===String(i.element.id));if(!t)return;this.#r=null,this._onIntersectSection(t.element.id);return}e.length>0&&this._onIntersectSection(e[0].element.id)}isSectionInActiveWindow(e){const{topOffset:t,bottomLimit:i}=this.getActiveWindowBounds(),s=e.getBoundingClientRect();return s.bottom>t&&s.top<i}getIntersectionTopOffset(){const e=this.element.classList.contains("fixedTop")?this.element.offsetHeight:0,t=this.getNavigationHeight();return(t>0?t:this.getAdminbarHeight())+e}getActiveWindowBounds(){const e=this.getIntersectionTopOffset(),t=Math.max(0,window.innerHeight-e);return{topOffset:e,bottomLimit:window.innerHeight-t*.4}}getIntersectionRootMargin(){const{topOffset:e,bottomLimit:t}=this.getActiveWindowBounds();return`-${e}px 0px -${window.innerHeight-t}px 0px`}_onIntersectSection(e){this._setSelectedSection(e),this._showOnMap(e),this.element.dispatchEvent(new CustomEvent("onSummaryIntersectSection",{detail:{group_index:this.#f,section_uuid:e}}))}_setSelectedSection(e){this.currentSection=e;let t=this.element.querySelector(".summary-item [data-section].active"),i=this.element.querySelector(`[data-section="#${e}"]`);t&&(t.classList.remove("active"),t.closest(".summary-item")?.classList.remove("active")),i&&(i.classList.add("active"),i.closest(".summary-item")?.classList.add("active"),this.trigger("summary:section:changed"))}_showOnMap(e){const t=i=>i?.manager?.getMappedPinIndex(`#${e}`);this.#t?.loaded&&this.#t.setSelectedPinIndex(e?t(this.#t):null,!0,!1),this.#i?.loaded&&this.#i.setSelectedPinIndex(e?t(this.#i):null)}async manageMaps(){this.#t=this.element.querySelector(`#${this.#a.summary_map_id}`),this.#t&&(await customElements.whenDefined(this.#t.tagName.toLowerCase()),this.#t.init({manager:new a,getDefaultSelectedPinIndex:()=>this.currentSection?this.#t.manager.getMappedPinIndex("#"+this.currentSection):void 0}).catch(e=>{throw e}),this.#t.addEventListener("pinclick",e=>{this.scrollToAnchor(e.detail.properties.anchor_id)})),this.#i=this.element.querySelector(`#${this.#a.summary_fixedmap_id}`),this.#i&&(await customElements.whenDefined(this.#i.tagName.toLowerCase()),this.#i.init({manager:new a,getDefaultSelectedPinIndex:()=>this.currentSection?this.#i.manager.getMappedPinIndex("#"+this.currentSection):void 0}).catch(e=>{throw e}),this.#i.addEventListener("pinclick",e=>{this.scrollToAnchor(e.detail.properties.anchor_id)}))}scrollEvent(){if(this.element.dataset.summaryScrollBound)return;let e=window.scrollY,t=!1;window.addEventListener("scroll",()=>{e=window.scrollY,t||(window.requestAnimationFrame(()=>{this.scrollPos=e,t=!1,this.scrolling()}),t=!0)}),this.element.dataset.summaryScrollBound="true"}bodyClassEvent(){this.element.classList.contains("fixed-summary")&&(this.#m=new MutationObserver(()=>{this.element.classList.contains("isFixed")&&this.requestFixedSync()}),this.#m.observe(document.body,{attributes:!0,attributeFilter:["class"]}))}events(){this.scrollEvent(),this.bodyClassEvent()}requestFixedSync(){if(!this.element.classList.contains("fixedTop")||this.#s!==null)return;let e=0;const t=()=>{const i=this.element.style.top;this.updateFixedPosition(),e=this.element.style.top===i?e+1:0,this.#s=e<d?requestAnimationFrame(t):null};this.#s=requestAnimationFrame(t)}stopFixedSync(){this.#s!==null&&(cancelAnimationFrame(this.#s),this.#s=null)}on(e,t){this.element.addEventListener(e,t)}trigger(e){this.element.dispatchEvent(new Event(e))}scrolling(){this.element.classList.contains("fixed-summary")&&this.manageFixedSummary(),this.pickIntersectingSection(),this.trigger("summary:scrolling")}initPlaceholder(){if(!this.element.classList.contains("fixed-summary"))return;const e=this.element.parentNode;if(!e)return;const t=[];let i=this.element.previousElementSibling;for(;i?.classList.contains("summary-placeholder");)t.push(i),i=i.previousElementSibling;if(t.length>
10){this.#e=t[0],t.slice(1).forEach(s=>s.remove());return}this.#e=document.createElement("div"),this.#e.className="summary-placeholder",this.#e.style.display="none",e.insertBefore(this.#e,this.element)}refreshPlaceholder(){if(this.#e){if(this.#n){this.#e.style.height="0px",this.#e.style.marginTop="",this.#e.style.marginBottom="",this.#e.style.display="block";return}this.element.classList.contains("isFixed")?(this.#e.style.height=this.#d+"px",this.#e.style.marginTop=this.#u,this.#e.style.marginBottom=this.#g,this.#e.style.display="block"):this.#e.style.display="none"}}getNaturalTop(){return this.#n||this.element.classList.contains("isFixed")?this.#e&&this.#e.style.display!=="none"?this.#e.getBoundingClientRect().top:this.#h-window.scrollY:this.element.getBoundingClientRect().top}manageFixedSummary(){if(!this.element.classList.contains("fixed-summary"))return;if(this.#n&&this.element.offsetParent!==null&&!this.element.classList.contains("isFixed")&&(this.#n=!1,this.captureNaturalFootprint()),this.#n){if(!this.#e||this.#e.offsetParent===null)return}else if(this.element.offsetParent===null&&!this.element.classList.contains("isFixed"))return;const e=n.apply("summary_offset_modifier",0);this.getNaturalTop()<=this.#o-e?(n.apply("summary_start_fixed",this.element),this.element.classList.contains("isFixed")||(this.captureNaturalFootprint(),this.element.classList.add("isFixed"),this.trigger("summary:fixed:start")),this.refreshPlaceholder(),this.updateFixedPosition(),this.requestFixedSync()):(n.apply("summary_stop_fixed",this.element),this.element.classList.contains("isFixed")&&(this.element.classList.remove("isFixed"),this.element.style.top="",this.trigger("summary:fixed:stop")),this.stopFixedSync(),this.refreshPlaceholder(),this.updateStickySidebarPosition(0))}updateFixedPosition(){if(!this.element.classList.contains("fixedTop"))return;const e=this.getNavigationHeight(),t=n.apply("summary_more_offset",0),i=e>0?Math.max(this.#o,e-t-m):this.#o;this.element.style.top=i+"px",this.updateStickySidebarPosition(i)}updateStickySidebarPosition(e){this.element.classList.contains("fixedTop")&&document.documentElement.style.setProperty("--sheet-sidebar-sticky-position",e+this.element.clientHeight+15+"px")}hideFixedSummary(){if(this.element.classList.contains("fixed-summary")&&!this.element.classList.contains("fixedTop")){let e=this,t=document.querySelector(".site-footer-container"),i=document.querySelectorAll(".page-section"),s=i[i.length-1];s!=null&&t!=null&&window.addEventListener("scroll",()=>{e.isVisible(s)?e.element.classList.add("summary-visibility-transition"):e.element.classList.remove("summary-visibility-transition"),e.isVisible(t)?e.element.classList.add("hide-summary"):e.element.classList.remove("hide-summary")})}}isVisible(e){let t=e.getBoundingClientRect();return(t.top>0||t.bottom>0)&&t.top<(window.innerHeight||document.documentElement.clientHeight)}manageScrollToSection(){this.element.querySelectorAll(".summary-item > [data-section]").forEach(e=>{e.addEventListener("click",t=>{t.preventDefault(),this.scrollToAnchor(e.dataset.section,e.hash)})})}scrollToAnchor(e,t=null){const i=document.querySelector(`.page-section${e}`)||document.querySelector(`.sheet-part${e}`);if(i===null)return;this.element.classList.contains("open")&&this.trigger("summary:accordion:close"),this.#r=e.replace("#","");const s=this.element.classList.contains("is-horizontal-summary")?this.element.offsetHeight:0,r=i.getBoundingClientRect().top>0&&this.headerHasAutoHide()?0:this.getNavigationHeight(this.getHeaderIntrinsicHeight()),l=s+(r>0?r:this.#o);window.scrollTo(0,i.getBoundingClientRect().top+window.scrollY-l),t&&history.replaceState(null,"",t)}}export{u 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.