Untitled
unknown
plain_text
a year ago
3.7 kB
4
Indexable
(function () { try { /* main variables */ var debug = 0; var variation_name = ""; /* all Pure helper functions */ function waitForElement(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); } function live(selector, event, callback, context) { /****Helper Functions****/ // helper for enabling IE 8 event bindings function addEvent(el, type, handler) { if (el.attachEvent) el.attachEvent("on" + type, handler); else el.addEventListener(type, handler); } // matches polyfill 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); // live binding helper using matchesSelector 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); } var egHeroText = `<h2 class="eg-heading">Fired Up For Fall</h2> <p class="eg-para">Hut hopping kits to bonfires and après firepit fits-get fired up for dropping temps and dropping in.</p> <div class="eg-button-container"> <a href="https://www.marmot.com/men/new-arrivals/" target="_self" class="eg-button btn large btn-black solid-fill">Shop Men</a> <a href="https://www.marmot.com/women/new-arrivals/" target="_self" class="eg-button btn large btn-black solid-fill">Shop Women</a> </div>`; function init() { document.querySelector('.storepage .experience-commerce_layouts-masonrybrick:nth-child(2) .col-lg-3.layout-region .text-container').innerHTML = egHeroText; window.addEventListener('scroll', () => { if(window.pageYOffset >= document.querySelector('body header.hasStickyNav').clientHeight){ document.body.classList.add('eg-sticky-element'); }else{ document.body.classList.remove('eg-sticky-element'); } }); live('.header-banner.header-row-brands button', 'click', function(){ document.body.classList.add('eg-no-banner'); }); } function noBanner(){ document.body.classList.add('eg-no-banner'); } /* Initialise variation */ waitForElement(".storepage .experience-commerce_layouts-masonrybrick:nth-child(2) .col-lg-3.layout-region .text-container", init, 100, 25000); waitForElement('.header-banner.header-row-brands.d-none',noBanner,50,10000); } catch (e) { if (debug) console.log(e, "error in Test" + variation_name); } })();
Editor is loading...