(function (){
'use strict';
function fixHeroHeight(){
var hero=document.querySelector('.er-hero-cover');
var header=document.querySelector('.er-site-header');
if(! header) return;
document.documentElement.style.setProperty('--er-header-height', header.offsetHeight + 'px'
);
if(! hero) return;
hero.style.minHeight='calc(100vh - ' + header.offsetHeight + 'px)';
}
(function (){
var bar=document.querySelector('.er-subnav-bar');
if(bar&&bar.parentElement){
bar.parentElement.classList.add('er-subnav-wrapper');
}}());
fixHeroHeight();
window.addEventListener('resize', fixHeroHeight);
}());
(function (){
'use strict';
var SLIDE_DURATION=400;
function cleanWpInlineOverrides(links){
links.forEach(function(link){
link.style.removeProperty('text-decoration');
link.style.removeProperty('text-underline-offset');
link.style.removeProperty('font-weight');
link.style.removeProperty('color');
});
}
function staggerLinks(links){
links.forEach(function(link, i){
link.style.transitionDelay=(i * 0.07) + 's';
link.classList.add('er-stagger-visible');
});
}
function resetLinks(links){
links.forEach(function(link){
link.classList.remove('er-stagger-visible');
link.style.removeProperty('transition-delay');
});
}
function injectContactLinks(container){
if(container.querySelector('.er-overlay-contact') ) return;
var navContent=container.querySelector('.wp-block-navigation__responsive-container-content'
);
if(! navContent) return;
var wrap=document.createElement('div');
wrap.className='er-overlay-contact';
wrap.innerHTML =
'<a href="tel:+442036030231" class="er-overlay-contact__link" aria-label="Call us">' +
'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>' +
'</svg>' +
'</a>' +
'<a href="mailto:hello@eyerevolution.co.uk" class="er-overlay-contact__link" aria-label="Email us">' +
'<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">' +
'<rect x="2" y="4" width="20" height="16" rx="2"/>' +
'<path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/>' +
'</svg>' +
'</a>';
navContent.appendChild(wrap);
}
function init(){
var header=document.querySelector('.er-site-header');
if(! header) return;
var slideTimer=null;
var observer=new MutationObserver(function(mutations){
mutations.forEach(function(mutation){
var target=mutation.target;
if(! target.classList.contains('wp-block-navigation__responsive-container') ) return;
var links=target.querySelectorAll('.wp-block-navigation-item__content, .wp-block-pages-list__item__link'
);
if(target.classList.contains('is-menu-open') ){
if(slideTimer){
clearTimeout(slideTimer);
slideTimer=null;
}
injectContactLinks(target);
cleanWpInlineOverrides(links);
slideTimer=setTimeout(function (){
cleanWpInlineOverrides(links);
staggerLinks(links);
var contactWrap=target.querySelector('.er-overlay-contact');
if(contactWrap){
contactWrap.style.transitionDelay=(links.length * 0.07 + 0.05) + 's';
contactWrap.classList.add('er-stagger-visible');
}
slideTimer=null;
}, SLIDE_DURATION - 20);
}else{
if(slideTimer){
clearTimeout(slideTimer);
slideTimer=null;
}
resetLinks(links);
var contactWrap=target.querySelector('.er-overlay-contact');
if(contactWrap){
contactWrap.classList.remove('er-stagger-visible');
contactWrap.style.removeProperty('transition-delay');
}
target.style.cssText='';
}});
});
header.querySelectorAll('.wp-block-navigation__responsive-container').forEach(function(container){
observer.observe(container, { attributes: true, attributeFilter: [ 'class' ] });
});
}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', init);
}else{
init();
}}());