(function () { 'use strict'; var popupEl = null; var autoCloseTimer = null; var popupBound = false; function createPopup() { if (popupEl) { return popupEl; } popupEl = document.createElement('div'); popupEl.className = 'eventup-marketing-popup'; popupEl.setAttribute('data-marketing-popup', ''); popupEl.setAttribute('role', 'dialog'); popupEl.setAttribute('aria-modal', 'true'); popupEl.setAttribute('aria-hidden', 'true'); popupEl.innerHTML = '
' + '
' + '

Introducing

' + '
' + '' + '' + '
' + '
'; document.body.appendChild(popupEl); bindPopupEvents(popupEl); return popupEl; } function bindPopupEvents(popup) { if (!popup || popupBound) { return; } popupBound = true; var closeBtn = popup.querySelector('[data-marketing-close]'); if (closeBtn) { closeBtn.addEventListener('click', hidePopup); } popup.addEventListener('click', function (event) { if (event.target === popup.querySelector('.eventup-marketing-popup__backdrop')) { hidePopup(); } }); document.addEventListener('keydown', function (event) { if (event.key === 'Escape' && popupEl && popupEl.classList.contains('is-visible')) { hidePopup(); } }); } function hidePreloader() { var preloader = document.getElementById('preloader'); if (!preloader) { return; } preloader.style.display = 'none'; preloader.style.visibility = 'hidden'; preloader.style.opacity = '0'; } function hidePopup() { if (!popupEl) { return; } if (autoCloseTimer) { window.clearTimeout(autoCloseTimer); autoCloseTimer = null; } popupEl.classList.remove('is-visible'); popupEl.setAttribute('aria-hidden', 'true'); document.body.classList.remove('eventup-marketing-popup-open'); window.setTimeout(function () { if (popupEl) { popupEl.style.display = 'none'; } }, 400); } function showPopup(config) { var popup = createPopup(); var heading = popup.querySelector('[data-marketing-heading]'); var logo = popup.querySelector('[data-marketing-logo]'); var logoConfig = (config && config.logo) || {}; var autoCloseMs = config && config.autoCloseDuration != null ? Number(config.autoCloseDuration) : 3000; if (heading) { heading.textContent = (config && config.heading) || 'Introducing'; } if (logo) { logo.src = logoConfig.url || 'assets/img/novel-logo.png'; logo.alt = logoConfig.alt || 'NOVEL'; } hidePreloader(); popup.style.display = 'flex'; popup.setAttribute('aria-hidden', 'false'); document.body.classList.add('eventup-marketing-popup-open'); window.requestAnimationFrame(function () { popup.classList.add('is-visible'); markShown(); }); if (autoCloseTimer) { window.clearTimeout(autoCloseTimer); } if (autoCloseMs > 0) { autoCloseTimer = window.setTimeout(hidePopup, autoCloseMs); } } function shouldShow(config) { if (!config || config.show === false) { return false; } if (config.showOncePerSession !== false) { try { if (window.sessionStorage.getItem('eventup-marketing-popup-v2') === '1') { return false; } } catch (error) { /* ignore */ } } return true; } function markShown() { try { window.sessionStorage.setItem('eventup-marketing-popup-v2', '1'); } catch (error) { /* ignore */ } } function init(config) { if (!shouldShow(config)) { if (popupEl) { popupEl.style.display = 'none'; } return; } function launch() { window.setTimeout(function () { showPopup(config); }, 150); } if (document.readyState === 'complete') { launch(); } else { window.addEventListener('load', launch); } } window.EventUpMarketingPopup = { init: init, show: showPopup, hide: hidePopup }; })();