`; } }) .catch(error => { console.error(« Submission failed », error); submitBtn.disabled = false; }); }); } function updateBannerPosition() { if (!banner || !bannerVisible) return; const topObstacles = [
document.querySelector(‘.dfp-leaderboard-container [style*= »position: fixed »]'), document.querySelector('.dfp-leaderboard-container [id^= »bordeaux-ad-« ]'), document.querySelector('.dfp-leaderboard-container'), document.querySelector('[data-component-name= »SiteHeader:Masthead »]'), document.querySelector('nav.primary-nav'), document.querySelector('.navigation__container') ]; laissez maxBottomOffset = 0 ; topObstacles.forEach(el => { if (el) { const rect = el.getBoundingClientRect(); const style = window.getComputedStyle(el); const isVisible = style.display !== 'none' && style.visibility !== 'hidden'; if (isVisible && rect.height > 0 && rect.bottom > 0 && rect.top < 300) { maxBottomOffset = Math.max(maxBottomOffset, rect.bottom } } }); bannière.style.top = `${Math.max(0, maxBottomOffset)}px`; bannière.style.marginTop = '0px'; } const triggerInstantUpdate = () => { if (bannerVisible) { window.requestAnimationFrame(updateBannerPosition); } } ; const adContainer = document.querySelector('.dfp-leaderboard-container'); const headerContainer = document.querySelector('[data-component-name= »SiteHeader:Masthead »]'); if (adContainer || headerContainer) { const instantObserver = new MutationObserver (triggerInstantUpdate); const observerConfig = { childList : vrai, sous-arbre : vrai, attributs : vrai, attributFilter : [‘style’, ‘class’]
} ; if (adContainer) instantObserver.observe(adContainer, observerConfig); if (headerContainer) instantObserver.observe(headerContainer, observerConfig); } const resizeObserver = new ResizeObserver(triggerInstantUpdate); resizeObserver.observer(document.body); resizeObserver.observer(document.documentElement); function showBanner() { if (window.scrollY < 100) return ; const heroComponent = document.getElementById('full-bleed-hero'); if (heroComponent && heroComponent.getBoundingClientRect().bottom > 0) return; if(typeof ffte !== 'undefined' && ffte?.properties?.articleType === 'deals') return; if (!bannerDismissed && !isAuthKiosq && !isAuthConnect) { if(window.dispatchOrQueueAction) { window.dispatchOrQueueAction('freyr.sendEventToFreyr', { nom : 'membershipEvent', eventObject : { adhésion : { action : « scroll-page », label : « membership-banner », tapez : « banner-sticky » } } }); } const bgImg = document.getElementById('skinnyBannerBgImg'); if (bgImg && !bgImg.getAttribute('src')) { if (bgImg.getAttribute('data-srcset')) bgImg.setAttribute('srcset', bgImg.getAttribute('data-srcset')); bgImg.setAttribute('src', bgImg.getAttribute('data-src')); } bannière.classList.add('show'); document.body.classList.add('banner-visible'); bannièreVisible = vrai ; updateBannerPosition(); } } function hideBanner() { if (isInputFocused) return ; bannière.classList.remove('show'); bannièreVisible = faux ; bannièreExpansée = faux ; bannière.classList.remove('expanded'); document.body.classList.remove('banner-expanded'); bannière.style.top = ''; bannière.style.marginTop = ''; } function toggleBanner() { if (bannerDismissed) return ; bannièreExpansive = !bannerExtension; bannière.classList.toggle('expanded', bannièreExpansée); document.body.classList.toggle('banner-expanded', bannièreExpanded); if (bannerExpanded && window.dispatchOrQueueAction) { window.dispatchOrQueueAction('freyr.sendEventToFreyr', { nom : 'membershipEvent', eventObject : { adhésion : { action : « click-banner », label : « membership-banner », type : « banner-sticky » } } }); } } window.addEventListener('scroll', () => { const heroComponent = document.getElementById('full-bleed-hero'); const isHeroVisible = heroComponent && heroComponent.getBoundingClientRect().bottom > 0; if (isHeroVisible || window.scrollY < 100) { if (!isInputFocused) hideBanner(); } else { if (!bannerVisible) showBanner(); } if (bannerVisible) triggerInstantUpdate(); window.addEventListener('resize', triggerInstantUpdate, { passive: true }); document.addEventListener('click', function (event) { if (!banner) return; if (!banner.contains(event.target) && banner.classList.contains('expanded') && document.body.classList.contains('banner-expanded')) { toggleBanner(); } }); if (bannerHeader) bannerHeader.addEventListener('clic', toggleBanner); if (joinNowBtn) joinNowBtn.addEventListener('click', e => { e.stopPropagation(); window.location.href = « https://www.gardeningknowhow.com/membership »; }); });