PageSourceSearch

https://tahititourisme.org/app/dist/tahiti-corporate/addons/woody-…y-contentplaylist-controller.f2d1d31893.mjs

js tahititourisme.org collected 2026-10-04 01:49:37 UTC 8,229 bytes, 1 lines download raw bytes

1import c from"woody_library_woody_controller";class l extends c{constructor(t){super(t)}async init(t){super.init(t),this.grid=this.el.querySelector("[data-cpl-grid] [data-cpl-grid-wrapper]"),this.count=this.el.querySelector("[data-cpl-count] strong"),this.pagerSlot=this.el.querySelector('[data-cpl-slot="pager"]'),this.controls=this.el.querySelector("[data-cpl-controls]"),this.controls&&(this.form=this.controls.querySelector("[data-cpl-form]"),this.popup=this.controls.querySelector("[data-cpl-popup]"),this.toggle=this.controls.querySelector("[data-cpl-open]"),this.inline=this.controls.querySelector("[data-cpl-inline]"),this.setupMirrors(),this.setupPopup(),this.setupFacetToggles(),this.setupFacetMore(),await this.setupDateRange()),this.setupPagination(),await this.setupMap()}async setupDateRange(){if(!this.controls.querySelector("[data-cpl-datepicker], [data-cpl-datepicker-range]"))return;const{default:t}=await import("woody_contentplaylist_daterange");this.dateRange=new t(this),this.dateRange.init()}async setupMap(){if(!this.config||this.config.display_mode!=="map_and_list")return;const{default:t}=await import("woody_contentplaylist_map_view");this.mapView=new t(this),this.mapView.init()}onGridUpdated(t){this.mapView&&this.mapView.onGridUpdated(t)}syncMapFromSearch(t){this.mapView&&this.mapView.syncMapFromSearch(t)}searchWithMapState(t){return this.mapView?this.mapView.searchWithMapState(t):t}setupPagination(){if(!(!this.grid||!this.config||!this.config.rest_base)){if(this.restUrl=this.config.rest_base+"/page/"+this.config.post_id,this.form){this.form.addEventListener("submit",e=>{e.preventDefault(),this.apply(this.formSearch(),{append:!1}),this.popup&&this.closePopup()});const t=this.form.querySelector("[data-cpl-reset]");t&&t.addEventListener("click",e=>{e.preventDefault(),this.syncFormFromSearch(""),this.dateRange&&this.dateRange.clear(),this.apply("",{append:!1}),this.popup&&this.closePopup()})}this.pagerSlot&&this.pagerSlot.addEventListener("click",t=>{const e=t.target.closest("[data-cpl-pager] a");if(e&&e.href){t.preventDefault(),this.apply(this.searchFromUrl(e.href),{append:!1}).then(()=>this.scrollToBlockTop());return}const i=t.target.closest("[data-cpl-loadmore]");if(i){t.preventDefault();const s=parseInt(i.getAttribute("data-next"),10)||2;this.apply(this.formSearch(s),{append:!0})}}),window.addEventListener("popstate",()=>{const t=window.location.search.replace(/^\?/,"");this.syncFormFromSearch(t),this.syncMapFromSearch(t),this.apply(t,{append:!1,push:!1})})}}async apply(t,e){e=e||{};const i=!!e.append,s=e.push!==!1;this.controls&&this.controls.classList.add("cpl-is-loading"),i?this.setLoadMoreLoading(!0):this.setCardsSkeleton(!0);const r=i?this.grid.lastElementChild:null;try{const o=await(await fetch(this.restUrl+(t?"?"+t:""),{headers:{Accept:"application/json"}})).json();if(i?this.grid.insertAdjacentHTML("beforeend",o.html||""):this.grid.innerHTML=o.html||"",this.count&&typeof o.total<"u"&&(this.count.textContent=o.total),this.pagerSlot&&(this.pagerSlot.innerHTML=o.pager_html||""),i&&this.focusFirstAppended(r),this.onGridUpdated({append:i,search:t}),s&&this.config.permalink){const n=this.searchWithMapState(t);window.history.pushState({},"",this.config.permalink+(n?"?"+n:""))}}catch(a){console.warn("[contentplaylist] apply failed",a)}finally{this.controls&&this.controls.classList.remove("cpl-is-loading"),this.setCardsSkeleton(!1),this.setLoadMoreLoading(!1)}}focusFirstAppended(t){const e=t?t.nextElementSibling:this.grid.firstElementChild;if(!e)return;const i=e.querySelector("a[href]");if(i){i.focus({preventScroll:!0});return}e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0})}setCardsSkeleton(t){this.grid&&this.grid.querySelectorAll(".card").forEach(e=>{e.classList.toggle("skeleton-card",t)})}setLoadMoreLoading(t){const e=this.pagerSlot&&this.pagerSlot.querySelector("[data-cpl-loadmore-wrap]");e&&e.classList.toggle("cpl-is-loading",t)}scrollToBlockTop(){const t=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.el.scrollIntoView({block:"start",behavior:t?"auto":"smooth"})}formSearch(t){const e=this.form?new URLSearchParams(new FormData(this.form)):new URLSearchParams;return e.delete("cpl_page"),t&&e.set("cpl_page",t),e.toString()}searchFromUrl(t){try{return new URL(t,window.location.origin).searchParams.toString()}catch{return""}}syncFormFromSearch(t){this.form&&(this.form.querySelectorAll("[data-cpl-field]").forEach(e
1=>{e.type==="checkbox"?e.checked=!1:e.value=""}),new URLSearchParams(t).forEach((e,i)=>{if(i==="cpl_page")return;const s=i.replace(/\[\]$/,""),r=this.form.querySelector('[data-cpl-field="'+s+'"][data-cpl-value="'+e+'"]');if(r){r.checked=!0;return}const a=this.form.querySelector('[data-cpl-field="'+i+'"]');a&&(a.value=e)}),this.reflectMirrors())}setupMirrors(){!this.inline||!this.form||(this.inline.hidden=!1,this.reflectMirrors(),this.inline.querySelectorAll("[data-cpl-mirror]").forEach(t=>{const e=this.canonicalFor(t);if(!e)return;const i=()=>{this.copyState(t,e),this.apply(this.formSearch(),{append:!1})};t.addEventListener("change",i),t.tagName==="INPUT"&&(t.type==="search"||t.type==="text")&&t.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),i())});const s=()=>this.copyState(e,t);e.addEventListener("change",s),e.addEventListener("input",s)}))}reflectMirrors(){!this.inline||!this.form||this.inline.querySelectorAll("[data-cpl-mirror]").forEach(t=>{const e=this.canonicalFor(t);e&&this.copyState(e,t)})}copyState(t,e){e.type==="checkbox"?e.checked=t.checked:e.value=t.value}canonicalFor(t){const e=t.getAttribute("data-cpl-mirror"),i=t.getAttribute("data-cpl-mirror-value");return i!==null?this.form.querySelector('[data-cpl-field="'+e+'"][data-cpl-value="'+i+'"]'):this.form.querySelector('[data-cpl-field="'+e+'"]')}setupPopup(){if(!this.popup||!this.toggle)return;this.onKeydown=e=>{e.key==="Escape"?this.closePopup():e.key==="Tab"&&this.trapFocus(e)},this.toggle.addEventListener("click",()=>this.openPopup());const t=this.popup.querySelector("[data-cpl-close]");t&&t.addEventListener("click",()=>this.closePopup()),this.popup.addEventListener("click",e=>{e.target===this.popup&&this.closePopup()})}openPopup(){this.popup.hidden=!1,this.toggle.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.onKeydown);const t=this.focusable();t.length&&t[0].focus()}closePopup(){!this.popup||this.popup.hidden||(this.popup.hidden=!0,this.toggle.setAttribute("aria-expanded","false"),document.removeEventListener("keydown",this.onKeydown),this.toggle.focus())}focusable(){return Array.prototype.slice.call(this.popup.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(t=>t.offsetParent!==null)}trapFocus(t){const e=this.focusable();if(!e.length)return;const i=e[0],s=e[e.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),s.focus()):!t.shiftKey&&document.activeElement===s&&(t.preventDefault(),i.focus())}setupFacetToggles(){const t=Array.prototype.slice.call(this.controls.querySelectorAll("[data-cpl-facet-toggle]"));t.forEach(e=>{const i=document.getElementById(e.getAttribute("aria-controls"));i&&(i.hidden=!0,e.setAttribute("aria-expanded","false"),e.addEventListener("click",()=>{const s=e.getAttribute("aria-expanded")==="true";e.setAttribute("aria-expanded",String(!s)),i.hidden=s}))}),t.length&&document.addEventListener("click",e=>{t.forEach(i=>{if(i.getAttribute("aria-expanded")!=="true")return;const s=document.getElementById(i.getAttribute("aria-controls"));!s||i.contains(e.target)||s.contains(e.target)||(i.setAttribute("aria-expanded","false"),s.hidden=!0)})})}setupFacetMore(){this.controls.querySelectorAll("[data-cpl-facet-more]").forEach(t=>{const e=document.getElementById(t.getAttribute("aria-controls"));if(!e)return;const i=t.getAttribute("data-cpl-facet-more-label"),s=t.getAttribute("data-cpl-facet-more-less-label"),r=e.querySelectorAll(".cpl-facet__term--extra");r.forEach(a=>{a.hidden=!0}),t.addEventListener("click",()=>{const a=t.getAttribute("aria-expanded")==="true";r.forEach(o=>{o.hidden=a}),t.setAttribute("aria-expanded",String(!a)),t.textContent=a?i:s})})}}export{l 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.