|
1
|
-
(()=>{function m(){document.querySelectorAll("[data-map-pos-left]").forEach(o=>{let r=o.getAttribute("data-map-pos-left"),i=o.getAttribute("data-map-pos-top");r&&i&&(o.style.position="absolute",o.style.left=r+"%",o.style.top=i+"%")})}var w=function(){let o={};function r(e,t,n){let s=document.querySelector(e),c=document.querySelector(`${e}.w-dropdown`),u=s.querySelector(`${e} .w-dropdown-toggle`),a=s.querySelector(`${e} .w-dropdown-list`),E=s.querySelector(`${e} .dropdown-selected-value`),f=s.querySelectorAll(`${e} .dropdown-item`);if(o[e]={container:s,dropdown:c,dropdownToggle:u,dropdownList:a,selectedItemValueContainer:E,collectionItems:f,onChange:t},f.forEach(d=>{d.addEventListener("click",function(S){S.preventDefault();let p=this;i(e,p),t&&t(p),a.classList.remove("w--open"),c.blur()})}),n){let d=l(e,n);d&&setTimeout(()=>{d.click()},200)}}function i(e,t){let n=o[e];if(!n)return;let s=n.selectedItemValueContainer;for(;s.firstChild;)s.removeChild(s.firstChild);let c=t;if(c){let u=c.cloneNode(!0);s.appendChild(u);let a=c.getAttribute("data-value");n.dropdown.setAttribute("data-current-value",a)}else console.error("SelectedItem Element not found.",t)}function l(e,t){let n=o[e];return Array.from(n.collectionItems).find(s=>s.getAttribute("data-value")===t)}return{init:function({selector:e,onChange:t,initialValue:n}){document.addEventListener("DOMContentLoaded",function(){r(e,t,n)})},setValue:function(e,t){let n=l(e,t);n?n.click():t!=null&&console.error(`No item with value '${t}' found in dropdown '${e}'`)},getValue:function(e){return o[e].dropdown.getAttribute("data-current-value")}}}();function y(){document.querySelectorAll("#edition-cards-section .edition-card-item").forEach(r=>{let i=r.querySelectorAll("a"),l=r.getAttribute("data-editionslug"),e=r.getAttribute("data-bookingstate");i.forEach(t=>{if(e=="Available Soon"){t.setAttribute("href","#"),t.style.cursor="auto";let n=t.querySelector(".edition-card-image");n.style.opacity=.4}else if(l){let n=t.getAttribute("href").split("?")[0];t.setAttribute("href",`${n}?edition=${encodeURIComponent(l)}`)}})})}function g(){let o=document.querySelectorAll(".filter-button"),r=document.querySelectorAll(".filter-list-item");o.forEach(l=>{l.addEventListener("click",function(){o.forEach(t=>t.classList.remove("active")),this.classList.add("active");let e=this.getAttribute("data-season");e==="all"?r.forEach(t=>{t.classList.remove("filtered-out")}):r.forEach(t=>{t.getAttribute("data-season")===e?t.classList.remove("filtered-out"):t.classList.add("filtered-out")})})});let i=document.querySelector('[data-season="all"]');i&&i.click()}document.addEventListener("DOMContentLoaded",function(){y(),g(),m()});function v(o){let r=document.querySelectorAll(".filter-list-item");o===""?r.forEach(i=>{i.style.display="block"}):r.forEach(i=>{i.getAttribute("data-location")===o?i.style.display="block":i.style.display="none"})}var A=new URLSearchParams(window.location.search),L=A.get("location");w.init({selector:"#destination-dropdown",initialValue:L,onChange:o=>{let r=o.getAttribute("data-value");v(r)}});})();
|