{"version":3,"sources":["ecom.cart.js"],"names":["e4","cart","init","jQuery","length","require","js","settings","handlebars","registerHelpers","registerTemplates","event","util","registerEvents","saveInternalBackLink","bindEvents","orderline","load","updateQuantityInfo","msg","document","on","goToInternalBackLink","find","preventDefault","ajax","objAjaxSettings","fnCallback","jCart","extend","url","ecom","method","dataType","cache","beforeSend","addClass","done","data","removeClass","trigger","jsonData","updateContent","loading","resolveWait","loaded","referrer","indexOf","location","protocol","host","sessionStorage","setItem","storageKeyInternalBackLink","strInternalBackLink","getItem","href","addProduct","objProductFormData","jDocument","objProductData","CartCmd","ProductID","VariantID","Quantity","Redirect","isPlainObject","type","productadd","strOrderlineId","isArray","lastAdded","objProductLastAdded","getIdByProduct","setFocus","productQuantity","productadded","removeProduct","update","html","tmpl","cartOrderlines","orderSummary","updated","intQuantity","jCartQuantity","isNumeric","empty","toggleFocus","debounce","target","debounceDelay","input","saveComment","hideCommentHelpText","delete","domNode","jForm","intOrderlineQuantityOriginal","jOrderline","closest","intOrderlineQuantity","parseInt","val","orderlineincrease","orderlinedecrease","serialize","attr","objOrderlineData","orderlinedelete","key","orderlinedeleted","currencyCode","name","productName","number","productNumber","price","productPrice","quantity","domInput","value","join","noop","showCommentHelpText","prop","strId","filter","focus","objProduct","strReturnValue","id","variantId","select","timeout","jBody","modal","bodyNoAdjustmentClass","is","hide","clearTimeout","setTimeout","show","jCartMsg","cartMsgLastadded","setPosition","objPosition","jCartMsgDialog","jHeader","jNavItemCart","first","objCartMsgPosition","isEmptyObject","objCartMsgReferencePosition","get","getBoundingClientRect","top","hasClass","Math","floor","bottom","right","window","width","left","maxWidth","css","msgHideDelay"],"mappings":"AAAAA,GAAAC,KAAA,CACAC,KAAA,WACA,IAAAC,OAAA,mBAAAC,OACAJ,GAAAK,QAAAC,GAAAN,GAAAO,SAAAF,QAAAG,WAAA,WACAR,GAAAQ,WAAAC,gBAAA,WACAT,GAAAQ,WAAAE,kBAAA,6EAGAV,GAAAC,KAAAU,MAAAX,GAA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,GAAAC,KAAAkB,IAAA8H,cACAF,EAAAP,MAAA,QACAxI,GAAAC,KAAAkB,IAAA0H,cAEAF,KAAA,WACA3I,GAAAC,KAAAkB,IAAAyH,eACAzI,OAAA,kBAAAqI,MAAA,SAEAS,YAAA,SAAAC,GACA,IAAAC,EAAAhJ,OAAA,kBAAAoB,KAAA,iBACA6H,EAAAjJ,OAAA,gBACAkJ,EAAAD,EAAA7H,KAAA,aAAAA,KAAA,uBAAAwG,OAAA,YAAAuB,QACAC,EAAAL,GAAA,GAEA,IAAAC,EAAA/I,SACA,IAAAD,OAAAqJ,cAAAD,KAGAA,EAFA,IAAAF,EAAAjJ,QACAqJ,EAAAJ,EAAAK,IAAA,GAAAC,wBACA,CACAC,KAAA,IAAAR,EAAAS,SAAA,aAAA,GAAAC,KAAAC,MAAAN,EAAAO,QACAC,MAAAH,KAAAC,MAAA5J,OAAA+J,QAAAC,QAAAV,EAAAQ,OACAG,KAAA,GACAC,SAAA,KAIA,CACAT,IAAA,EACAK,MAAA,EACAG,KAAA,EACAC,SAAA,SAKAlB,EAAAmB,IAAAf,IAEAV,WAAA,WACA7I,GAAAC,KAAAkB,IAAAyH,eACA5I,GAAAC,KAAAkB,IAAAmH,QAAAO,WAAA7I,GAAAC,KAAAkB,IAAAwH,KAAA3I,GAAAO,SAAAwB,KAAA9B,KAAAsK,eAEA3B,aAAA,WACA5I,GAAAC,KAAAkB,IAAAmH,UACAtI,GAAAC,KAAAkB,IAAAmH,QAAAM,aAAA5I,GAAAC,KAAAkB,IAAAmH","file":"ecom.cart.js","sourcesContent":["e4.cart = {\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' );\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 }\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 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 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 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.settings.ecom.cart.storageKeyInternalBackLink, document.referrer );\r\n }\r\n },\r\n goToInternalBackLink: function ( event ) {\r\n var strInternalBackLink = sessionStorage.getItem( e4.settings.ecom.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 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 ) == true ) {\r\n jQuery.extend( objProductData, objProductFormData );\r\n }\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 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 }\r\n else if ( intQuantity === 0 ) {\r\n jCartQuantity.empty();\r\n }\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.debounceDelay.input * 2 ) )\r\n .on( 'input', '.js-e-orderline-comment-input', e4.util.debounce( function ( event ) {\r\n e4.cart.orderline.saveComment( event.target );\r\n }, e4.settings.debounceDelay.input ) )\r\n .on( 'input', '.js-e-orderline-comment-input', function ( event ) {\r\n e4.cart.orderline.hideCommentHelpText( event.target );\r\n } )\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 }\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 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 saveComment: function ( domInput ) {\r\n e4.cart.ajax( {\r\n data: [\r\n domInput.name,\r\n domInput.value\r\n ].join( '=' ),\r\n beforeSend: jQuery.noop\r\n }, function () {\r\n e4.cart.orderline.showCommentHelpText( domInput );\r\n } );\r\n },\r\n showCommentHelpText: function ( domInput ) {\r\n jQuery( domInput ).closest( '.form-group' ).find( '.js-e-orderline-comment-help-text' ).prop( 'hidden', false );\r\n },\r\n hideCommentHelpText: function ( domInput ) {\r\n jQuery( domInput ).closest( '.form-group' ).find( '.js-e-orderline-comment-help-text' ).prop( 'hidden', true );\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 }\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( e4.settings.modal.bodyNoAdjustmentClass );\r\n } ).on( 'hidden.bs.modal', function () {\r\n jBody.removeClass( e4.settings.modal.bodyNoAdjustmentClass );\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 }\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"]}