(function () { var id = '5723567975038976'; var lastShownStorageKey = 'lumifish-pop-up.appspot.com.' + id + '.lastShown'; var mobile = window.matchMedia("only screen and (max-width: 600px)").matches; if (sessionStorage && sessionStorage.getItem(lastShownStorageKey)) { return; } var mobileSettings = {"appearsAfter":"2","show":"always","disappearsAfter":0,"enabled":false}; var desktopSettings = {"appearsAfter":0,"show":"always","enabled":false,"disappearsAfter":0}; var settings = mobile ? mobileSettings : desktopSettings; if (!settings.enabled === true) { return; } var localStorageSupported = { get: function () { var test = 'test'; try { localStorage.setItem(test, test); localStorage.removeItem(test); return true; } catch (e) { return false; } } }; if (localStorageSupported) { var updatedAt = new Date('2018-01-11T11:21:28.775Z'); var lastShown = new Date(localStorage.getItem(lastShownStorageKey)); var now = new Date(); var shownDaysAgo = getDays(now) - getDays(lastShown); function getDays(date) { return date.getTime() / (1000 * 60 * 60 * 24); } if (settings.show === 'onceAfterEdit' && lastShown > updatedAt) { return; } if (settings.show === 'oncePerWeek' && shownDaysAgo < 7) { return; } if (settings.show === 'oncePerMonth' && shownDaysAgo < 30) { return; } } var totalSheets = 3; function loadStylesheet(url, callback) { var script = document.createElement('link'); script.type = 'text/css'; script.rel = 'stylesheet'; script.onload = function () { totalSheets--; if (callback && totalSheets === 0) { callback(); } }; script.href = url; document.getElementsByTagName('head')[0].appendChild(script); }; loadStylesheet('https://lumifish-pop-up.appspot.com/stylesheets/modal.css', renderPopup); loadStylesheet('https://lumifish-pop-up.appspot.com/stylesheets/popup.css', renderPopup); loadStylesheet('https://fonts.googleapis.com/css?family=Arima+Madurai|Cormorant+Garamond|Cormorant+Upright|Cuprum|Dosis|Halant|Kalam|Laila|Lekton|Nunito|Open+Sans:400,700|Raleway|Roboto|Roboto+Slab|Ubuntu', renderPopup); function renderPopup() { var showTimeout = (settings.appearsAfter && settings.appearsAfter > 0) ? settings.appearsAfter * 1000 : 0; var hideTimeout = (settings.disappearsAfter && settings.disappearsAfter > 0) ? settings.disappearsAfter * 1000 : 0; setTimeout(render, showTimeout); function render() { var modal, span; function hide() { modal.style.display = 'none'; } function show() { modal.style.display = 'block'; } var desktopModalContent = '
×
'; var mobileModalContent = '
×
'; var modalContent = mobile ? mobileModalContent : desktopModalContent; document.body.insertAdjacentHTML('afterbegin', modalContent); modal = document.getElementById('lumifish-modal_' + id); span = modal.getElementsByClassName('lumifish-modal-close')[0]; hide(); // When the user clicks on (x), close the modal span.onclick = function () { hide(); }; // When the user clicks anywhere outside of the modal, close it window.onclick = function (event) { if (event.target === modal) { hide(); } }; if (localStorageSupported) { localStorage.setItem(lastShownStorageKey, new Date()); } if (sessionStorage) { sessionStorage.setItem(lastShownStorageKey, new Date()); } if (hideTimeout > 0) { setTimeout(hide, hideTimeout); } var imageUrls = Array.prototype.slice.call(document.querySelectorAll('#lumifish-modal_' + id + ' div[style*="background-image"]')).map(e => (/(?:\(['"]?)(.*?)(?:['"]?\))/).exec(e.style.backgroundImage)[1]); var waitFor = imageUrls.length; if (waitFor === 0) { show(); } else { var loaded = 0; imageUrls.forEach(url => { var img = new Image() img.src = url; img.onload = function () { loaded++; if (loaded === waitFor) { show(); } }; }) } } }; })();