Gratis verzending CE-gecertificeerd 3 jaar garantie

Tesla Model S laadkabel

(function () { // ========================= // INSTELLINGEN // ========================= const POPUP_DELAY = 1500; const STORAGE_KEY = 'mcc_newsletter_popup_closed_v1'; const STORAGE_SUBMITTED_KEY = 'mcc_newsletter_popup_submitted_v1'; // VUL HIER JE ECHTE NIEUWSBRIEF ENDPOINT IN const NEWSLETTER_ACTION_URL = 'https://JOUW-NIEUWSBRIEF-URL-HIER'; const NEWSLETTER_METHOD = 'POST'; const EXCLUDED_PATHS = [ '/checkout', '/account', '/service', '/cart' ]; // ========================= // HELPERS // ========================= function isExcludedPath() { const path = window.location.pathname.toLowerCase(); return EXCLUDED_PATHS.some(function (item) { return path.indexOf(item) === 0; }); } function hasClosedPopup() { return localStorage.getItem(STORAGE_KEY) === '1'; } function hasSubmittedPopup() { return localStorage.getItem(STORAGE_SUBMITTED_KEY) === '1'; } function closePopup() { const overlay = document.getElementById('mcc-newsletter-overlay'); if (overlay) { overlay.classList.remove('is-visible'); } localStorage.setItem(STORAGE_KEY, '1'); } function showPopup() { const overlay = document.getElementById('mcc-newsletter-overlay'); if (overlay) { overlay.classList.add('is-visible'); } } function injectStyles() { if (document.getElementById('mcc-newsletter-styles')) return; const css = ` #mcc-newsletter-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease; } #mcc-newsletter-overlay.is-visible { opacity: 1; visibility: visible; } .mcc-newsletter-modal { position: relative; width: 100%; max-width: 540px; background: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,.25); font-family: inherit; } .mcc-newsletter-topbar { background: #111111; color: #ffffff; text-align: center; font-size: 15px; font-weight: 700; padding: 12px 16px; letter-spacing: .2px; } .mcc-newsletter-body { padding: 32px 28px 28px; } .mcc-newsletter-close { position: absolute; top: 10px; right: 12px; width: 38px; height: 38px; border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: #444; } .mcc-newsletter-title { margin: 0 0 10px; font-size: 30px; line-height: 1.15; color: #111; font-weight: 800; } .mcc-newsletter-text { margin: 0 0 20px; font-size: 16px; line-height: 1.6; color: #333; } .mcc-newsletter-highlight { font-weight: 700; } .mcc-newsletter-discount { display: block; text-align: center; font-size: 36px; font-weight: 900; margin-top: 6px; color: #e60023; } .mcc-newsletter-form { display: flex; flex-direction: column; gap: 12px; } .mcc-newsletter-input { width: 100%; height: 52px; border: 1px solid #d8d8d8; border-radius: 10px; padding: 0 16px; font-size: 16px; outline: none; box-sizing: border-box; } .mcc-newsletter-input:focus { border-color: #111; } .mcc-newsletter-button { width: 100%; height: 52px; border: 0; border-radius: 10px; background: #111111; color: #ffffff; font-size: 16px; font-weight: 700; cursor: pointer; } .mcc-newsletter-button:hover { opacity: .92; } .mcc-newsletter-note { margin-top: 12px; font-size: 12px; line-height: 1.5; color: #666; } .mcc-newsletter-success, .mcc-newsletter-error { margin-top: 12px; font-size: 14px; line-height: 1.5; display: none; } .mcc-newsletter-success { color: #0a7a2f; } .mcc-newsletter-error { color: #b42318; } @media (max-width: 640px) { .mcc-newsletter-body { padding: 26px 18px 22px; } .mcc-newsletter-title { font-size: 24px; } .mcc-newsletter-discount { font-size: 30px; } } `; const style = document.createElement('style'); style.id = 'mcc-newsletter-styles'; style.innerHTML = css; document.head.appendChild(style); } function injectMarkup() { if (document.getElementById('mcc-newsletter-overlay')) return; const html = ` `; document.body.insertAdjacentHTML('beforeend', html); const overlay = document.getElementById('mcc-newsletter-overlay'); const closeBtn = overlay.querySelector('.mcc-newsletter-close'); closeBtn.addEventListener('click', closePopup); overlay.addEventListener('click', function (e) { if (e.target === overlay) { closePopup(); } }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && overlay.classList.contains('is-visible')) { closePopup(); } }); } function bindForm() { const form = document.getElementById('mcc-newsletter-form'); const success = document.getElementById('mcc-newsletter-success'); const error = document.getElementById('mcc-newsletter-error'); if (!form) return; form.addEventListener('submit', function (e) { e.preventDefault(); success.style.display = 'none'; error.style.display = 'none'; const emailInput = form.querySelector('input[name="email"]'); const email = emailInput.value.trim(); if (!email) return; if (!NEWSLETTER_ACTION_URL || NEWSLETTER_ACTION_URL.indexOf('JOUW-NIEUWSBRIEF-URL-HIER') !== -1) { success.style.display = 'block'; localStorage.setItem(STORAGE_SUBMITTED_KEY, '1'); localStorage.setItem(STORAGE_KEY, '1'); setTimeout(function () { closePopup(); }, 1200); return; } const formData = new FormData(); formData.append('email', email); fetch(NEWSLETTER_ACTION_URL, { method: NEWSLETTER_METHOD, body: formData, mode: 'cors' }) .then(function (response) { if (!response.ok) throw new Error('Network error'); success.style.display = 'block'; localStorage.setItem(STORAGE_SUBMITTED_KEY, '1'); localStorage.setItem(STORAGE_KEY, '1'); setTimeout(function () { closePopup(); }, 1200); }) .catch(function () { error.style.display = 'block'; }); }); } function initPopup() { if (isExcludedPath()) return; if (hasClosedPopup() || hasSubmittedPopup()) return; injectStyles(); injectMarkup(); bindForm(); window.setTimeout(showPopup, POPUP_DELAY); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initPopup); } else { initPopup(); } })();