(function(opts){ 'use strict'; var head = document.getElementsByTagName('head')[0], query = {}; if (location.search) { var items = location.search.substring(1).split('&'); for (var i = 0; i < items.length; i++) { var p = items[i].split('='); query[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); } } document.addEventListener("DOMContentLoaded", function() { var nodes = document.querySelectorAll('[data-crm-widget]'); for (var i = 0; i < nodes.length; i++) { renderWidget(nodes[i]); } }); function evalSnippets(widget) { var nodes = widget.querySelectorAll('script:not([src])'); for (var i = 0; i < nodes.length; i++) { eval(nodes[i].innerHTML); } } function renderWidget(widget) { var name = widget.getAttribute('data-crm-widget'); if (name in opts.except) return; query['r'] = '/' + name; var queryStr = Object.keys(query).map(function(k) { return k + '=' + encodeURIComponent(query[k]); }).join('&'); var request = new XMLHttpRequest(); request.open('GET', opts.sn + '?' + queryStr, true); request.setRequestHeader("X-Requested-With", "XMLHttpRequest"); request.onload = function() { if (request.status == 200) { widget.innerHTML = this.responseText; var scripts = widget.querySelectorAll('script[src]'); var k = 0; if (scripts.length) { for (var i = 0; i < scripts.length; i++) { var script = document.createElement('script'); script.src = scripts[i].getAttribute('src'); script.async = false; script.onload = function() { if (scripts.length == ++k) { evalSnippets(widget); } }; head.appendChild(script); } } else { evalSnippets(widget); } } }; request.send(); }})({"sn":"\/wp-content\/special\/proxy_order.php","query":[],"except":{"termsPopup":1}}); (function(content, cookieName){/** * Exit popup * This file loaded from ExitPopup widget */ window.addEventListener("load", function() { var popupWrapper = document.createElement('div'); popupWrapper.innerHTML = content; document.querySelector('body').appendChild(popupWrapper); var container = document.querySelector('#of-popup-container'), overlay = container.querySelector('.of-popup-overlay'), offerPopup = container.querySelector('.of-special-offer-popup'), thankYouPopup = container.querySelector('.of-thank-you-popup'), form = container.querySelector('form'), error = form.querySelector('.of-email-error'), sendButton = container.querySelector('button.of-offer-btn'), emailInput = container.querySelector('input.of-offer-email'); document.body.onmouseleave = function(e) { if (e.clientY < 10) { updateState(); } }; emailInput.onclick = function() { analytics(function() { ga('send', 'event', 'popup', 'field_email', document.URL, {'nonInteraction': 1}); }); }; emailInput.onfocus = function() { this.className = 'of-offer-email'; }; sendButton.onclick = function() { analytics(function() { ga('send', 'event', 'popup', 'button_send_mail', document.URL, {'nonInteraction': 1}); }); }; var disablePopup = function() { if (document.cookie.indexOf(cookieName) == -1) { document.cookie = cookieName + '=1'; } updateState(); }; // Hide offerPopup & overlay when clicked close button container.querySelectorAll('.of-close-btn')[0].onclick = disablePopup; container.querySelectorAll('.of-close-btn')[1].onclick = disablePopup; // Hide popupOverlay & popups overlay.onclick = disablePopup; // Update popup state function updateState() { if (document.cookie.indexOf(cookieName) >= 0) { offerPopup.style.display = 'none'; overlay.style.display = 'none'; thankYouPopup.style.display = 'none'; } else { overlay.style.display = 'block'; offerPopup.style.display = 'block'; emailInput.focus(); analytics(function() { ga('send', 'event', 'popup', 'view_popup', document.URL, {'nonInteraction': 1}); }); } } form.onsubmit = function(e) { e.preventDefault(); var request = new XMLHttpRequest(); request.open('POST', this.getAttribute('action'), true); request.onload = function() { if (request.status == 200) { var data = JSON.parse(request.responseText); if (data.error) { emailInput.className += ' has-error'; } else { offerPopup.style.display = 'none'; thankYouPopup.style.display = 'block'; var date = new Date(new Date().getTime() + (60 * 1000 * 60 * 24 * 365 /* year */)); document.cookie = cookieName + '=1; expires=' + date.toUTCString(); analytics(function() { ga('send', 'event', 'popup', 'thank_you', document.URL); }); } } }; request.send(new FormData(this)); }; function analytics(callback) { if (typeof(ga) === 'undefined') { console.log('ga is not defined.'); } else { callback(); } } });})("