{"version":3,"sources":["ecom.cart.js"],"names":["e4","cart","storageKeyInternalBackLink","init","jQuery","length","require","js","settings","handlebars","registerHelpers","registerTemplates","event","util","registerEvents","saveInternalBackLink","bindEvents","orderline","load","updateQuantityInfo","msg","document","referrer","indexOf","location","protocol","host","sessionStorage","setItem","goToInternalBackLink","strInternalBackLink","getItem","preventDefault","href","on","find","productsWithZeroInStock","filter","index","element","parseInt","data","each","orderlines","trigger","ajax","objAjaxSettings","fnCallback","jCart","jqXHR","extend","url","ecom","method","dataType","cache","beforeSend","addClass","done","removeClass","jsonData","updateContent","loading","resolveWait","loaded","addProduct","objProductFormData","jDocument","objProductData","CartCmd","ProductID","VariantID","Quantity","Redirect","isPlainObject","type","productadd","isArray","lastAdded","objProductLastAdded","strOrderlineId","getIdByProduct","setFocus","productQuantity","productadded","removeProduct","update","html","tmpl","cartOrderlines","orderSummary","cartFooter","updated","intQuantity","jCartQuantity","isNumeric","empty","toggleFocus","debounce","target","debounceDelay","domNode","jOrderline","closest","intOrderlineQuantity","val","jForm","intOrderlineQuantityOriginal","orderlineincrease","orderlinedecrease","serialize","attr","delete","objOrderlineData","orderlinedelete","key","orderlinedeleted","currencyCode","name","productName","number","productNumber","price","productPrice","quantity","strId","focus","objProduct","strReturnValue","id","variantId","select","timeout","jBody","is","hide","clearTimeout","setTimeout","show","jCartMsg","cartMsgLastadded","setPosition","modal","objPosition","jCartMsgDialog","jHeader","jNavItemCart","first","objCartMsgPosition","objCartMsgReferencePosition","isEmptyObject","get","getBoundingClientRect","top","hasClass","Math","floor","bottom","right","window","width","left","maxWidth","css","msgHideDelay"],"mappings":"AAAAA,GAAAC,MACAC,2BAAA,2BACAC,KAAA,WACA,IAAAC,OAAA,mBAAAC,OACAL,GAAAM,QAAAC,GAAAP,GAAAQ,SAAAF,QAAAG,WAAA,WACAT,GAAAS,WAAAC,gBAAA,WACAV,GAAAS,WAAAE,kBAAA,+GAGAX,GAAAC,KAAAW,MAAAZ,GAAAa,KAAAC,eAAA,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KAAAL,EAAA3I,QACAD,OAAAkJ,cAAAF,MAAA,IACA,IAAAF,EAAA7I,QACAgJ,EAAAH,EAAAK,IAAA,GAAAC,wBACAJ,GACAK,IAAAR,EAAAS,SAAA,gBAAA,EAAA,GAAAC,KAAAC,MAAAP,EAAAQ,QACAC,MAAAH,KAAAC,MAAAxJ,OAAA2J,QAAAC,QAAAX,EAAAS,OACAG,KAAA,GACAC,SAAA,KAGAd,GACAK,IAAA,EACAK,MAAA,EACAG,KAAA,EACAC,SAAA,SAKAlB,EAAAmB,IAAAf,IAEAX,WAAA,WACAzI,GAAAC,KAAAmB,IAAAoH,eACAxI,GAAAC,KAAAmB,IAAAgH,QAAAK,WAAAzI,GAAAC,KAAAmB,IAAAmH,KAAAvI,GAAAQ,SAAA4C,KAAAnD,KAAAmK,eAEA5B,aAAA,WACAxI,GAAAC,KAAAmB,IAAAgH,UACApI,GAAAC,KAAAmB,IAAAgH,QAAAI,aAAAxI,GAAAC,KAAAmB,IAAAgH","file":"ecom.cart.js","sourcesContent":["e4.cart = {\r\n storageKeyInternalBackLink: 'e4.cart.internalBackLink',\r\n init: function () {\r\n if (jQuery('.js-e-cart-form').length === 1) {\r\n e4.require.js(e4.settings.require.handlebars, function () {\r\n e4.handlebars.registerHelpers('compare');\r\n e4.handlebars.registerTemplates('#js-e-handlebars-tmpl-cart-orderlines #js-e-handlebars-tmpl-order-summary #js-e-handlebars-tmpl-cart-footer');\r\n // ATTENTION: Please note that all product-add/remove events are trigger on jQuery( document ) and not\r\n // the cart element.\r\n e4.cart.event = e4.util.registerEvents('load loaded update updated productadd productadded productremove productremoved orderlinedelete orderlinedeleted orderlineincrease orderlinedecrease', 'cart');\r\n e4.cart.saveInternalBackLink();\r\n e4.cart.bindEvents();\r\n e4.cart.orderline.bindEvents();\r\n e4.cart.load();\r\n });\r\n } else if (jQuery('.js-e-cart-quantity').length > 0) {\r\n e4.cart.event = e4.util.registerEvents('productadd productadded productremove productremoved', 'cart');\r\n e4.cart.updateQuantityInfo();\r\n e4.cart.msg.init();\r\n }\r\n },\r\n saveInternalBackLink: function () {\r\n if (document.referrer.indexOf(location.protocol + '//' + location.host) === 0 && document.referrer.indexOf('/shop/cart/checkout') === -1) {\r\n sessionStorage.setItem(e4.cart.storageKeyInternalBackLink, document.referrer);\r\n }\r\n },\r\n goToInternalBackLink: function (event) {\r\n var strInternalBackLink = sessionStorage.getItem(e4.cart.storageKeyInternalBackLink);\r\n if (strInternalBackLink !== null && strInternalBackLink.indexOf(location.protocol + '//' + location.host) === 0) {\r\n event.preventDefault();\r\n location.href = strInternalBackLink;\r\n }\r\n },\r\n bindEvents: function () {\r\n jQuery(document).on('click', '.js-e-cart-back-link', e4.cart.goToInternalBackLink).find('.js-e-cart-form').on('submit', function (event) {\r\n event.preventDefault();\r\n });\r\n\r\n jQuery('.js-e-cart').on('loaded.e4.cart', function () {\r\n var productsWithZeroInStock = jQuery('.js-e-cart-orderlines').find('.js-e-orderline').filter(function (index, element){\r\n return parseInt(jQuery(element).data('productStock')) === 0;\r\n });\r\n\r\n productsWithZeroInStock.each(function (index, orderlines){\r\n jQuery(orderlines).find('.js-e-orderline-delete-btn').trigger('click');\r\n });\r\n });\r\n\r\n },\r\n ajax: function (objAjaxSettings, fnCallback) {\r\n var jCart = jQuery('.js-e-cart'),\r\n jqXHR = jQuery.ajax(jQuery.extend({\r\n url: e4.settings.ecom.cart.url,\r\n method: 'POST',\r\n dataType: 'json',\r\n cache: false,\r\n beforeSend: function () {\r\n if (jCart.length === 1) {\r\n jQuery('.js-e-cart-main, .js-e-cart-aside').find('.js-e-loading-overlay').addClass('is-loading');\r\n }\r\n }\r\n }, objAjaxSettings));\r\n jqXHR.done(function (data) {\r\n if (typeof fnCallback === 'function') {\r\n fnCallback(data);\r\n }\r\n if (jCart.length === 1) {\r\n jQuery('.js-e-cart-main, .js-e-cart-aside').find('.js-e-loading-overlay').removeClass('is-loading');\r\n }\r\n });\r\n },\r\n load: function () {\r\n var jCart = jQuery('.js-e-cart');\r\n jCart.trigger(e4.cart.event.load);\r\n e4.cart.ajax({\r\n method: 'GET'\r\n }, function (jsonData) {\r\n e4.cart.updateContent(jsonData);\r\n e4.loading.resolveWait('.js-e-cart-main');\r\n e4.loading.resolveWait('.js-e-cart-aside');\r\n jCart.trigger(e4.cart.event.loaded, jsonData);\r\n });\r\n },\r\n addProduct: function (objProductFormData, fnCallback) {\r\n var jDocument = jQuery(document),\r\n jCart = jDocument.find('.js-e-cart');\r\n var objProductData = {\r\n CartCmd: 'add',\r\n ProductID: '',\r\n VariantID: '',\r\n Quantity: 1,\r\n Redirect: false\r\n };\r\n if (jQuery.isPlainObject(objProductFormData)) {\r\n jQuery.extend(objProductData, objProductFormData);\r\n } else if (jQuery.type(objProductFormData) === 'string') {\r\n objProductData.ProductID = objProductFormData;\r\n }\r\n jDocument.trigger(e4.cart.event.productadd, objProductData);\r\n e4.cart.ajax({\r\n data: objProductData\r\n }, function (jsonData) {\r\n if (jCart.length === 1) {\r\n e4.cart.updateContent(jsonData);\r\n if (jQuery.isArray(jsonData.cart.lastAdded) === true) {\r\n var objProductLastAdded = jsonData.cart.lastAdded[jsonData.cart.lastAdded.length - 1],\r\n strOrderlineId = e4.cart.orderline.getIdByProduct(objProductLastAdded);\r\n e4.cart.orderline.setFocus(strOrderlineId);\r\n }\r\n }\r\n e4.cart.updateQuantityInfo(jsonData.cart.productQuantity);\r\n if (typeof fnCallback === 'function') {\r\n fnCallback(jsonData);\r\n }\r\n jDocument.trigger(e4.cart.event.productadded, jsonData);\r\n });\r\n },\r\n removeProduct: function () {\r\n },\r\n updateContent: function (jsonData) {\r\n var jCart = jQuery('.js-e-cart');\r\n jCart.trigger(e4.cart.event.update);\r\n jCart.find('.js-e-cart-orderlines').html(e4.handlebars.tmpl.cartOrderlines(jsonData));\r\n jCart.find('.js-e-order-summary').html(e4.handlebars.tmpl.orderSummary(jsonData));\r\n jCart.find('.e-cart-footer').html(e4.handlebars.tmpl.cartFooter(jsonData));\r\n \r\n \r\n e4.cart.updateQuantityInfo(jsonData.cart.productQuantity);\r\n jCart.trigger(e4.cart.event.updated);\r\n },\r\n updateQuantityInfo: function (intQuantity) {\r\n var jCartQuantity = jQuery('.js-e-cart-quantity');\r\n if (jCartQuantity.length > 0) {\r\n if (jQuery.isNumeric(intQuantity) === false) {\r\n e4.cart.ajax({\r\n method: 'GET'\r\n }, function (jsonData) {\r\n if (jQuery.isNumeric(jsonData.cart.productQuantity) === true) {\r\n e4.cart.updateQuantityInfo(jsonData.cart.productQuantity);\r\n }\r\n });\r\n } else if (intQuantity === 0) {\r\n jCartQuantity.empty();\r\n } else {\r\n jCartQuantity.html(intQuantity);\r\n }\r\n }\r\n },\r\n orderline: {\r\n bindEvents: function () {\r\n jQuery('.js-e-cart-form')\r\n .on('focus blur', '.js-e-orderline-quantity-input', e4.cart.orderline.toggleFocus)\r\n .on('input', '.js-e-orderline-quantity-input', e4.util.debounce(function (event) {\r\n e4.cart.orderline.update(event.target);\r\n }, e4.settings.ecom.cart.debounceDelay))\r\n .on('click', '.js-e-orderline-update-btn', function (event) {\r\n event.preventDefault();\r\n e4.cart.orderline.update(event.target);\r\n })\r\n .on('click', '.js-e-orderline-delete-btn', function (event) {\r\n event.preventDefault();\r\n e4.cart.orderline.delete(event.target);\r\n });\r\n },\r\n update: function (domNode) {\r\n var jOrderline = jQuery(domNode).closest('.js-e-orderline'),\r\n intOrderlineQuantity = parseInt(jOrderline.find('.js-e-orderline-quantity-input').val());\r\n if (intOrderlineQuantity !== 0) {\r\n var jForm = jOrderline.closest('.js-e-cart-form'),\r\n jCart = jForm.closest('.js-e-cart'),\r\n intOrderlineQuantityOriginal = parseInt(jOrderline.data('product-quantity'));\r\n if (intOrderlineQuantity > intOrderlineQuantityOriginal) {\r\n jCart.trigger(e4.cart.event.orderlineincrease);\r\n } else if (intOrderlineQuantity < intOrderlineQuantityOriginal) {\r\n jCart.trigger(e4.cart.event.orderlinedecrease);\r\n }\r\n jForm.find('.js-e-cart-form-cartcmd').val('updateorderlines');\r\n e4.cart.ajax({\r\n data: jForm.serialize()\r\n }, function (jsonData) {\r\n e4.cart.updateContent(jsonData);\r\n e4.cart.orderline.setFocus(jOrderline.attr('id'));\r\n });\r\n }\r\n \r\n },\r\n delete: function (domNode) {\r\n var jCart = jQuery('.js-e-cart'),\r\n jOrderline = jQuery(domNode).closest('.js-e-orderline'),\r\n objOrderlineData = jOrderline.data();\r\n jCart.trigger(e4.cart.event.orderlinedelete);\r\n e4.cart.ajax({\r\n data: {\r\n key: jOrderline.attr('id'),\r\n CartCmd: 'delorderline',\r\n Redirect: false\r\n }\r\n }, function (jsonData) {\r\n e4.cart.updateContent(jsonData);\r\n jCart.trigger(e4.cart.event.orderlinedeleted, {\r\n currencyCode: jsonData.cart.currencyCode,\r\n name: objOrderlineData.productName,\r\n number: objOrderlineData.productNumber,\r\n price: objOrderlineData.productPrice,\r\n quantity: objOrderlineData.productQuantity\r\n });\r\n });\r\n },\r\n setFocus: function (strId) {\r\n if (strId !== '') {\r\n var jOrderline = jQuery('.js-e-orderline').filter('#' + strId);\r\n if (jOrderline.length === 1) {\r\n jOrderline.find('.js-e-orderline-quantity-input').focus();\r\n }\r\n }\r\n },\r\n getIdByProduct: function (objProduct) {\r\n var strReturnValue = '',\r\n jOrderline = jQuery('.js-e-orderline').filter('[data-product-id=\"' + objProduct.id + '\"][data-product-variant-id=\"' + objProduct.variantId + '\"]');\r\n if (jOrderline.length === 1) {\r\n strReturnValue = jOrderline.attr('id');\r\n }\r\n return strReturnValue;\r\n },\r\n toggleFocus: function (event) {\r\n var jOrderline = jQuery(event.target).closest('.js-e-orderline');\r\n if (event.type === 'focusin') {\r\n jQuery(event.target).select();\r\n jOrderline.addClass('has-focus');\r\n } else {\r\n jOrderline.removeClass('has-focus');\r\n }\r\n }\r\n },\r\n msg: {\r\n timeout: null,\r\n init: function () {\r\n if (jQuery('#js-e-cart-msg').length === 1) {\r\n e4.require.js(e4.settings.require.handlebars, function () {\r\n e4.handlebars.registerTemplates('#js-e-handlebars-tmpl-cart-msg-lastadded');\r\n });\r\n e4.cart.msg.bindEvents();\r\n }\r\n },\r\n bindEvents: function () {\r\n var jBody = jQuery('body');\r\n jQuery('#js-e-cart-msg').on('show.bs.modal', function () {\r\n jBody.addClass('modal-open-no-adjustment');\r\n }).on('hidden.bs.modal', function () {\r\n jBody.removeClass('modal-open-no-adjustment');\r\n }).on('click', function (event) {\r\n if (jQuery(event.target).is('#js-e-cart-msg') === true) {\r\n e4.cart.msg.hide();\r\n }\r\n }).find('.modal-dialog').on('mouseenter', e4.cart.msg.clearTimeout).on('mouseleave', e4.cart.msg.setTimeout);\r\n jQuery(document).on(e4.cart.event.productadded, function (event, jsonData) {\r\n e4.cart.msg.show(jsonData);\r\n });\r\n },\r\n show: function (jsonData) {\r\n var jCartMsg = jQuery('#js-e-cart-msg');\r\n jCartMsg.find('.js-e-cart-msg-content').html(e4.handlebars.tmpl.cartMsgLastadded(jsonData));\r\n e4.cart.msg.clearTimeout();\r\n e4.cart.msg.setPosition();\r\n jCartMsg.modal('show');\r\n e4.cart.msg.setTimeout();\r\n },\r\n hide: function () {\r\n e4.cart.msg.clearTimeout();\r\n jQuery('#js-e-cart-msg').modal('hide');\r\n },\r\n setPosition: function (objPosition) {\r\n var jCartMsgDialog = jQuery('#js-e-cart-msg').find('.modal-dialog'),\r\n jHeader = jQuery('.js-e-header'),\r\n jNavItemCart = jHeader.find('.js-e-nav').find('.js-e-nav-item-cart').filter(':visible').first(),\r\n objCartMsgPosition = objPosition || {},\r\n objCartMsgReferencePosition = {};\r\n if (jCartMsgDialog.length === 1) {\r\n if (jQuery.isEmptyObject(objCartMsgPosition) === true) {\r\n if (jNavItemCart.length === 1) {\r\n objCartMsgReferencePosition = jNavItemCart.get(0).getBoundingClientRect();\r\n objCartMsgPosition = {\r\n top: jHeader.hasClass('is-hidden') === true ? '' : Math.floor(objCartMsgReferencePosition.bottom),\r\n right: Math.floor(jQuery(window).width() - objCartMsgReferencePosition.right),\r\n left: '',\r\n maxWidth: ''\r\n };\r\n } else {\r\n objCartMsgPosition = {\r\n top: 0,\r\n right: 0,\r\n left: 0,\r\n maxWidth: '100%'\r\n };\r\n }\r\n }\r\n }\r\n jCartMsgDialog.css(objCartMsgPosition);\r\n },\r\n setTimeout: function () {\r\n e4.cart.msg.clearTimeout();\r\n e4.cart.msg.timeout = setTimeout(e4.cart.msg.hide, e4.settings.ecom.cart.msgHideDelay);\r\n },\r\n clearTimeout: function () {\r\n if (e4.cart.msg.timeout) {\r\n e4.cart.msg.timeout = clearTimeout(e4.cart.msg.timeout);\r\n }\r\n }\r\n }\r\n};\r\n\r\n"],"sourceRoot":"/source/"}