function aeSlideDown(el, ms){
if(!el) return;
ms=ms||250;
el.style.removeProperty('display');
let display=window.getComputedStyle(el).display;
if(display==='none') display='block';
el.style.display=display;
const height=el.scrollHeight;
el.style.overflow='hidden';
el.style.height='0px';
el.style.paddingTop='0';
el.style.paddingBottom='0';
el.style.marginTop='0';
el.style.marginBottom='0';
void el.offsetHeight;
el.style.transitionProperty='height, margin, padding';
el.style.transitionDuration=ms + 'ms';
el.style.height=height + 'px';
el.style.removeProperty('padding-top');
el.style.removeProperty('padding-bottom');
el.style.removeProperty('margin-top');
el.style.removeProperty('margin-bottom');
setTimeout(()=> {
el.style.removeProperty('height');
el.style.removeProperty('overflow');
el.style.removeProperty('transition-duration');
el.style.removeProperty('transition-property');
}, ms);
}
function aeSlideUp(el, ms){
if(!el) return;
ms=ms||250;
el.style.transitionProperty='height, margin, padding';
el.style.transitionDuration=ms + 'ms';
el.style.boxSizing='border-box';
el.style.height=el.offsetHeight + 'px';
void el.offsetHeight;
el.style.overflow='hidden';
el.style.height='0px';
el.style.paddingTop='0';
el.style.paddingBottom='0';
el.style.marginTop='0';
el.style.marginBottom='0';
setTimeout(()=> {
el.style.display='none';
el.style.removeProperty('height');
el.style.removeProperty('padding-top');
el.style.removeProperty('padding-bottom');
el.style.removeProperty('margin-top');
el.style.removeProperty('margin-bottom');
el.style.removeProperty('overflow');
el.style.removeProperty('transition-duration');
el.style.removeProperty('transition-property');
}, ms);
}
function aeSlideToggle(el, ms){
if(!el) return;
if(window.getComputedStyle(el).display==='none') aeSlideDown(el, ms);
else aeSlideUp(el, ms);
}
(function (){
const customSelects=document.getElementsByClassName('custom-select');
Array.prototype.forEach.call(customSelects, function (wrapper){
const selElmnt=wrapper.getElementsByTagName('select')[0];
if(!selElmnt) return;
const a=document.createElement('DIV');
a.setAttribute('class', 'select-selected');
a.innerHTML=selElmnt.options[selElmnt.selectedIndex].innerHTML;
wrapper.appendChild(a);
const b=document.createElement('DIV');
b.setAttribute('class', 'select-items select-hide');
for (let j=1; j < selElmnt.length; j++){
const c=document.createElement('DIV');
c.innerHTML=selElmnt.options[j].innerHTML;
c.addEventListener('click', function (){
const s=this.parentNode.parentNode.getElementsByTagName('select')[0];
const h=this.parentNode.previousSibling;
for (let i=0; i < s.length; i++){
if(s.options[i].innerHTML===this.innerHTML){
s.selectedIndex=i;
h.innerHTML=this.innerHTML;
const y=this.parentNode.getElementsByClassName('same-as-selected');
for (let k=0; k < y.length; k++) y[k].removeAttribute('class');
this.setAttribute('class', 'same-as-selected');
break;
}}
h.click();
});
b.appendChild(c);
}
wrapper.appendChild(b);
a.addEventListener('click', function (e){
e.stopPropagation();
closeAllSelect(this);
this.nextSibling.classList.toggle('select-hide');
this.classList.toggle('select-arrow-active');
});
});
function closeAllSelect(elmnt){
const x=document.getElementsByClassName('select-items');
const y=document.getElementsByClassName('select-selected');
const arrNo=[];
for (let i=0; i < y.length; i++){
if(elmnt===y[i]) arrNo.push(i);
else y[i].classList.remove('select-arrow-active');
}
for (let i=0; i < x.length; i++){
if(arrNo.indexOf(i)===-1) x[i].classList.add('select-hide');
}}
document.addEventListener('click', function (){ closeAllSelect(null); });
})();
window.addEventListener('load', function (){
const cont=document.querySelector('.container');
const leftEls=document.querySelectorAll('.container-left');
if(!cont||!leftEls.length) return;
const left=cont.getBoundingClientRect().left;
leftEls.forEach((el)=> {
el.style.width='calc(100% - ' + left + 'px)';
});
});
function aeEqualHeight(parents, childSelector){
if(!parents||!parents.length) return;
let currentTallest=0;
let currentRowStart=0;
let rowEls=[];
parents.forEach((parent)=> {
const child=parent.querySelector(childSelector);
if(!child) return;
child.style.height='auto';
const top=parent.offsetTop;
if(currentRowStart!==top){
rowEls.forEach((p)=> {
const c=p.querySelector(childSelector);
if(c) c.style.height=currentTallest + 'px';
});
rowEls=[];
currentRowStart=top;
currentTallest=child.offsetHeight;
rowEls.push(parent);
}else{
rowEls.push(parent);
currentTallest=Math.max(currentTallest, child.offsetHeight);
}
rowEls.forEach((p)=> {
const c=p.querySelector(childSelector);
if(c) c.style.height=currentTallest + 'px';
});
});
}
document.addEventListener('DOMContentLoaded', function (){
document.querySelectorAll('.filter-arg').forEach((el)=> {
el.addEventListener('click', function (e){
e.preventDefault();
const url=new URL(document.location);
url.searchParams.set(this.dataset.arg, this.dataset.value);
document.location=url;
});
});
document.querySelectorAll('.show-more').forEach((btn)=> {
btn.addEventListener('click', function (){
if(this.id==='hider'||this.id==='shower' ||
this.id==='hider1'||this.id==='shower1') return;
const showing=Array.from(this.parentNode.children)
.filter((c)=> c!==this&&c.classList.contains('showing'));
const showSiblings=Array.from(this.parentNode.children)
.filter((c)=> c!==this&&c.classList.contains('show'));
const span=this.querySelector('span');
if(this.classList.contains('active')){
this.classList.remove('active');
showing.forEach((s)=> aeSlideUp(s));
showSiblings.forEach((s)=> s.classList.remove('active'));
if(span) span.textContent=span.dataset.more||span.textContent;
}else{
this.classList.add('active');
showing.forEach((s)=> aeSlideDown(s));
showSiblings.forEach((s)=> s.classList.add('active'));
if(span) span.textContent=span.dataset.less||span.textContent;
}});
});
document.querySelectorAll('.ae-readmore-toggle').forEach((cb)=> {
cb.addEventListener('change', ()=> {
if(cb.checked) return;
const shower=document.querySelector('label[for="' + cb.id + '"].ae-readmore__shower');
if(shower){
shower.scrollIntoView({ behavior: 'smooth', block: 'center' });
}});
});
document.querySelectorAll('.lang-toggle').forEach((toggle)=> {
toggle.addEventListener('click', function (e){
e.preventDefault();
aeSlideToggle(this.nextElementSibling);
});
});
document.querySelectorAll('.language-menu li a').forEach((link)=> {
link.addEventListener('click', function (){
const langWrap=this.closest('.menu-lang');
if(!langWrap) return;
const toggle=langWrap.querySelector('.lang-toggle');
if(toggle) toggle.innerHTML=this.innerHTML;
const menu=this.closest('.language-menu');
if(menu) aeSlideUp(menu);
});
});
const toggleMnu=document.querySelector('.toggle-mnu');
if(toggleMnu){
toggleMnu.addEventListener('click', function (){
document.documentElement.classList.toggle('overflow-hidden');
this.classList.toggle('on');
const header=this.closest('.site-header');
if(header){
header.classList.toggle('active');
if(header.classList.contains('abs-header')){
header.classList.toggle('light-header');
}}
document.querySelectorAll('.header-nav').forEach((n)=> n.classList.toggle('show'));
});
}
const applyEqualHeight=()=> {
if(window.innerWidth <=840) return;
aeEqualHeight(document.querySelectorAll('.main-posts .blog-post'), 'figure');
aeEqualHeight(document.querySelectorAll('.contact-sections'), '.cbox p');
};
applyEqualHeight();
window.addEventListener('load', applyEqualHeight);
let resizeT=null;
window.addEventListener('resize', ()=> {
clearTimeout(resizeT);
resizeT=setTimeout(applyEqualHeight, 150);
});
});
(function (){
const btns=document.querySelectorAll('.acc-btn');
btns.forEach((el)=> el.addEventListener('click', function (){
this.classList.toggle('is-open');
const content=this.nextElementSibling;
if(!content) return;
if(content.style.maxHeight) content.style.maxHeight=null;
else content.style.maxHeight=content.scrollHeight + 'px';
}));
})();
window.aeBindInfoTooltips=function (root){
const scope=root||document;
const items=scope.querySelectorAll('.info-item[data-tooltip]:not([data-ae-tooltip-bound])');
if(!items.length) return;
items.forEach((el)=> {
el.setAttribute('data-ae-tooltip-bound', '1');
if(!el.title&&el.dataset.tooltip){
el.title=el.dataset.tooltip;
}
el.addEventListener('click', (e)=> {
e.stopPropagation();
document.querySelectorAll('.info-item.tooltip-active').forEach((other)=> {
if(other!==el) other.classList.remove('tooltip-active');
});
el.classList.toggle('tooltip-active');
});
});
};
(function (){
window.aeBindInfoTooltips(document);
document.addEventListener('click', ()=> {
document.querySelectorAll('.info-item.tooltip-active').forEach((el)=> {
el.classList.remove('tooltip-active');
});
});
})();
(function (){
const btn=document.querySelector('.ae-load-more');
if(!btn) return;
const pagination=document.querySelector('.main .pagination');
if(pagination) pagination.style.display='none';
const grid=document.querySelector('.related-vacation .row');
if(!grid) return;
const cfg=window.aeLoadMore||{};
if(!cfg.ajaxurl||!cfg.nonce) return;
let io=null;
let inFlight=false;
function startObserver(){
if(!('IntersectionObserver' in window)) return;
if(io) io.disconnect();
io=new IntersectionObserver((entries)=> {
for (const entry of entries){
if(entry.isIntersecting) loadNext();
}}, { rootMargin: '400px 0px' });
io.observe(btn);
}
function stopObserver(){
if(io) io.disconnect();
}
window.aeLoadMoreReengage=function (){
btn.disabled=false;
btn.classList.remove('is-loading');
const wrap=btn.closest('.ae-load-more-wrapper');
if(wrap) wrap.style.display='';
startObserver();
};
window.aeLoadMoreHide=function (){
const wrap=btn.closest('.ae-load-more-wrapper');
if(wrap) wrap.style.display='none';
stopObserver();
};
window.aeLoadMoreSetPaged=function (n){
btn.dataset.paged=String(n);
};
async function loadNext(){
if(inFlight||btn.disabled||!document.body.contains(btn)) return;
inFlight=true;
btn.disabled=true;
btn.classList.add('is-loading');
const originalText=btn.textContent;
btn.textContent=btn.dataset.loadingText||'Laden…';
const fd=new FormData();
fd.append('action', 'ae_load_more_venues');
fd.append('nonce', cfg.nonce);
fd.append('paged', btn.dataset.paged||'1');
fd.append('term_id', btn.dataset.termId||'0');
fd.append('taxonomy', btn.dataset.taxonomy||'category');
try {
const params=new URLSearchParams(window.location.search);
const allowed=['price_min','price_max','anglers_min','extra_guests','dog','accommodation'];
allowed.forEach(function (k){
const v=params.get(k);
if(v!==null&&v!=='') fd.append('filters[' + k + ']', v);
});
params.getAll('activities[]').forEach(function (v){
fd.append('filters[activities][]', v);
});
} catch (e){}
try {
const res=await fetch(cfg.ajaxurl, { method: 'POST', body: fd, credentials: 'same-origin' });
const json=await res.json();
if(!json||!json.success) throw new Error('bad response');
const tmp=document.createElement('div');
tmp.innerHTML=json.data.html;
const frag=document.createDocumentFragment();
while (tmp.firstChild) frag.appendChild(tmp.firstChild);
grid.appendChild(frag);
if(typeof window.aeBindInfoTooltips==='function'){
window.aeBindInfoTooltips(grid);
}
btn.dataset.paged=String(json.data.next_paged);
if(!json.data.has_more){
stopObserver();
const wrap=btn.closest('.ae-load-more-wrapper');
if(wrap) wrap.style.display='none';
}else{
btn.disabled=false;
btn.classList.remove('is-loading');
btn.textContent=originalText;
if(io){
io.unobserve(btn);
requestAnimationFrame(()=> {
if(document.body.contains(btn)) io.observe(btn);
});
}}
} catch (err){
btn.disabled=false;
btn.classList.remove('is-loading');
btn.textContent=originalText;
} finally {
inFlight=false;
}}
btn.addEventListener('click', loadNext);
startObserver();
})();
(function (){
const wrappers=document.querySelectorAll('.ae-fld-count');
if(!wrappers.length) return;
function updateTotal(){
const aIn=document.querySelector('.ae-fld-count--anglers .ae-count__input');
const gIn=document.querySelector('.ae-fld-count--guests .ae-count__input');
const out=document.querySelector('.ae-total__value');
if(!aIn||!out) return;
const anglers=parseInt(aIn.value, 10)||0;
const guests=gIn ? (parseInt(gIn.value, 10)||0):0;
out.textContent=String(anglers + guests);
}
wrappers.forEach((w)=> {
const min=parseFloat(w.dataset.min)||0;
const max=parseFloat(w.dataset.max)||20;
const input=w.querySelector('.ae-count__input');
const slider=w.querySelector('.ae-count__slider');
const fill=w.querySelector('.ae-count__bar-fill');
if(!input||!slider) return;
function syncFromSlider(){
input.value=slider.value;
updateFill(parseFloat(slider.value));
updateTotal();
input.dispatchEvent(new Event('change', {bubbles: true}));
}
function syncFromInput(){
let v=parseFloat(input.value);
if(isNaN(v)) v=min;
if(v < min) v=min;
if(v > max) v=max;
slider.value=v;
updateFill(v);
updateTotal();
}
function updateFill(v){
if(!fill) return;
const pct=((v - min) / (max - min)) * 100;
fill.style.width=Math.max(0, Math.min(100, pct)) + '%';
}
slider.addEventListener('input', syncFromSlider);
input.addEventListener('input',  syncFromInput);
syncFromInput();
});
updateTotal();
})();
(function (){
const wrappers=document.querySelectorAll('.ae-fld-range');
if(!wrappers.length) return;
wrappers.forEach((w)=> {
const min=parseFloat(w.dataset.min)||0;
const max=parseFloat(w.dataset.max)||100;
const step=parseFloat(w.dataset.step)||1;
const prefix=w.dataset.prefix||'';
const suffix=w.dataset.suffix||'';
const lower=w.querySelector('.ae-range__input--lower');
const upper=w.querySelector('.ae-range__input--upper');
const fill=w.querySelector('.ae-range__fill');
const display=w.querySelector('.ae-range__display');
const hMin=w.querySelector('.ae-range__hidden--min');
const hMax=w.querySelector('.ae-range__hidden--max');
if(!lower||!upper) return;
function fmt(v){ return prefix + v + suffix; }
function update(){
let lo=parseFloat(lower.value);
let up=parseFloat(upper.value);
if(lo > up - step){
if(document.activeElement===lower) lo=up - step;
else up=lo + step;
lower.value=lo;
upper.value=up;
}
const range=max - min;
const lpct=((lo - min) / range) * 100;
const upct=((up - min) / range) * 100;
if(fill){
fill.style.left=lpct + '%';
fill.style.right=(100 - upct) + '%';
}
if(display) display.textContent=fmt(lo) + ' – ' + fmt(up);
if(hMin) hMin.value=(lo > min) ? String(lo):'';
if(hMax) hMax.value=(up < max) ? String(up):'';
}
lower.addEventListener('input', update);
upper.addEventListener('input', update);
lower.addEventListener('change', ()=> w.dispatchEvent(new Event('change', {bubbles:true})));
upper.addEventListener('change', ()=> w.dispatchEvent(new Event('change', {bubbles:true})));
update();
});
})();
(function (){
const form=document.querySelector('.ae-arch-filter');
if(!form) return;
const grid=document.querySelector('.related-vacation .row');
if(!grid) return;
const cfg=window.aeLoadMore||{};
if(!cfg.ajaxurl||!cfg.nonce) return;
let btn=document.querySelector('.ae-load-more');
let btnWrap=document.querySelector('.ae-load-more-wrapper');
let timer=null;
let inFlight=false;
function buildFilterPayload(){
const fd=new FormData(form);
const out={};
for (const [k, v] of fd){
if(v===''||v==='0') continue;
if(k==='activities[]'){
if(!out.activities) out.activities=[];
out.activities.push(v);
}else{
out[k]=v;
}}
return out;
}
function updateUrl(payload){
const params=new URLSearchParams();
Object.keys(payload).forEach((k)=> {
if(k==='activities'){
payload.activities.forEach((v)=> params.append('activities[]', v));
}else{
params.append(k, payload[k]);
}});
const qs=params.toString();
const newUrl=qs ? (window.location.pathname + '?' + qs):window.location.pathname;
history.replaceState(null, '', newUrl);
}
function rebuildChips(payload){
const chipsWrap=form.querySelector('.ae-arch-filter__chips');
const detailsEl=form.querySelector('.ae-arch-filter__details');
if(!chipsWrap||!detailsEl) return;
const labels=(cfg.chipLabels||{});
const acts=labels.activities||{};
const country=form.dataset.countryName||'';
const currency=form.dataset.currency||'€';
const maxChips=parseInt(form.dataset.chipMax||'3', 10);
const chips=[];
if(country) chips.push(country);
const anglers=parseInt(payload.anglers_min, 10);
if(anglers > 0){
const tpl=anglers===1 ? (labels.visser_one||'%d visser'):(labels.visser_many||'%d vissers');
chips.push(tpl.replace('%d', anglers));
}
const guests=parseInt(payload.extra_guests, 10);
if(guests > 0){
const tpl=guests===1 ? (labels.gast_one||'%d extra gast'):(labels.gast_many||'%d extra gasten');
chips.push(tpl.replace('%d', guests));
}
if(payload.price_min||payload.price_max){
const pmin=parseInt(payload.price_min, 10)||0;
const pmax=parseInt(payload.price_max, 10)||3000;
chips.push(currency + pmin + '–' + currency + pmax);
}
if(Array.isArray(payload.activities)){
payload.activities.forEach((key)=> {
if(acts[key]) chips.push(acts[key]);
});
}
if(payload.accommodation) chips.push(labels.accommodation||'Accommodatie');
if(payload.dog)           chips.push(labels.dog||'Hond mee');
if(payload.exclusief)     chips.push(labels.exclusief||'Gehele meer');
const visible=chips.slice(0, maxChips);
const overflow=chips.slice(maxChips);
const escape=(s)=> String(s).replace(/[&<>"']/g, (c)=> ({
'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'
}[c]));
let html=visible.map((c)=> '<span class="ae-chip">' + escape(c) + '</span>').join('');
if(overflow.length > 0){
html +='<span class="ae-chip ae-chip--more" title="' + escape(overflow.join(', ')) + '">+' + overflow.length + '</span>';
}
chipsWrap.innerHTML=html;
detailsEl.classList.toggle('ae-arch-filter__details--no-chips', chips.length===0);
}
async function applyFilter(){
if(inFlight) return;
inFlight=true;
form.classList.add('is-loading');
const payload=buildFilterPayload();
updateUrl(payload);
rebuildChips(payload);
const reqFd=new FormData();
reqFd.append('action', 'ae_load_more_venues');
reqFd.append('nonce', cfg.nonce);
reqFd.append('paged_target', '1');
const formTermId=form.dataset.termId||(btn&&btn.dataset.termId)||'0';
const formTaxonomy=form.dataset.taxonomy||(btn&&btn.dataset.taxonomy)||'category';
reqFd.append('term_id',  formTermId);
reqFd.append('taxonomy', formTaxonomy);
Object.keys(payload).forEach((k)=> {
if(k==='activities'){
payload.activities.forEach((v)=> reqFd.append('filters[activities][]', v));
}else{
reqFd.append('filters[' + k + ']', payload[k]);
}});
try {
const res=await fetch(cfg.ajaxurl, { method: 'POST', body: reqFd, credentials: 'same-origin' });
const json=await res.json();
if(!json||!json.success) throw new Error('bad response');
grid.innerHTML=json.data.html||'';
if(typeof window.aeBindInfoTooltips==='function'){
window.aeBindInfoTooltips(grid);
}
const counter=document.querySelector('.ae-results-count__num');
const counterLabel=document.querySelector('.ae-results-count__label');
if(counter&&typeof json.data.total_found!=='undefined'){
const newTotal=parseInt(json.data.total_found, 10)||0;
const oldTotal=parseInt(counter.dataset.total||'0', 10);
counter.textContent=String(newTotal);
counter.dataset.total=String(newTotal);
if(counterLabel){
counterLabel.textContent=(newTotal===1)
? (form.dataset.labelOne||'resultaat')
: (form.dataset.labelMany||'resultaten');
}
if(newTotal!==oldTotal){
counter.classList.remove('is-flash');
void counter.offsetWidth;
counter.classList.add('is-flash');
}}
const empty=grid.parentNode.querySelector('.ae-empty-inline');
if(!grid.children.length){
if(!empty){
const div=document.createElement('div');
div.className='ae-empty-inline';
div.textContent=(form.dataset.emptyText||'Geen visvakanties gevonden met deze filters.');
grid.parentNode.insertBefore(div, grid.nextSibling);
}}else if(empty){
empty.remove();
}
if(json.data.has_more){
if(typeof window.aeLoadMoreSetPaged==='function'){
window.aeLoadMoreSetPaged(json.data.next_paged);
}
if(typeof window.aeLoadMoreReengage==='function'){
window.aeLoadMoreReengage();
}}else if(typeof window.aeLoadMoreHide==='function'){
window.aeLoadMoreHide();
}} catch (err){
} finally {
inFlight=false;
form.classList.remove('is-loading');
}}
function debounced(){
clearTimeout(timer);
timer=setTimeout(applyFilter, 300);
}
form.addEventListener('input',  debounced);
form.addEventListener('change', debounced);
form.addEventListener('submit', function (e){
e.preventDefault();
clearTimeout(timer);
applyFilter();
});
})();
(function (){
const details=document.querySelector('.ae-arch-filter__details');
if(!details) return;
const mq=window.matchMedia('(min-width: 701px)');
const sync=(e)=> {
if(e.matches) details.setAttribute('open', '');
};
sync(mq);
if(typeof mq.addEventListener==='function'){
mq.addEventListener('change', sync);
}else if(typeof mq.addListener==='function'){
mq.addListener(sync);
}})();
(function (){
const KEY='ae_filter_state_v1';
const FIELDS=['country','vtype','anglers_min','extra_guests',
'price_min','price_max','dog','accommodation',
'exclusief','start_date','end_date'];
function readUrlState(form){
const params=new URLSearchParams(window.location.search);
const out={};
FIELDS.forEach((k)=> {
const v=params.get(k);
if(v) out[k]=v;
});
const acts=params.getAll('activities[]');
if(acts.length) out.activities=acts;
if(form&&!out.country){
const slug=form.dataset.countrySlug||'';
if(slug) out.country=slug;
}
return out;
}
function save(){
const state=readUrlState(form);
try { sessionStorage.setItem(KEY, JSON.stringify(state)); } catch (e){}}
function load(){
try {
const raw=sessionStorage.getItem(KEY);
return raw ? JSON.parse(raw):null;
} catch (e){ return null; }}
function applyDateBlock(block, isoDate){
if(!block||!isoDate) return;
const m=String(isoDate).match(/^(\d{4})-(\d{2})-(\d{2})$/);
if(!m) return;
const yearEl=block.querySelector('.year');
const monthEl=block.querySelector('.month');
const dayEl=block.querySelector('.day');
if(yearEl){ yearEl.value=String(parseInt(m[1], 10)); yearEl.dispatchEvent(new Event('change', { bubbles: true })); }
if(monthEl){ monthEl.value=String(parseInt(m[2], 10)); monthEl.dispatchEvent(new Event('change', { bubbles: true })); }
if(dayEl){ dayEl.value=String(parseInt(m[3], 10)); dayEl.dispatchEvent(new Event('change', { bubbles: true })); }}
function applyToForm(form, state){
if(!state) return;
FIELDS.forEach((k)=> {
if(state[k]===undefined) return;
const field=form.querySelector(`[name="${k}"]`);
if(!field) return;
if(field.type==='checkbox'){
field.checked=state[k]=='1'||state[k]===true;
field.dispatchEvent(new Event('change', { bubbles: true }));
}else{
field.value=state[k];
field.dispatchEvent(new Event('input',  { bubbles: true }));
field.dispatchEvent(new Event('change', { bubbles: true }));
}});
if(Array.isArray(state.activities)){
state.activities.forEach((v)=> {
const cb=form.querySelector(`input[name="activities[]"][value="${v}"]`);
if(cb){
cb.checked=true;
cb.dispatchEvent(new Event('change', { bubbles: true }));
}});
}
applyDateBlock(form.querySelector('.date-block.from'), state.start_date);
applyDateBlock(form.querySelector('.date-block.to'),   state.end_date);
}
const form=document.querySelector('.ae-arch-filter');
if(!form) return;
const mode=form.dataset.mode||'archive';
if(mode==='home'){
const hasUrlState=Object.keys(readUrlState(form)).length > 0;
if(!hasUrlState){
setTimeout(()=> applyToForm(form, load()), 30);
}}else{
save();
let saveTimer=null;
const debouncedSave=()=> {
clearTimeout(saveTimer);
saveTimer=setTimeout(save, 350);
};
form.addEventListener('input',  debouncedSave);
form.addEventListener('change', debouncedSave);
}})();
(function (){
const details=document.querySelector('details.ae-activities');
if(!details) return;
const panel=details.querySelector('.ae-activities__panel');
const summary=details.querySelector('summary');
const chosen=summary&&summary.querySelector('.ae-activities__chosen');
if(!panel||!summary||!chosen) return;
const labels=(window.aeLoadMore&&window.aeLoadMore.chipLabels&&window.aeLoadMore.chipLabels.activities)||{};
const placeholder=summary.dataset.placeholder||'Kies activiteiten';
function updateChosen(){
const checked=panel.querySelectorAll('input[type="checkbox"]:checked');
if(checked.length===0){
chosen.textContent=placeholder;
}else{
const names=Array.from(checked).map((cb)=> labels[cb.value]||cb.value);
chosen.textContent=names.join(', ');
}}
panel.addEventListener('change', (e)=> {
const target=e.target;
if(!target||target.type!=='checkbox') return;
updateChosen();
details.removeAttribute('open');
});
})();
(function (){
const sel=document.querySelector('.ae-country-switch');
if(!sel) return;
sel.addEventListener('change', function (){
const target=sel.value;
if(!target) return;
try {
const u=new URL(target, window.location.origin);
const cur=new URLSearchParams(window.location.search);
const carry=['price_min', 'price_max', 'anglers_min',
'extra_guests', 'dog', 'accommodation'];
carry.forEach(function (k){
const v=cur.get(k);
if(v) u.searchParams.set(k, v);
});
cur.getAll('activities[]').forEach(function (v){
u.searchParams.append('activities[]', v);
});
window.location.href=u.toString();
} catch (e){
window.location.href=target;
}});
})();
(function (){
function closeActivitiesIfOutside(target){
document.querySelectorAll('.ae-activities[open]').forEach(function (det){
if(!det.contains(target)) det.removeAttribute('open');
});
}
document.addEventListener('click', function (e){
closeActivitiesIfOutside(e.target);
});
document.addEventListener('focusin', function (e){
closeActivitiesIfOutside(e.target);
});
})();
(function (){
'use strict';
var dialog=null;
var currentGroup=null;
var currentIndex=0;
function getYouTubeId(url){
if(!url) return null;
var m=url.match(/(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|v\/))([^?&"'>\s]+)/);
return m ? m[1]:null;
}
function isImage(url){
return /\.(jpe?g|png|gif|webp|avif|svg)(\?|#|$)/i.test(url);
}
function ensureDialog(){
if(dialog) return dialog;
dialog=document.createElement('dialog');
dialog.className='ae-lightbox';
dialog.setAttribute('aria-label', 'Lightbox');
dialog.innerHTML =
'<button type="button" class="ae-lightbox__close" aria-label="Sluiten">&times;</button>' +
'<button type="button" class="ae-lightbox__prev"  aria-label="Vorige">&lsaquo;</button>' +
'<button type="button" class="ae-lightbox__next"  aria-label="Volgende">&rsaquo;</button>' +
'<div class="ae-lightbox__content"></div>';
document.body.appendChild(dialog);
dialog.querySelector('.ae-lightbox__close').addEventListener('click', closeLightbox);
dialog.querySelector('.ae-lightbox__prev').addEventListener('click', function (){ navigate(-1); });
dialog.querySelector('.ae-lightbox__next').addEventListener('click', function (){ navigate(1); });
dialog.addEventListener('click', function (e){
if(e.target===dialog) closeLightbox();
});
dialog.addEventListener('keydown', function (e){
if(e.key==='ArrowLeft'){ e.preventDefault(); navigate(-1); }
if(e.key==='ArrowRight'){ e.preventDefault(); navigate(1); }});
dialog.addEventListener('close', function (){
dialog.querySelector('.ae-lightbox__content').innerHTML='';
currentGroup=null;
currentIndex=0;
});
return dialog;
}
function getGroupItems(group){
if(!group) return [];
if(!/^[A-Za-z0-9_\-]+$/.test(group)) return [];
return Array.prototype.slice.call(document.querySelectorAll('[data-fancybox="' + group + '"]')
);
}
function renderItem(href, alt){
var content=dialog.querySelector('.ae-lightbox__content');
var ytId=getYouTubeId(href);
if(ytId){
content.innerHTML =
'<iframe src="https://www.youtube.com/embed/' + encodeURIComponent(ytId) +
'?autoplay=1&rel=0" allow="autoplay; encrypted-media; fullscreen" ' +
'allowfullscreen frameborder="0"></iframe>';
return true;
}
if(isImage(href)){
var img=document.createElement('img');
img.src=href;
img.alt=alt||'';
img.decoding='async';
content.innerHTML='';
content.appendChild(img);
return true;
}
window.open(href, '_blank', 'noopener');
return false;
}
function showOrHideNav(group){
var items=group ? getGroupItems(group):[];
var showNav=items.length > 1;
dialog.querySelector('.ae-lightbox__prev').style.display=showNav ? '':'none';
dialog.querySelector('.ae-lightbox__next').style.display=showNav ? '':'none';
}
function openLightbox(href, group, index, alt){
ensureDialog();
currentGroup=group||null;
currentIndex=index||0;
if(!renderItem(href, alt)) return;
showOrHideNav(currentGroup);
if(!dialog.open) dialog.showModal();
}
function navigate(direction){
if(!currentGroup) return;
var items=getGroupItems(currentGroup);
if(items.length < 2) return;
currentIndex=(currentIndex + direction + items.length) % items.length;
var item=items[currentIndex];
renderItem(item.href||item.getAttribute('href'), item.getAttribute('alt')||item.title||'');
}
function closeLightbox(){
if(dialog&&dialog.open) dialog.close();
}
document.addEventListener('click', function (e){
var link=e.target.closest('[data-fancybox]');
if(link){
e.preventDefault();
var group=link.getAttribute('data-fancybox')||null;
var items=group ? getGroupItems(group):[];
var idx=items.indexOf(link);
openLightbox(
link.href||link.getAttribute('href'),
group,
Math.max(0, idx),
link.getAttribute('alt')||link.title||''
);
return;
}
var trigger=e.target.closest('[data-fancybox-trigger]');
if(trigger){
e.preventDefault();
var triggerGroup=trigger.getAttribute('data-fancybox-trigger');
var triggerItems=getGroupItems(triggerGroup);
if(triggerItems.length > 0){
openLightbox(
triggerItems[0].href||triggerItems[0].getAttribute('href'),
triggerGroup,
0,
triggerItems[0].getAttribute('alt')||triggerItems[0].title||''
);
}}
});
})();
document.addEventListener('DOMContentLoaded', ()=> {
if(window.innerWidth > 767) return;
const container=document.querySelector('.ae-vacation-grid');
if(!container) return;
const countryBlocks=container.querySelectorAll('.ae-vacation-country-block');
requestAnimationFrame(()=> {
const containerTop=container.offsetTop;
for (const block of countryBlocks){
const header=block.querySelector('.ae-vacation-country-name');
if(header&&header.textContent.trim().toLowerCase().startsWith('nederland')){
container.scrollTop=header.offsetTop - containerTop;
break;
}}
});
const items=container.querySelectorAll('.ae-vacation-item');
let currentActive=null;
const observer=new IntersectionObserver(entries=> {
entries.forEach(entry=> {
if(entry.isIntersecting){
if(currentActive) currentActive.classList.remove('is-active');
entry.target.classList.add('is-active');
currentActive=entry.target;
}});
}, {
root: container,
threshold: 0.65
});
items.forEach(item=> observer.observe(item));
const originalHTML=container.innerHTML;
let scrollPending=false;
container.addEventListener('scroll', ()=> {
if(scrollPending) return;
scrollPending=true;
requestAnimationFrame(()=> {
scrollPending=false;
const scrollTop=container.scrollTop;
const clientHeight=container.clientHeight;
const scrollHeight=container.scrollHeight;
if(scrollTop + clientHeight >=scrollHeight - 10){
container.insertAdjacentHTML('beforeend', originalHTML);
}else if(scrollTop <=5){
container.insertAdjacentHTML('afterbegin', originalHTML);
container.scrollTop +=1;
}});
}, { passive: true });
});
(function (){
var WIDGET_URL='https://ticket.anglingescapes.nl/modules/chat/js/widget.js?v=3941';
var ANCHOR_ID='ae-freescout-anchor';
var loadingState=null;
function setupFreeScoutConfig(){
var lang=(document.documentElement.lang||'en').toLowerCase().split('-')[0];
if(['nl', 'de', 'en', 'es', 'fr', 'it'].indexOf(lang)===-1){
lang='en';
}
window.FreeScoutW={
s: {
color: '#ff7900',
position: 'br',
locale: lang,
require: [],
id: 1271802239
}};}
function getOrCreateAnchor(){
var anchor=document.getElementById(ANCHOR_ID);
if(!anchor){
anchor=document.createElement('span');
anchor.id=ANCHOR_ID;
anchor.style.cssText=[
'position:fixed',
'bottom:20px',
'right:20px',
'width:1px',
'height:1px',
'opacity:0',
'pointer-events:none',
'z-index:-1'
].join(';');
document.body.appendChild(anchor);
}
return anchor;
}
function tryOpenChat(){
if(!window.FreeScoutW||typeof window.FreeScoutW.show!=='function'){
return false;
}
var anchor=getOrCreateAnchor();
try {
window.FreeScoutW.show(anchor, false);
rebrandPoweredBy();
return true;
} catch (e){
console.warn('[FreeScout] show() faalde:', e);
return false;
}}
var rebrandDone=false;
function rebrandPoweredBy(){
function patchOnce(){
var links=document.querySelectorAll('a[href*="freescout"], a[href*="FreeScout"]');
var changed=0;
links.forEach(function (link){
if(link.id===ANCHOR_ID) return;
link.href='https://www.altenasolutions.com';
link.textContent='altenasolutions.com';
link.title='altenasolutions.com';
link.target='_blank';
link.rel='noopener';
changed++;
});
document.querySelectorAll('*').forEach(function (el){
if(el.children.length===0&&/freescout/i.test(el.textContent) &&
!/altenasolutions/i.test(el.textContent)){
el.textContent=el.textContent.replace(/freescout/gi, 'altenasolutions.com');
changed++;
}});
return changed;
}
var attempts=0;
var poll=setInterval(function (){
attempts++;
if(patchOnce() > 0||attempts >=20){
clearInterval(poll);
}}, 250);
if(rebrandDone) return;
rebrandDone=true;
var observer=new MutationObserver(function (){
patchOnce();
});
observer.observe(document.body, { childList: true, subtree: true });
}
function loadWidget(callback){
if(loadingState===true){
if(callback) callback();
return;
}
if(Array.isArray(loadingState)){
loadingState.push(callback);
return;
}
loadingState=[callback];
setupFreeScoutConfig();
var script=document.createElement('script');
script.async=true;
script.id='freescout-w';
script.src=WIDGET_URL;
script.onload=function (){
var attempts=0;
var maxAttempts=100;
var poll=setInterval(function (){
attempts++;
if(window.FreeScoutW&&typeof window.FreeScoutW.show==='function'){
clearInterval(poll);
var queued=loadingState;
loadingState=true;
queued.forEach(function (cb){ if(cb) cb(); });
}else if(attempts >=maxAttempts){
clearInterval(poll);
console.warn('[FreeScout] FreeScoutW.show niet beschikbaar na 5s', window.FreeScoutW);
}}, 50);
};
script.onerror=function (){
console.error('[FreeScout] widget.js kon niet worden geladen');
loadingState=null;
};
document.head.appendChild(script);
}
window.aeOpenChat=function (){
loadWidget(function (){
if(!tryOpenChat()){
console.warn('[FreeScout] kon chat-paneel niet openen', window.FreeScoutW);
}});
};})();
document.addEventListener('DOMContentLoaded', function (){
const body=document.body;
const masthead=document.getElementById('masthead');
const toggleBtn=document.querySelector('.toggle-mnu');
const headerNav=document.querySelector('.header-nav');
if(toggleBtn&&headerNav&&masthead){
toggleBtn.addEventListener('click', function (e){
e.preventDefault();
e.stopPropagation();
toggleBtn.classList.toggle('is-open');
headerNav.classList.toggle('is-open');
masthead.classList.toggle('menu-open');
body.classList.toggle('menu-open');
});
document.addEventListener('click', function (){
toggleBtn.classList.remove('is-open');
headerNav.classList.remove('is-open');
masthead.classList.remove('menu-open');
body.classList.remove('menu-open');
});
headerNav.addEventListener('click', function (e){
e.stopPropagation();
});
}
document.querySelectorAll('.toggle-submenu').forEach(toggle=> {
toggle.addEventListener('click', function (e){
e.preventDefault();
e.stopPropagation();
const parent=this.closest('.visvakantie-menu');
document.querySelectorAll('.visvakantie-menu.is-open')
.forEach(menu=> {
if(menu!==parent) menu.classList.remove('is-open');
});
parent.classList.toggle('is-open');
});
});
const langToggle=document.querySelector('.lang-toggle');
const langMenu=document.querySelector('.menu-lang');
if(langToggle&&langMenu){
langToggle.addEventListener('click', function (e){
e.preventDefault();
e.stopPropagation();
langMenu.classList.toggle('is-open');
});
document.addEventListener('click', function (){
langMenu.classList.remove('is-open');
});
langMenu.addEventListener('click', function (e){
e.stopPropagation();
});
}});
document.addEventListener('DOMContentLoaded', function (){
const fields=document.querySelectorAll('.ae-dropdown-field');
fields.forEach(field=> {
const select=field.querySelector('.ae-select');
const valueEl=field.querySelector('.ae-value');
const radios=field.querySelectorAll('input[type="radio"]');
if(!select) return;
select.addEventListener('click', function (e){
e.preventDefault();
e.stopPropagation();
fields.forEach(f=> f!==field&&f.classList.remove('is-open'));
field.classList.toggle('is-open');
});
radios.forEach(radio=> {
radio.addEventListener('change', function (){
const label=field.querySelector(`label[for="${radio.id}"]`);
if(label){
valueEl.textContent=label.textContent.trim();
}
field.classList.add('is-selected');
field.classList.remove('is-open');
});
});
});
document.addEventListener('click', function (){
fields.forEach(field=> field.classList.remove('is-open'));
});
});
document.addEventListener('DOMContentLoaded', ()=> {
const months=[
'januari','februari','maart','april','mei','juni',
'juli','augustus','september','oktober','november','december'
];
function initDateBlock(block, baseDate, isFrom=false){
const dayEl=block.querySelector('.day');
const monthEl=block.querySelector('.month');
const yearEl=block.querySelector('.year');
const today=new Date();
const startYear=today.getFullYear();
for (let y=startYear; y <=startYear + 3; y++){
yearEl.add(new Option(y, y));
}
months.forEach((m, i)=> {
monthEl.add(new Option(m, i + 1));
});
function updateDays(){
dayEl.innerHTML='';
const y=+yearEl.value;
const m=+monthEl.value;
const days=new Date(y, m, 0).getDate();
for (let d=1; d <=days; d++){
dayEl.add(new Option(d, d));
}
if(+dayEl.value > days) dayEl.value=days;
}
function autoFixPastMonth(){
if(!isFrom) return;
if(+yearEl.value===today.getFullYear() &&
+monthEl.value - 1 < today.getMonth()
){
yearEl.value=today.getFullYear() + 1;
}}
function setDate(date){
yearEl.value=date.getFullYear();
monthEl.value=date.getMonth() + 1;
updateDays();
dayEl.value=date.getDate();
}
yearEl.addEventListener('change', updateDays);
monthEl.addEventListener('change', ()=> {
autoFixPastMonth();
updateDays();
});
setDate(baseDate);
return {
getDate: ()=>
new Date(+yearEl.value, +monthEl.value - 1, +dayEl.value),
setDate
};}
const today=new Date();
const from=initDateBlock(
document.querySelector('.date-block.from'),
today,
true
);
const to=initDateBlock(
document.querySelector('.date-block.to'),
new Date(today.getTime() + 7 * 86400000)
);
function syncHidden(){
const f=from.getDate();
const t=to.getDate();
const fmt=d =>
d.getFullYear() + '-' +
String(d.getMonth()+1).padStart(2,'0') + '-' +
String(d.getDate()).padStart(2,'0');
document.getElementById('start_date').value=fmt(f);
document.getElementById('end_date').value=fmt(t);
}
document
.querySelectorAll('.date-block.from select')
.forEach(sel=> {
sel.addEventListener('change', ()=> {
const newTo=new Date(from.getDate().getTime() + 7 * 86400000);
to.setDate(newTo);
syncHidden();
});
});
document
.querySelectorAll('.date-block select')
.forEach(sel=> sel.addEventListener('change', syncHidden));
syncHidden();
const dateWrapper=document.querySelector('.vtype');
const dateSelects=document.querySelectorAll('.date-block select');
if(!dateWrapper||!dateSelects.length) return;
function updateDateSelectedState(){
let allFilled=true;
dateSelects.forEach(sel=> {
if(!sel.value||sel.value==='0'){
allFilled=false;
}});
if(allFilled){
dateWrapper.classList.add('is-selected');
}else{
dateWrapper.classList.remove('is-selected');
}}
dateSelects.forEach(sel=> {
sel.addEventListener('change', updateDateSelectedState);
});
updateDateSelectedState();
});
(function (){
'use strict';
function initSlider(slider){
if(!slider||slider.dataset.aeSliderInit==='1') return;
var track =
slider.querySelector('.VisvakantieCountrySlider__track') ||
slider.querySelector('[data-slider-track]');
var btnPrev =
slider.querySelector('.VisvakantieCountrySlider__btn--prev') ||
slider.querySelector('[data-slider-prev]');
var btnNext =
slider.querySelector('.VisvakantieCountrySlider__btn--next') ||
slider.querySelector('[data-slider-next]');
if(!track||!btnPrev||!btnNext) return;
var scrollAmount=280;
if(slider.classList.contains('VisvakantieTypeSlider') &&
window.matchMedia('(min-width: 769px)').matches
){
var slide=track.querySelector('.VisvakantieTypeSlider__slide');
if(slide){
var gap=parseInt(getComputedStyle(track).gap||0, 10);
scrollAmount=(slide.offsetWidth + gap) * 3;
}}
btnNext.addEventListener('click', function (){
track.scrollBy({ left: scrollAmount, behavior: 'smooth' });
});
btnPrev.addEventListener('click', function (){
track.scrollBy({ left: -scrollAmount, behavior: 'smooth' });
});
var isDragging=false;
var startX=0;
var startScrollLeft=0;
track.addEventListener('mousedown', function (e){
if(e.button!==0) return;
isDragging=true;
startX=e.pageX;
startScrollLeft=track.scrollLeft;
track.classList.add('is-dragging');
e.preventDefault();
});
track.addEventListener('mousemove', function (e){
if(!isDragging) return;
var delta=e.pageX - startX;
track.scrollLeft=startScrollLeft - delta;
});
track.addEventListener('mouseup', function (){
isDragging=false;
track.classList.remove('is-dragging');
});
track.addEventListener('mouseleave', function (){
isDragging=false;
track.classList.remove('is-dragging');
});
var touchStartX=0;
var touchScrollStart=0;
track.addEventListener('touchstart', function (e){
touchStartX=e.touches[0].pageX;
touchScrollStart=track.scrollLeft;
}, { passive: true });
track.addEventListener('touchmove', function (e){
var delta=e.touches[0].pageX - touchStartX;
track.scrollLeft=touchScrollStart - delta;
}, { passive: true });
slider.dataset.aeSliderInit='1';
}
function lazyInitSlider(slider){
if(!slider) return;
if(typeof IntersectionObserver==='undefined'){
initSlider(slider);
return;
}
var io=new IntersectionObserver(function (entries){
entries.forEach(function (entry){
if(entry.isIntersecting){
initSlider(entry.target);
io.unobserve(entry.target);
}});
}, {
rootMargin: '200px 0px',
threshold: 0,
});
io.observe(slider);
}
document.addEventListener('DOMContentLoaded', function (){
document.querySelectorAll('.VisvakantieCountrySlider').forEach(initSlider);
document.querySelectorAll('.VisvakantieTypeSlider').forEach(lazyInitSlider);
});
})();