commercelayer
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -1,24 +0,1 @@ | ||
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var o=n(7),i=n(17),a=Object.prototype.toString;function r(e){return"[object Array]"===a.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===a.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===a.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===a.call(e)},isFile:function(e){return"[object File]"===a.call(e)},isBlob:function(e){return"[object Blob]"===a.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,i=arguments.length;o<i;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,function(t,i){e[i]=n&&"function"==typeof t?o(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){const o=n(5),i=n(36);e.exports={getOrderCookieName:function(){return`order_token_${o.countryCode()}`},getAccessTokenCookieName:function(){return`access_token_${o.clientId()}_${o.marketId()}`},getAccessTokenRetryLockCookieName:function(){return`${this.getAccessTokenCookieName()}_retry_lock`},getOrderToken:function(){return i.get(this.getOrderCookieName())},setOrderToken:function(e){return i.set(this.getOrderCookieName(),e,{expires:30})},deleteOrderToken:function(){return i.remove(this.getOrderCookieName())},getAccessTokenCookie:function(){return i.get(this.getAccessTokenCookieName())},setAccessTokenCookie:function(e,t){i.set(this.getAccessTokenCookieName(),e,t)},getAccessTokenRetryLockCookie:function(){return i.get(this.getAccessTokenRetryLockCookieName())},setAccessTokenRetryLockCookie:function(){i.set(this.getAccessTokenRetryLockCookieName(),"1",{expires:1/1440})},getElementFromTemplate:function(e){return"TEMPLATE"==e.tagName?e.content.cloneNode(!0):e.cloneNode(!0)},getInventoryFirstAvailableLevel:function(e){if(first_level=e.levels[0],0==first_level.quantity)for(k=1;k<e.levels.length;k++)if(level=e.levels[k],level.quantity>0){first_level=level;break}return first_level}}},function(e,t){e.exports={config:document.querySelector("#clayer-config"),main:document.querySelector("#clayer-main"),prices:Array.prototype.slice.call(document.querySelectorAll(".clayer-price"),0),variants:Array.prototype.slice.call(document.querySelectorAll(".clayer-variant"),0),variantSelect:document.querySelector(".clayer-variant-select"),availabilityMessageContainer:document.querySelector("#clayer-availability-message-container"),availabilityMessageAvailableTemplate:document.querySelector("#clayer-availability-message-available-template"),availabilityMessageUnavailableTemplate:document.querySelector("#clayer-availability-message-unavailable-template"),addToBag:document.querySelector(".clayer-add-to-bag"),shoppingBagContainer:document.querySelector("#clayer-shopping-bag-container"),shoppingBagItemsContainer:document.querySelector("#clayer-shopping-bag-items-container"),shoppingBagItemTemplate:document.querySelector("#clayer-shopping-bag-item-template"),shoppingBagItemsCount:document.querySelector("#clayer-shopping-bag-items-count"),shoppingBagSubtotal:document.querySelector("#clayer-shopping-bag-subtotal"),shoppingBagShipping:document.querySelector("#clayer-shopping-bag-shipping"),shoppingBagPayment:document.querySelector("#clayer-shopping-bag-payment"),shoppingBagDiscount:document.querySelector("#clayer-shopping-bag-discount"),shoppingBagTaxes:document.querySelector("#clayer-shopping-bag-taxes"),shoppingBagTotal:document.querySelector("#clayer-shopping-bag-total"),shoppingBagCheckout:document.querySelector("#clayer-shopping-bag-checkout"),shoppingBagClose:document.querySelector("#clayer-shopping-bag-close"),shoppingBagToggle:document.querySelector("#clayer-shopping-bag-toggle"),shoppingBagUnavailableMessage:document.querySelector(".clayer-shopping-bag-unavailable-message")}},function(e,t,n){e.exports=n(16)},function(e,t,n){"use strict";(function(t){var o=n(0),i=n(20),a={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:("undefined"!=typeof XMLHttpRequest?s=n(8):void 0!==t&&(s=n(8)),s),transformRequest:[function(e,t){return i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],function(e){c.headers[e]={}}),o.forEach(["post","put","patch"],function(e){c.headers[e]=o.merge(a)}),e.exports=c}).call(this,n(19))},function(e,t,n){const o=n(2);e.exports={baseUrl:function(){return o.config.dataset.baseUrl},clientId:function(){return o.config.dataset.clientId},marketId:function(){return o.config.dataset.marketId},countryCode:function(){return o.config.dataset.countryCode},languageCode:function(){return o.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return o.config.dataset.cartUrl},returnUrl:function(){return o.config.dataset.returnUrl},privacyUrl:function(){return o.config.dataset.privacyUrl},termsUrl:function(){return o.config.dataset.termsUrl}}},function(e,t,n){const o=n(2),a=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=o.prices,$prices.length>0&&(skuCodes=[],$prices.forEach(function(e){skuCodes.push(e.dataset.skuCode)}),skus=[],skusEndpoint="/api/skus?filter[codes]="+skuCodes.join(",")+"&include=prices&page[size]=25",skuAttributes=["id","code","prices.formatted_amount","prices.formatted_compare_at_amount","prices.amount_cents","prices.compare_at_amount_cents"],a.get(skusEndpoint).then(function(e){if(u.updatePrices(r(e.data).get(skuAttributes)),pageCount=e.data.meta.page_count,pageCount>1)for(p=2;p<=pageCount;p++)skusEndpointWithPage=skusEndpoint+"&page[number]="+p,a.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(o.addToBag),$variants=o.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),a.get("/api/skus?filter[codes]="+skuCodes.join(",")).then(function(t){for(skus=r(t.data).get(["id","code"]),i=0;i<skus.length;i++)variant=document.querySelector('.clayer-variant[data-sku-code="'+skus[i].code+'"]'),variant&&(variant.value=skus[i].id,u.enableElement(variant),0==i&&e.exports.selectVariant(variant))}))},getInventory:function(e,t){a.get("/api/skus/"+e+"?fields[skus]=inventory").then(function(n){sku=n.data.data,u.updateAvailabilityMessage(sku.attributes.inventory),sku.attributes.inventory.available?(u.updateAddToBagSKU(e,t),u.enableAddToBag()):u.disableAddToBag()})},selectVariant:function(t){switch(t.tagName){case"INPUT":switch(t.type){case"radio":t.click();break;case"hidden":e.exports.getInventory(t.value,t.dataset.skuName)}break;case"OPTION":$select=t.parentNode,$select.value=t.value,$select.dispatchEvent(new Event("change"))}},createOrder:function(){return a.post("/api/orders",{data:{type:"orders",attributes:{shipping_country_code_lock:s.countryCode(),language_code:s.languageCode(),cart_url:s.cartUrl(),return_url:s.returnUrl(),privacy_url:s.privacyUrl(),terms_url:s.termsUrl()}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return c.setOrderToken(e.data.data.attributes.token),e.data.data})},refreshOrder:function(){c.getOrderToken()&&this.getOrder().then(function(e){e&&"placed"==e.attributes.status&&(c.deleteOrderToken(),u.clearShoppingBag())})},createLineItem:function(e,t,n,o){return a.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:o,_update_quantity:1},relationships:{order:{data:{type:"orders",id:e}},item:{data:{type:"skus",id:t}}}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},deleteLineItem:function(e){return a.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return a.patch("/api/line_items/"+e,{data:{type:"line_items",id:e,attributes:t}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},updateLineItemQty:function(e,t){api=this,api.updateLineItem(e,{quantity:t}).then(function(e){api.getOrder()}).catch(function(e){if(e.response)switch(e.response.status){case 422:u.displayShoppingBagUnavailableMessage()}})},updateShoppingBagItems:function(e){if(api=this,$shoppingBagItemsContainer=o.shoppingBagItemsContainer,$shoppingBagItemsContainer&&(normalized_order=r(e).get(["id","formatted_subtotal_amount","formatted_discount_amount","formatted_shipping_amount","formatted_payment_method_amount","formatted_total_tax_amount","formatted_total_amount_with_taxes","line_items.id","line_items.item_type","line_items.image_url","line_items.name","line_items.quantity","line_items.formatted_unit_amount","line_items.formatted_total_amount"])[0],normalized_order.line_items))for($shoppingBagItemsContainer.innerHTML="",i=0;i<normalized_order.line_items.length;i++)if(line_item=normalized_order.line_items[i],"skus"==line_item.item_type&&($shoppingBagItemTemplate=o.shoppingBagItemTemplate,$shoppingBagItemTemplate)){for("TEMPLATE"==$shoppingBagItemTemplate.tagName?$shoppingBagItem=$shoppingBagItemTemplate.content.cloneNode(!0):$shoppingBagItem=$shoppingBagItemTemplate.cloneNode(!0),$shoppingBagItemImage=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-image"),$shoppingBagItemImage.src=line_item.image_url,$shoppingBagItemName=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-name"),$shoppingBagItemName.innerHTML=line_item.name,$shoppingBagItemQtyContainer=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-qty-container"),$qtySelect=document.createElement("select"),$qtySelect.dataset.lineItemId=line_item.id,qty=1;qty<=10;qty++)$option=document.createElement("option"),$option.value=qty,$option.text=qty,qty==line_item.quantity&&($option.selected=!0),$qtySelect.appendChild($option);$qtySelect.addEventListener("change",function(e){api.updateLineItemQty(this.dataset.lineItemId,this.value)}),$shoppingBagItemQtyContainer.appendChild($qtySelect),$shoppingBagItemUnitAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-unit-amount"),$shoppingBagItemUnitAmount.innerHTML=line_item.formatted_unit_amount,$shoppingBagItemTotalAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-total-amount"),$shoppingBagItemTotalAmount.innerHTML=line_item.formatted_total_amount,$shoppingBagItemRemove=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-remove"),$shoppingBagItemRemove.dataset.lineItemId=line_item.id,$shoppingBagItemRemove.addEventListener("click",function(e){e.preventDefault(),api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder()})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,a.get("/api/orders?include=line_items&filter[token]="+c.getOrderToken()).then(function(e){if(e.data.data.length>0)return api.updateShoppingBagItems(e.data),u.hideShoppingBagUnavailableMessage(),u.updateShoppingBagSummary(e.data.data[0]),u.updateShoppingBagCheckout(e.data),0==e.data.data[0].attributes.skus_count&&u.clearShoppingBag(),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},function(e,t,n){"use strict";var o=n(0),i=n(21),a=n(23),r=n(24),s=n(25),c=n(9),u="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(26);e.exports=function(e){return new Promise(function(t,p){var l=e.data,d=e.headers;o.isFormData(l)&&delete d["Content-Type"];var f=new XMLHttpRequest,g="onreadystatechange",h=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in f||s(e.url)||(f=new window.XDomainRequest,g="onload",h=!0,f.onprogress=function(){},f.ontimeout=function(){}),e.auth){var m=e.auth.username||"",y=e.auth.password||"";d.Authorization="Basic "+u(m+":"+y)}if(f.open(e.method.toUpperCase(),a(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f[g]=function(){if(f&&(4===f.readyState||h)&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in f?r(f.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:1223===f.status?204:f.status,statusText:1223===f.status?"No Content":f.statusText,headers:n,config:e,request:f};i(t,p,o),f=null}},f.onerror=function(){p(c("Network Error",e,null,f)),f=null},f.ontimeout=function(){p(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},o.isStandardBrowserEnv()){var v=n(27),B=(e.withCredentials||s(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;B&&(d[e.xsrfHeaderName]=B)}if("setRequestHeader"in f&&o.forEach(d,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)}),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){f&&(f.abort(),p(e),f=null)}),void 0===l&&(l=null),f.send(l)})}},function(e,t,n){"use strict";var o=n(22);e.exports=function(e,t,n,i,a){var r=new Error(e);return o(r,t,n,i,a)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){const o=n(35),i=n(3),a=n(5),r=n(1);i.defaults.baseURL=a.baseUrl(),i.defaults.headers.common.Accept="application/vnd.api+json",i.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+r.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),i.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&o.cookies&&null==r.getAccessTokenRetryLockCookie()?(r.setAccessTokenRetryLockCookie(),i.post("/oauth/token",{grant_type:"client_credentials",client_id:a.clientId(),scope:"market:"+a.marketId()}).then(function(e){return r.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,i.request(e.config)})):Promise.reject(e)})},function(e,t,n){var o,i,a;i=[],void 0===(a="function"==typeof(o=function(){function e(o,i){if(!(this instanceof e)){var a=new e(o);return i?a.get(i):a}if("string"==typeof o&&(o=JSON.parse(o)),!o||!o.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=o,this.isCollection=t(o.data),this.haystack=(r=o.included,s=this.isCollection?o.data:[o.data],c=[],n(u=r||[],function(e){c.push(e.type+"@"+e.id)}),n(s,function(e){c.indexOf(e.type+"@"+e.id)<0&&u.push(e)}),u)}function t(e){return e instanceof Array}function n(e,n,o){if(t(e))for(var i=e.length,a=0;a<i;a++)n.call(o,e[a],a);else for(var r in e)e.hasOwnProperty(r)&&n.call(o,r,e[r])}function o(e,t,o){var i=[];return n(e,function(e,n){i.push(t.call(o,e,n))}),i}function i(i,s,c){var u={};return n(i,function(n,i){if(i)u[n]=function(e,n,i,s){var c=i.relationships&&i.relationships[e]&&i.relationships[e].data,u=c&&r(c,s);return t(u)?o(u,function(e){return a(n,e,s)}):u?a(n,u,s):void 0}(n,i,s,c);else{var p=s.relationships&&s.relationships[n]&&s.relationships[n].data;if(p){var l=r(p,c);u[n]=l?new e({data:l,included:c}):void 0}else u[n]=function(e,t){return["id","type"].indexOf(e)>=0?t[e]:t.attributes[e]}(n,s)}}),u}function a(t,n,o){return s.call(new e({data:n,included:o}),t)}function r(e,i){var a=[],r=t(e)?o(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(i,function(e){r.indexOf(e.type+"@"+e.id)>=0&&a.push(e)}),0===a.length?void 0:1!==a.length||t(e)?a:a[0]}function s(e){return this.isCollection?o(this.dataset.data,function(t){return i(e,t,this.haystack)},this):i(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var i,a,r=s.call(this,(i=t(e)?e:[e],a={},n(i,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var o in n)n.hasOwnProperty(o)&&("object"==typeof n[o]&&null!==n[o]?(void 0===t[o]&&(t[o]={}),e(t[o],n[o])):t[o]=n[o]);return t}(a,function(e){for(var t={},n=t,o=e.length,i=0;i<o;i++)n=n[e[i]]=n[e[i]]||(i+1===o?void 0:{});return t}(t)):a[e]=void 0}),a));return this.isCollection?t(e)?r:o(r,function(t){return t[e]}):t(e)?r:r[e]},e})?o.apply(t,i):o)||(e.exports=a)},function(e,t,n){const o=n(2),i=n(1),a=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t,n){el=e.querySelector(t),el&&(el.innerHTML=n)},displayElement:function(e){e&&(e.style.display="block")},hideElement:function(e){e&&(e.style.display="none")},updatePrices:function(e){for(k=0;k<e.length;k++)priceAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .amount'),priceAmount&&(priceAmount.innerHTML=e[k].prices[0].formatted_amount),priceCompareAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .compare-at-amount'),priceCompareAmount&&e[k].prices[0].compare_at_amount_cents>e[k].prices[0].amount_cents&&(priceCompareAmount.innerHTML=e[k].prices[0].formatted_compare_at_amount)},updateAddToBagSKU:function(e,t){$addToBag=o.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=o.availabilityMessageContainer,$container&&(first_level=i.getInventoryFirstAvailableLevel(e),first_level.quantity>0?(dlt=first_level.delivery_lead_times[0],qty=first_level.quantity,minDays=dlt.min.days,maxDays=dlt.max.days,shippingMethodName=dlt.shipping_method.name,shippingMethodPrice=dlt.shipping_method.formatted_price_amount,this.displayAvailableMessage(qty,minDays,maxDays,shippingMethodName,shippingMethodPrice)):this.displayUnavailableMessage())},updateShoppingBagSummary:function(e){$shoppingBagItemsCount=o.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=o.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=o.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=o.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=o.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=o.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=o.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=o.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=a(e).get(["line_items.id","checkout_url"])[0],normalized_order.line_items?(this.enableElement($shoppingBagCheckout),$shoppingBagCheckout.href=normalized_order.checkout_url):($shoppingBagCheckout.href="",this.disableElement($shoppingBagCheckout)))},displayAvailableMessage:function(e,t,n,a,r){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageAvailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),this.setElementHTML($el,".clayer-availability-message-available-qty",e),this.setElementHTML($el,".clayer-availability-message-available-min-days",t),this.setElementHTML($el,".clayer-availability-message-available-max-days",n),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-name",a),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-price",r),$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageUnavailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=o.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=o.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){o.shoppingBagItemsContainer&&(o.shoppingBagItemsContainer.innerHTML="")},displayShoppingBagUnavailableMessage:function(){this.displayElement(o.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(o.shoppingBagUnavailableMessage)}}},function(e,t,n){const o=n(6),i=n(37);n(1);t.init=function(){o.getPrices(),o.getVariants(),i.setVariantSelect(),i.setAddToShoppingBag(),i.setShoppingBagToggle(),o.refreshOrder()},document.addEventListener("DOMContentLoaded",function(){window.commercelayer=e.exports,e.exports.init()})},function(e,t,n){"use strict";var o=n(0),i=n(7),a=n(18),r=n(4);function s(e){var t=new a(e),n=i(a.prototype.request,t);return o.extend(n,a.prototype,t),o.extend(n,t),n}var c=s(r);c.Axios=a,c.create=function(e){return s(o.merge(r,e))},c.Cancel=n(11),c.CancelToken=n(33),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(34),e.exports=c,e.exports.default=c},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)} | ||
/*! | ||
* Determine if an object is a Buffer | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
e.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},function(e,t,n){"use strict";var o=n(4),i=n(0),a=n(28),r=n(29);function s(e){this.defaults=e,this.interceptors={request:new a,response:new a}}s.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),(e=i.merge(o,{method:"get"},this.defaults,e)).method=e.method.toLowerCase();var t=[r,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){s.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){s.prototype[e]=function(t,n,o){return this.request(i.merge(o||{},{method:e,url:t,data:n}))}}),e.exports=s},function(e,t){var n,o,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(e){n=a}try{o="function"==typeof clearTimeout?clearTimeout:r}catch(e){o=r}}();var c,u=[],p=!1,l=-1;function d(){p&&c&&(p=!1,c.length?u=c.concat(u):l=-1,u.length&&f())}function f(){if(!p){var e=s(d);p=!0;for(var t=u.length;t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,p=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===r||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function h(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new g(e,t)),1!==u.length||p||s(f)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=h,i.addListener=h,i.once=h,i.off=h,i.removeListener=h,i.removeAllListeners=h,i.emit=h,i.prependListener=h,i.prependOnceListener=h,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,n){"use strict";var o=n(0);e.exports=function(e,t){o.forEach(e,function(n,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[o])})}},function(e,t,n){"use strict";var o=n(9);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(o("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n,o,i){return e.config=t,n&&(e.code=n),e.request=o,e.response=i,e}},function(e,t,n){"use strict";var o=n(0);function i(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var a;if(n)a=n(t);else if(o.isURLSearchParams(t))a=t.toString();else{var r=[];o.forEach(t,function(e,t){null!=e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),r.push(i(t)+"="+i(e))}))}),a=r.join("&")}return a&&(e+=(-1===e.indexOf("?")?"?":"&")+a),e}},function(e,t,n){"use strict";var o=n(0),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,a,r={};return e?(o.forEach(e.split("\n"),function(e){if(a=e.indexOf(":"),t=o.trim(e.substr(0,a)).toLowerCase(),n=o.trim(e.substr(a+1)),t){if(r[t]&&i.indexOf(t)>=0)return;r[t]="set-cookie"===t?(r[t]?r[t]:[]).concat([n]):r[t]?r[t]+", "+n:n}}),r):r}},function(e,t,n){"use strict";var o=n(0);e.exports=o.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var o=e;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=o.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function i(){this.message="String contains an invalid character"}i.prototype=new Error,i.prototype.code=5,i.prototype.name="InvalidCharacterError",e.exports=function(e){for(var t,n,a=String(e),r="",s=0,c=o;a.charAt(0|s)||(c="=",s%1);r+=c.charAt(63&t>>8-s%1*8)){if((n=a.charCodeAt(s+=.75))>255)throw new i;t=t<<8|n}return r}},function(e,t,n){"use strict";var o=n(0);e.exports=o.isStandardBrowserEnv()?{write:function(e,t,n,i,a,r){var s=[];s.push(e+"="+encodeURIComponent(t)),o.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),o.isString(i)&&s.push("path="+i),o.isString(a)&&s.push("domain="+a),!0===r&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var o=n(0);function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=i},function(e,t,n){"use strict";var o=n(0),i=n(30),a=n(10),r=n(4),s=n(31),c=n(32);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||r.adapter)(e).then(function(t){return u(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return a(t)||(u(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var o=n(0);e.exports=function(e,t,n){return o.forEach(n,function(n){e=n(e,t)}),e}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var o=n(11);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i(function(t){e=t}),cancel:e}},e.exports=i},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t){!function(t){var n="Modernizr"in t,o=t.Modernizr;!function(e,t,n){var o=[],i={_version:"3.6.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){o.push({name:e,fn:t,options:n})},addAsyncTest:function(e){o.push({name:null,fn:e})}},a=function(){};a.prototype=i,a=new a;var r=[]; | ||
/*! | ||
{ | ||
"name": "Cookies", | ||
"property": "cookies", | ||
"tags": ["storage"], | ||
"authors": ["tauren"] | ||
} | ||
!*/ | ||
a.addTest("cookies",function(){try{t.cookie="cookietest=1";var e=-1!=t.cookie.indexOf("cookietest=");return t.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}catch(e){return!1}}),function(){var e,t,n,i,s,c;for(var u in o)if(o.hasOwnProperty(u)){if(e=[],(t=o[u]).name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(i="function"==typeof t.fn?t.fn():t.fn,s=0;s<e.length;s++)1===(c=e[s].split(".")).length?a[c[0]]=i:(!a[c[0]]||a[c[0]]instanceof Boolean||(a[c[0]]=new Boolean(a[c[0]])),a[c[0]][c[1]]=i),r.push((i?"":"no-")+c.join("-"))}}(),delete i.addTest,delete i.addAsyncTest;for(var s=0;s<a._q.length;s++)a._q[s]();e.Modernizr=a}(t,document),e.exports=t.Modernizr,n?t.Modernizr=o:delete t.Modernizr}(window)},function(e,t,n){var o,i; | ||
/*! | ||
* JavaScript Cookie v2.2.0 | ||
* https://github.com/js-cookie/js-cookie | ||
* | ||
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack | ||
* Released under the MIT license | ||
*/!function(a){if(void 0===(i="function"==typeof(o=a)?o.call(t,n,t,e):o)||(e.exports=i),!0,e.exports=a(),!!0){var r=window.Cookies,s=window.Cookies=a();s.noConflict=function(){return window.Cookies=r,s}}}(function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}return function t(n){function o(t,i,a){var r;if("undefined"!=typeof document){if(arguments.length>1){if("number"==typeof(a=e({path:"/"},o.defaults,a)).expires){var s=new Date;s.setMilliseconds(s.getMilliseconds()+864e5*a.expires),a.expires=s}a.expires=a.expires?a.expires.toUTCString():"";try{r=JSON.stringify(i),/^[\{\[]/.test(r)&&(i=r)}catch(e){}i=n.write?n.write(i,t):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=(t=(t=encodeURIComponent(String(t))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape);var c="";for(var u in a)a[u]&&(c+="; "+u,!0!==a[u]&&(c+="="+a[u]));return document.cookie=t+"="+i+c}t||(r={});for(var p=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d<p.length;d++){var f=p[d].split("="),g=f.slice(1).join("=");this.json||'"'!==g.charAt(0)||(g=g.slice(1,-1));try{var h=f[0].replace(l,decodeURIComponent);if(g=n.read?n.read(g,h):n(g,h)||g.replace(l,decodeURIComponent),this.json)try{g=JSON.parse(g)}catch(e){}if(t===h){r=g;break}t||(r[h]=g)}catch(e){}}return r}}return o.set=o,o.get=function(e){return o.call(o,e)},o.getJSON=function(){return o.apply({json:!0},[].slice.call(arguments))},o.defaults={},o.remove=function(t,n){o(t,"",e(n,{expires:-1}))},o.withConverter=t,o}(function(){})})},function(e,t,n){const o=n(2),i=(n(3),n(12),n(14)),a=n(6),r=n(1);e.exports={setVariantSelect:function(){$variantSelect=o.variantSelect,$variantSelect?$variantSelect.addEventListener("change",function(e){$selectedOption=$variantSelect.options[this.selectedIndex],a.getInventory($selectedOption.value,$selectedOption.dataset.skuName)}):($variants=o.variants,$variants.forEach(function(e){e.addEventListener("click",function(e){a.getInventory(this.value,this.dataset.skuName)})}))},setAddToShoppingBag:function(){$addToBag=o.addToBag,$addToBag&&$addToBag.addEventListener("click",function(e){e.preventDefault(),orderPromise=r.getOrderToken()?a.getOrder():a.createOrder(),orderPromise.then(function(e){a.createLineItem(e.id,$addToBag.dataset.skuId,$addToBag.dataset.skuName,$addToBag.dataset.skuImageUrl).then(function(e){a.getOrder(),i.openShoppingBag()}).catch(function(e){if(e.response)switch(e.response.status){case 422:i.displayUnavailableMessage()}})})})},setShoppingBagToggle:function(){$shoppingBagToggle=o.shoppingBagToggle,$shoppingBagToggle&&$shoppingBagToggle.addEventListener("click",function(e){e.preventDefault(),i.toggleShoppingBag()})}}}]); | ||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){document.addEventListener("readystatechange",function(){console.log(document.readyState),console.log(document.querySelector("#clayer-config")),console.log("---")})}]); |
{ | ||
"name": "commercelayer", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "The Official Commerce Layer JS library", | ||
@@ -5,0 +5,0 @@ "main": "./src/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27597
743