PluginProbe
seQura / 3.2.0
seQura v3.2.0
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / assets / js / dist / page / widget-facade.min.js

widget-facade.min.js in seQura 3.2.0, at assets/js/dist/page/widget-facade.min.js

2 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(t,r,n){return(r=function(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}document.addEventListener("DOMContentLoaded",(function(){SequraConfigParams&&SequraWidgetFacade&&(SequraWidgetFacade=a(a(a(a({},{widgets:[],miniWidgets:[]}),SequraConfigParams),SequraWidgetFacade),{mutationObserver:null,forcePriceSelector:!0,presets:{L:'{"alignment":"left"}',R:'{"alignment":"right"}',legacy:'{"type":"legacy"}',legacyL:'{"type":"legacy","alignment":"left"}',legacyR:'{"type":"legacy","alignment":"right"}',minimal:'{"type":"text","branding":"none","size":"S","starting-text":"as-low-as"}',minimalL:'{"type":"text","branding":"none","size":"S","starting-text":"as-low-as","alignment":"left"}',minimalR:'{"type":"text","branding":"none","size":"S","starting-text":"as-low-as","alignment":"right"}'},init:function(){var e=this,t=[];this.widgets.forEach((function(r){Object.keys(r).forEach((function(t){"string"==typeof r[t]&&(r[t]=e.decodeEntities(r[t]))})),t.some((function(e){return e.price_src===r.price_src&&e.dest===r.dest&&e.product===r.product&&e.theme===r.theme&&e.reverse===r.reverse&&e.campaign===r.campaign}))||t.push(r)})),this.widgets=t},getText:function(e){return e&&document.querySelector(e)?document.querySelector(e).textContent:"0"},nodeToCents:function(e){return this.textToCents(e?e.textContent:"0")},selectorToCents:function(e){return this.textToCents(this.getText(e))},decodeEntities:function(e){if(!e.match(/&(nbsp|amp|quot|lt|gt|#\d+|#x[0-9A-Fa-f]+);/g))return e;var t=document.createElement("div");return t.innerHTML=e,t.textContent},textToCents:function(e){var t=this.decodeEntities(this.thousandSeparator),r=this.decodeEntities(this.decimalSeparator);return(e=e.replace(/^\D*/,"").replace(/\D*$/,"")).indexOf(r)<0&&(e+=r+"00"),this.floatToCents(parseFloat(e.replace(t,"").replace(r,".")))},floatToCents:function(e){return parseInt(e.toFixed(2).replace(".",""),10)},refreshComponents:function(){Sequra.onLoad((function(){Sequra.refreshComponents()}))},isVariableProduct:function(e){return!!document.querySelector(e)},getPriceSelector:function(e){return!this.forcePriceSelector&&this.isVariableProduct(e.isVariableSel)?e.variationPriceSel:e.priceSel},getWidgetTargets:function(e,t,n){var i=[];if(t.dest){var o,a=e.querySelectorAll(t.dest),s="data-sequra-observed-"+t.product,u=r(a);try{for(u.s();!(o=u.n()).done;){var c=o.value;c.getAttribute(s)!=n&&(c.setAttribute(s,n),i.push({elem:c,widget:t}))}}catch(e){u.e(e)}finally{u.f()}}return i},getMiniWidgetTargets:function(e){var t=[];if(e.dest)for(var r=document.querySelectorAll(e.dest),n=document.querySelectorAll(e.priceSel),i="data-sequra-observed-price-"+e.product,o=0;o<r.length;o++){var a=r[o],s=void 0!==n[o]?n[o]:null,u=s?this.nodeToCents(s):null;null!==u&&a.getAttribute(i)!=u&&(a.setAttribute(i,u),t.push({elem:a,priceElem:s,widget:e}))}return t},getObservedAt:function(){return Date.now()},removeWidgetsOnPage:function(){this.mutationObserver&&this.mutationObserver.disconnect(),document.querySelectorAll(".sequra-promotion-widget").forEach((function(e){return e.remove()})),this.mutationObserver&&this.mutationObserver.observe(document,{childList:!0,subtree:!0})},refreshWidgets:function(){var e,n=this,i=[],o=r(this.widgets);try{for(o.s();!(e=o.n()).done;){var a=e.value,s=this.getWidgetTargets(document,a,this.getObservedAt());i.push.apply(i,t(s))}}catch(e){o.e(e)}finally{o.f()}var u,c=r(this.miniWidgets);try{for(c.s();!(u=c.n()).done;){var l=u.value,d=this.getMiniWidgetTargets(l);i.push.apply(i,t(d))}}catch(e){c.e(e)}finally{c.f()}i.forEach((function(e){var t=e.elem,r=e.widget;n.isMiniWidget(r)?n.drawMiniWidgetOnElement(r,t,e.priceElem):n.drawWidgetOnElement(r,t)}))},drawWidgetsOnPage:function(){var e=this,t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];(this.widgets.length||this.miniWidgets.length)&&(this.mutationObserver&&this.mutationObserver.disconnect(),this.forcePriceSelector=t,this.refreshWidgets(),this.mutationObserver=new MutationObserver((function(t){e.mutationObserver.disconnect();var n,i=r(t);try{for(i.s();!(n=i.n()).done;){var o=n.value;if(["childList","subtree","characterData"].includes(o.type)){e.refreshWidgets();break}}}catch(e){i.e(e)}finally{i.f()}e.mutationObserver.observe(document,{childList:!0,subtree:!0,characterData:!0})})),this.mutationObserver.observe(document,{childList:!0,subtree:!0,characterData:!0}))},isMiniWidget:function(e){return-1!==this.miniWidgets.indexOf(e)},drawMiniWidgetOnElement:function(e,t,r){if(!r){var n=this.getPriceSelector(e);if(!(r=document.querySelector(n)))return void console.error(n+" is not a valid css selector to read the price from, for seQura mini-widget.")}var i=this.nodeToCents(r),o="sequra-educational-popup",a=o+"--"+e.product,s=t.parentNode.querySelector("."+o+"."+a);if(s){if(i==s.getAttribute("data-amount"))return;s.remove()}if(!(e.maxAmount&&e.maxAmount<i)){var u=document.createElement("small");u.className=o+" "+a,u.setAttribute("data-amount",i),u.setAttribute("data-product",e.product);var c=Sequra.computeCreditAgreements({amount:i,product:e.product})[e.product],l=null;do{l=c.pop()}while(i<l.min_amount.value&&c.length>1);if(!(i<l.min_amount.value)||e.messageBelowLimit){if(i>=l.min_amount.value)u.innerText=e.message.replace("%s",l.instalment_total.string);else{if(!e.messageBelowLimit)return;u.innerText=e.messageBelowLimit.replace("%s",l.min_amount.string)}t.nextSibling?(t.parentNode.insertBefore(u,t.nextSibling),this.refreshComponents()):t.parentNode.appendChild(u)}}},drawWidgetOnElement:function(e,t){var r=this.getPriceSelector(e),n=document.querySelector(r);if(n){var i=this.nodeToCents(n),o="sequra-promotion-widget",a=o+"--"+e.product,s=t.parentNode.querySelector("."+o+"."+a);if(s){if(i==s.getAttribute("data-amount"))return;s.remove()}var u=document.createElement("div");u.className=o+" "+a,u.setAttribute("data-amount",i),u.setAttribute("data-product",e.product);var c=this.presets[e.theme]?this.presets[e.theme]:e.theme;try{var l=JSON.parse(c);for(var d in l)u.setAttribute("data-"+d,""+l[d])}catch(e){u.setAttribute("data-type","text")}e.campaign&&u.setAttribute("data-campaign",e.campaign),e.registrationAmount&&u.setAttribute("data-registration-amount",e.registrationAmount),t.nextSibling?(t.parentNode.insertBefore(u,t.nextSibling),this.refreshComponents()):t.parentNode.appendChild(u)}else console.error(r+" is not a valid css selector to read the price from, for seQura widget.")}}),SequraWidgetFacade.init(),Sequra.onLoad((function(){if(SequraWidgetFacade.drawWidgetsOnPage(),"undefined"!=typeof jQuery){var e=jQuery(".variations_form");e.length&&(e.on("show_variation",(function(){return SequraWidgetFacade.drawWidgetsOnPage(!1)})),e.on("hide_variation",(function(){return SequraWidgetFacade.drawWidgetsOnPage()})))}})))}))}();
2 //# sourceMappingURL=widget-facade.min.js.map