Untitled
unknown
plain_text
a year ago
12 kB
4
Indexable
(function () { try { /* main variables */ var debug = 0; var variation_name = ""; var $; /* 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 (el && found) callback.call(el, e); }); } live(selector, event, callback, context); } var couponDivHTML = ` <div class="eg-new-form_container"> <div class="eg-commerce-form-coupon_toggle"> <div class="eg-message_wrapper"> Have a coupon? <a class="eg-showcoupon">Click here to enter your code</a> </div> </div> <ul class="eg-commerce_error"> <li> <div class="eg-message_container"> <span class="eg-message_icon eg-icon_close"></span> Coupon is Invalid! </div> </li> </ul> <div class="eg-checkout eg-commerce_checkout"> <p>If you have a coupon code, please apply it below.</p> <div class="eg-coupon"> <div> <div class="eg-search_box"> <label for="coupon_code" class="eg-search-box_text">Coupon:</label> <input type="text" name="coupon_code" class="eg-input_text" placeholder="Coupon code" id="eg-coupon_code" value="" fdprocessedid="zcztr"> </div> <div class="eg-button"> <button type="button" class="button expand" name="apply_coupon" value="Apply coupon" fdprocessedid="skpvaq">Apply coupon</button> </div> </div> </div> </div> </div> `; /* Variation Init */ function init() { var cartSubtotal = document.querySelector('#order_review > .shop_table .cart-subtotal'); var woocommerceInfo = document.querySelector('html body .woocommerce-info'); // var checkoutCoupon = document.querySelector('html body .checkout_coupon'); if (cartSubtotal && woocommerceInfo && !document.querySelector('.eg-new-tr')) { cartSubtotal.insertAdjacentHTML('afterend', `<tr class="eg-new-tr"><td colspan="2">${couponDivHTML}</td></tr>`); } } function monitorRequest() { const send = XMLHttpRequest.prototype.send XMLHttpRequest.prototype.send = function () { this.addEventListener('load', function () { if (this.responseURL.indexOf('?wc-ajax') !== -1) { waitForElement('#order_review > .shop_table .cart-subtotal', init, 50, 15000); if (this.responseURL.indexOf('wc-ajax=apply_coupon') !== -1) { const el = document.createElement('div'); el.innerHTML = this.response; waitForElement('.eg-new-form_container', function () { const formEl = document.querySelector('.eg-new-form_container'); if (el.querySelector('.woocommerce-error')) { formEl.classList.add('eg-has-err'); } else { formEl.classList.remove('eg-has-err'); } formEl.querySelector('.eg-commerce_error .eg-message_container').innerHTML = el.innerText.trim(); }, 50, 15000); } } }) return send.apply(this, arguments) } } function testEvents() { if (!document.querySelector('.eg-events-added')) { document.body.classList.add('eg-events-added'); live('html body .eg-new-form_container .eg-message_wrapper>.eg-showcoupon', 'click', function () { document.querySelector('html body .eg-new-form_container').classList.toggle('eg-open-form'); }); live('html body .eg-new-form_container .eg-commerce_checkout .eg-button>button', 'click', function () { waitForElement('html body #coupon_code', function () { const cpnFrmNew = document.querySelector('html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-input_text'); const oriCouponEl = document.querySelector('html body #coupon_code'); oriCouponEl.value = cpnFrmNew.value; oriCouponEl.dispatchEvent(new Event('input')); oriCouponEl.closest('form').querySelector('button[type="submit"]').click(); }, 1, 15000); }); } } waitForElement('body', function () { monitorRequest(); testEvents(); waitForElement('#order_review > .shop_table .cart-subtotal', init, 50, 15000); }, 50, 15000); } catch (e) { if (debug) console.log(e, "error in Test" + variation_name); } })(); html body .eg-new-form_container .eg-message_wrapper { text-align: left; font-size: 100% !important; line-height: 1.3; font-family: "PT Sans", sans-serif; color: #000000; } html body .eg-new-form_container .eg-message_wrapper>.eg-showcoupon { color: #3d9cd2; background-color: transparent; text-align: left; font-size: 100% !important; line-height: 1.3; font-family: "PT Sans", sans-serif; cursor: pointer !important; } html body .eg-new-form_container .eg-message_wrapper>.eg-showcoupon:hover { outline: none; text-decoration: none; transition: all 0.3s ease 0s; color: #000000 !important; } html body .eg-new-form_container .eg-commerce_error { margin: 0; text-align: center; margin-top: 0.5em !important; } html body .eg-new-form_container:not(.eg-has-err) .eg-commerce_error { display: none !important; } html body .eg-new-form_container .eg-commerce_error>li { margin-bottom: 0.6em; list-style: none !important; } html body .eg-new-form_container .eg-commerce_error .eg-message_container { color: #b20000 !important; font-family: "PT Sans", sans-serif; font-weight: 400; font-style: normal; } html body .eg-new-form_container .eg-commerce_checkout { border: 2px solid #396daf; padding: 30px; border-style: dashed; min-height: 0 !important; transition: min-height 0.5s ease-in-out, max-height 0.2s linear; margin-top: 0.5em !important; } html body .eg-new-form_container { margin-top: 10px !important; margin-bottom: 1.3em !important; } html body .eg-new-form_container .eg-commerce_checkout>p { margin-bottom: 0.5em; margin-top: 0px !important; text-align: left; color: #000000 !important; } html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon>div { align-items: center; display: flex; flex-flow: row nowrap; justify-content: space-between; width: 100%; } html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon .eg-search_box { flex: 1; } html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-search-box_text { clip: rect(1px, 1px, 1px, 1px); height: 1px; overflow: hidden; position: absolute !important; width: 1px; clip-path: inset(50%); margin: -1px; padding: 0; word-wrap: normal !important; border: 0; } html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-input_text { appearance: none; background-color: #fff; border: 1px solid #ddd; border-radius: 0; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); box-sizing: border-box; color: #333; font-size: .97em; height: 2.507em; max-width: 100%; padding: 0 0.75em; transition: color .3s, border .3s, background .3s, opacity .3s; vertical-align: middle; width: 100%; font-family: "Open Sans", sans-serif; margin: 0px !important; } html body .eg-new-form_container .eg-commerce_checkout .eg-button>button { display: block; max-width: 100% !important; width: 100% !important; background-color: #396daf; border-color: rgba(0, 0, 0, .05); color: #fff; font-size: 18px !important; font-family: 'Roboto', sans-serif; padding: 9px 15px !important; min-height: inherit !important; line-height: inherit !important; margin: 0px !important; } html body .woocommerce-form-coupon-toggle, html body .woocommerce-form-coupon-toggle+.checkout_coupon { display: none !important; } html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-input_text:focus { background-color: #fff; box-shadow: 0 0 5px #ccc !important; color: #333; opacity: 1 !important; } html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-input_text:hover { box-shadow: inset 0 -1.8em 1em 0 transparent; } html body .eg-new-form_container:not(.eg-open-form) .eg-commerce_checkout { max-height: 0px !important; overflow: hidden !important; padding: 0 !important; border: 0 !important; margin: 0 !important; } html body .eg-new-form_container.eg-open-form .eg-commerce_checkout { min-height: 132.11px !important; max-height: 212px !important; } html body .eg-new-form_container:not(.eg-open-form) { margin-bottom: 10px !important; } html body .eg-new-form_container:not(.eg-open-form) .eg-commerce_checkout * { opacity: 0 !important; } @media only screen and (max-width:1024px) { html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon .eg-search_box { flex: 1; flex-grow: 0; padding-bottom: 5px; padding-top: 5px; width: 100%; } html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon>div { flex-flow: column wrap; } html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon .eg-search_box { flex: 1; flex-grow: 0; padding-bottom: 10px; padding-top: 5px; width: 100%; } html body .eg-new-form_container .eg-commerce_checkout>.eg-coupon .eg-button { width: 100% !important; } html body .eg-new-form_container .eg-message_wrapper { text-align: center; } html body .eg-new-form_container .eg-commerce_checkout .eg-search_box>.eg-input_text { height: 3.2em !important; } }
Editor is loading...
Leave a Comment