Untitled

 avatar
unknown
plain_text
a year ago
4.0 kB
5
Indexable
<script>
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    var waitForElement = function (selector, trigger, delayInterval, delayTimeout) {
      var interval = setInterval(function () {
        if (
          document &&
          document.querySelector(selector) &&
          document.querySelectorAll(selector).length > 0
        ) {
          clearInterval(interval);
          trigger();
        }
      }, delayInterval);
      setTimeout(function () {
        clearInterval(interval);
      }, delayTimeout);
    }

    var live = function (selector, event, callback, context) {
      function addEvent(el, type, handler) {
        if (el.attachEvent) el.attachEvent('on' + type, handler);
        else el.addEventListener(type, handler);
      }
      this.Element &&
        (function (ElementPrototype) {
          ElementPrototype.matches =
            ElementPrototype.matches ||
            ElementPrototype.matchesSelector ||
            ElementPrototype.webkitMatchesSelector ||
            ElementPrototype.msMatchesSelector ||
            function (selector) {
              var node = this,
                nodes = (node.parentNode || node.document).querySelectorAll(selector),
                i = -1;
              while (nodes[++i] && nodes[i] != node);
              return !!nodes[i];
            };
        })(Element.prototype);
      function live(selector, event, callback, context) {
        addEvent(context || document, event, function (e) {
          var found,
            el = e.target || e.srcElement;
          while (el && el.matches && el !== context && !(found = el.matches(selector))) el = el.parentElement;
          if (found) callback.call(el, e);
        });
      }
      live(selector, event, callback, context);
    };

    live('.eg-side_bar', 'click', function () {
      document.body.classList.toggle('eg-show_popup')
    });

    live('.eg-popup #camp_popup_close', 'click', function () {
      document.body.classList.remove('eg-show_popup');
    })

    var sidepopup = '<button class="eg-side_bar" type="button" tabindex="0" style="z-index: 49;position: fixed;bottom: 0;right: 0px;width: 100px;margin: 0px;"><div style="height: 100%; width: 100%;"><span style="overflow: hidden;clip-path: polygon(100% 100%, 100% 0, 0 100%);display: block;"><div style="height: 85px;width: 100.208px;t;transform: rotate(0deg);ransform-origin: left top;background-color: #f1d27a;"><div style="padding-bottom: 8px; padding-top: 55px;transform: rotate(-39deg);"><div style="width: 100%;"><p style="text-align: center; font-size: 27px; line-height: 20px; font-family: ITCGaramondStd-LtCond; font-weight: 400; font-style: normal;"><span  style=" font-size: 27px; line-height: 20px; font-family: ITCGaramondStd-LtCond; font-weight: 600; font-style: normal;">10% Off </span></p></div></div></div></span></div></button><div class="eg-popup"></div>';

    /* Variation Init */
    var init = function () {
      if (!document.querySelector('.eg-side_bar')) {
        document.body.insertAdjacentHTML('beforeend', sidepopup);
        if (document.querySelector('#doormatt')) {
          document.querySelector('.eg-popup').insertAdjacentElement('beforeend', document.querySelector('html body #doormatt '))
        }
      }

      document.body.addEventListener('click', function (event) {
        var sidebar = document.querySelector('#doormatt .popup');
        if (sidebar && !sidebar.contains(event.target)) {
          document.body.classList.remove('eg-show_popup');
        }
      });
    }

    /* Initialize variation */
    waitForElement('html body #doormatt', init, 50, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();






  </script>
<style>
html body .eg-popup {
    display: none;
}
button.eg-side_bar.hide {
    display: none !important;
}
.eg-show_popup .eg-popup {
    display: block !important;
}


</style>
Editor is loading...
Leave a Comment