PageSourceSearch

https://cabanes-auvergne.fr/wp-content/cache/min/1/be/modules/ModuleCart.js?ver=1787484640

js cabanes-auvergne.fr collected 2026-10-08 05:43:17 UTC 13,755 bytes, 17 lines download raw bytes

1(function($){$.widget("sqs.ModuleCart",$.sqs.resaModule,{widgetEventPrefix:"",options:{excludeIfNotPayor:!1,modifyCart:!0,validateCart:!1,bookId:'',stayId:'',labelStore:['LBL_cart','LBL_remove_stay','LBL_remove_stay_all','LBL_clear_cart',"LBL_precheckin_saved","LBL_selfcheckin_saved","LBL_selfcheckout_saved","LBL_info","LBL_remove_gift_voucher_to_consume"],showAddToCartPopup:!1,showAddToCartTimeout:20000,moveAddToCartPopup:undefined,confirm:!1,validateButtons:undefined,finalizeCartUrl:'',clearCartUrl:'',validateUrl:'',cancelUrl:'',redirectIfCartEmptyUrl:'',addToCartRedirectUrl:'',badStateRedirectionUrl:undefined,sendGtmIdentification:!1,purpose:'CREATION','sqs.cartemptyloaded':undefined,'sqs.clearcartdone':undefined,'sqs.removeFromCart':undefined,'sqs.cartValidated':undefined,'sqs.payments_confirmed':undefined,},_create:function(){this._super()},_beforeLoadTemplate:function(){var that=this;var def=$.Deferred();var promise=def.promise();if(this.options.confirm){this._post("confirm",{bookId:this.options.bookId}).done(function(e,data){that._trigger('sqs.payments_confirmed');def.resolve()})}else{promise=this._super()}
2return promise},_onLoad:function(data){var loadData=data.data;if(loadData.emptyCart===!0){this._trigger('sqs.cartemptyloaded');if(this.options.redirectIfCartEmptyUrl&&this.options.redirectIfCartEmptyUrl.length){this.redirect(this.options.redirectIfCartEmptyUrl)}}
3this.validateButtons=this.getElement(".form-validate-cart");if(this.options.validateButtons&&$(this.options.validateButtons).length){this.validateButtons=this.validateButtons.add($(this.options.validateButtons))}
4this._registerEvent(data);if(this.options.validateCart==!1){this.validateButtons.hide()}
5if(this.options.finalizeCartUrl==""){this.getElement(".form-finalize-cart").hide()}
6this.getElement(".cart_addtocart_popup").hide();var moveAddToCartPopupDestValid=this.options.moveAddToCartPopup!=undefined&&$(this.options.moveAddToCartPopup).length>0;if(this.options.showAddToCartPopup&&moveAddToCartPopupDestValid){var previousPopup=$(this.options.moveAddToCartPopup).find(".cart_addtocart_popup");previousPopup.remove();var popup=this.getElement(".cart_addtocart_popup");popup.detach();$(this.options.moveAddToCartPopup).append(popup)}
7if(data.actionData.actionName=="addToCart"){var addToCartRedirection=this.options.addToCartRedirectUrl;if(addToCartRedirection&&addToCartRedirection.trim().length){this.redirect(addToCartRedirection)}}
8var addtoCartPopup=moveAddToCartPopupDestValid?$(this.options.moveAddToCartPopup).find(".cart_addtocart_popup"):this.getElement(".cart_addtocart_popup");if(this.options.showAddToCartPopup&&this.options.finalizeCartUrl!=""&&(data.actionData.actionName=="addToCart"||data.actionData.actionName=="buy")){addtoCartPopup.css({opacity:0});addtoCartPopup.show();addtoCartPopup.animate({opacity:1},200);setTimeout(function hideAddToCartPopup(){addtoCartPopup.animate({opacity:0}
8,200,function(){addtoCartPopup.hide()})},this.options.showAddToCartTimeout);$('body').one('click',function(){addtoCartPopup.hide()});addtoCartPopup.on('click',function(){return!1})}else{addtoCartPopup.hide()}
9if(this.options.sendGtmIdentification==!0){this._sendIdentificationToGTM()}
10var that=this;this._post('isIntegratePayment',{}).done(function(data){if(data.data.isIntegratePayment===!0){console.log("envoie de l'event de paiement à GTM");that._sendPayToGTM()}})},_onRefresh:function(){},_getLoadParams:function(){return{bookId:this.options.bookId,badStateRedirectionUrl:this.options.badStateRedirectionUrl,purpose:this.options.purpose,onlyCreation:this.options.onlyCreation,excludeIfNotPayor:this.options.excludeIfNotPayor}},_registerEvent:function(data){var that=this;var loadData=data.data;if(this.options.modifyCart){this.getElement(".form-clear-cart").on('click',function(e){var cartItems=that.getElement(".cart-item").length;if(cartItems>0){var confirmCallback=function(){that.clearCart()};that.messageHandler.messageModule('onConfirm',{title:that.translatedLabels.LBL_cart,question:that.translatedLabels.LBL_clear_cart,confirmCallback:confirmCallback})}});this.getElement(".remove-from-cart").on('click',function(e){var stayId=$(this).attr('stay-id');var giftVoucherId=$(this).attr('gift-voucher-id');var wellnessCareId=$(this).attr('wellness-care-id');var productSoldId=$(this).attr('product-sold-id');var categoryId=$(this).attr('categoryId');var price=$(this).attr('price');var productName=$(this).attr('name');var currencyCode=$(this).attr('currencyCode');var from=$(this).attr('from');var to=$(this).attr('to');var element=$(this);var confirmCallback=function(){that._post('removeFromCart',{stayId:stayId,wellnessCareId:wellnessCareId,giftVoucherId:giftVoucherId,productSoldId:productSoldId}).done(function(data){that.closePopup();that._trigger("sqs.removeFromCart",null,data);that._sendRemoveFromCartToGTM(element);if(data.data.cartEmpty=="true"&&that.options.clearCartUrl&&that.options.clearCartUrl.length){that.redirect(that.options.clearCartUrl)}}).fail(function(errorData){that.messageHandler.messageModule('onMessage',{type:"error",message:errorData.MESSAGE})})};that.messageHandler.messageModule('onConfirm',{title:that.translatedLabels.LBL_cart,question:that.translatedLabels.LBL_remove_stay_all,confirmCallback:confirmCallback})});this.getElement(".remove-gift-voucher-to-consume-from-cart").on('click',function(){var element=$(this);var giftVoucherId=$(this).attr('gift-voucher-id');var giftVoucherRedeemId=$(this).attr('gift-voucher-redeem-id');var invPayLId=$(this).attr('inv-pay-l-id');var confirmCallback=function(){that._post('removeGiftVoucherToConsumeFromCart',{giftVoucherId:giftVoucherId,giftVoucherRedeemId:giftVoucherRedeemId,invPayLId:invPayLId}).done(function(data){that.closePopup();that._trigger("sqs.removeGiftVoucherToConsumeFromCart",null,data);if(data.data.cartEmpty=="true"&&that.options.clearCartUrl&&that.options.clearCartUrl.length){that.redirect(that.options.clearCartUrl)}}).fail(function(errorData){that.messageHandler.messageModule('onMessage',{type:"error",message:errorData.MESSAGE})})};that.messageHandler.messageModule('onConfirm',{title:that.translatedLabels.LBL_cart,question:that.translatedLabels.LBL_remove_gift_voucher_to_consume,confirmCallback:confirmCallback})})}else{this.getElement(".form-clear-cart").hide();this.getElement(".remove-from-cart").hide();this.getElement(".remove-gift-voucher-to-consume-from-cart").hide()}
11if(!this.options.validateCart&&!this.options.modifyCart){this.getElement(".book_promo_value").attr('disabled',!0)}
12this.validateButtons.off('click.cart');if(loadData.forupdate===!0){this.validateButtons.on('click.cart',function(e){if(that.options.purpose==="PRE_CHECKIN"){that._updateCart('LBL_precheckin_saved')}else if(that.options.purpose==="SELF_CHECKIN"){that._updateCart('LBL_selfcheckin_saved')}else if(that.options.purpose==="SELF_CHECKOUT"){that._updateCart('LBL_selfcheckout_saved')}else{that._updateCart('LBL_other_saved')}})}else{this.validateButtons.on('click.cart',function(e){that._post('updatePreempts').done(function(data){that.moduleManager.waitNoMoreAjax().done(function(){that._validateCart()})})})}
13this.getElement(".form-finalize-cart").on('click',function(e){that.redirect(that.options.finalizeCartUrl)});this.getElement(".channel_choice").on("change",function(){var channel_value=$(this).val();that._submitData("channel",{channel:channel_value})});that.promoCode=this.getElement(".book_promo_value").val();this.getElement(".book_promo_value").on("blur",function(e){var inputVal=$(this).val();if(that.promoCode!=inputVal){that.promoCode=inputVal;that._post('promoCode',{value:inputVal,})}});this.getElement(".book_promo_value").keypress(function(event){if(event.which==13){event.preventDefault();var inputVal=$(this).val();if(that.promoCode!=inputVal){that.promoCode=inputVal;that._post('promoCode',{value:inputVal,})}
14return!1}});that._sendConfirmToGTM()},clearCart:function(){return this._clearCart({clearCartAfterUpdate:!1})},_clearCart:function(params){var that=this;var def=$.Deferred();that._post('clear',params).done(function(data){that.closePopup();that._trigger('sqs.clearcartdone');that._sendClearCartToGTM();if(that.options.clearCartUrl&&that.options.clearCartUrl.length){that.redirect(that.options.clearCartUrl)}
15def.resolve()});return def.promise()},_updateCart:function(successLabel){var that=this;var validateUrl=this.options.validateUrl;var cancelUrl=this.options.cancelUrl;var purpose=this.options.purpose;var badStateRedirectionUrl=this.options.badStateRedirectionUrl;that._post('update',{validateUrl:validateUrl,cancelUrl:cancelUrl,purpose:purpose,badStateRedirectionUrl:badStateRedirectionUrl},function(data){if(data&&data.data&&(data.data.warning_code=='LOCK_LOST'||data.data.warning_code=='BAD_STATE')){that.loadFailCallback()}}).done(function(data){that._post('clear',{clearCartAfterUpdate:!0}).done(function(data){});that.closePopup();that._trigger("sqs.cartvalidated",null,data);if(data.data.redirectionHTML){document.write(data.data.redirectionHTML)}})},_validateCart:function(){var that=this;var validateUrl=this.options.validateUrl;var cancelUrl=this.options.cancelUrl;var navOverride=encodeURI(JSON.stringify(this.moduleManager.redirectTable));validateUrl=this.moduleManager._addRequestParameters(validateUrl,{'navOverride':navOverride});cancelUrl=this.moduleManager._addRequestParameters(cancelUrl,{'navOverride':navOverride});confirmCallback=function(){that._post('validate',{validateUrl:validateUrl,cancelUrl:cancelUrl}).done(function(data){that._sendPayToGTM();that.closePopup();that._trigger("sqs.cartvalidated",null,data);if(data.data.redirectionHTML){document.write(data.data.redirectionHTML)}})}
16var infirmCallback=function(){that.loadTemplate()};that._post('checkBeforePay').done(function(data){if(data.data.emptyCart){that.messageHandler.messageModule('onMessage',{type:"warning",message:data.data.emptyCart,close:function(){that.redirect(that.options.clearCartUrl)}})}else if(data.data.message){that.messageHandler.messageModule('onConfirm',{title:that.translatedLabels.LBL_info,question:data.data.message,width:500,confirmCallback:confirmCallback,infirmCallback:infirmCallback})}else{confirmCallback()}})}
16,getCartDetail:function(){var that=this;var details=this.getElement(".remove-from-cart");var products=[];$.each(details,function(key,value){var el=$(value);var productData=that.getGTMEcommerceProductDataFrom(el);productData.quantity=1;products.push(productData)});return products},_sendIdentificationToGTM:function(){if(typeof dataLayer!==typeof undefined){var products=this.getCartDetail();dataLayer.push({'event':'checkoutOption','ecommerce':{'checkout_option':{'actionField':{'step':2,'option':'Identification'},'products':products}}})}},_sendPayToGTM:function(){if(typeof dataLayer!==typeof undefined){var products=this.getCartDetail();dataLayer.push({'event':'checkoutOption','ecommerce':{'checkout_option':{'actionField':{'step':3,'option':'Pay'},'products':products}}})}},_sendConfirmToGTM:function(){if(this.options.confirm&&typeof dataLayer!==typeof undefined){this.options.confirm=!1;var products=this.getCartDetail();var totalPaidHtml=this.getElement(".gtm_total_paid");var transactionIdHtml=this.getElement(".gtm_transaction_id");var transactionId=transactionIdHtml.attr("transaction_code");var bookId=transactionIdHtml.attr("book_id");var that=this;if(bookId){that._post('getProductAlreadySend',{productsToTest:JSON.stringify(products),transactionId:transactionId,bookId:bookId}).done(function(data){if(data.data.products){const productToSend=JSON.parse(data.data.products);that.sendPurchaseToGtm(transactionId,productToSend)}})}}},_sendClearCartToGTM:function(){if(typeof dataLayer!==typeof undefined){var products=this.getCartDetail();dataLayer.push({'event':'removeFromCart','ecommerce':{'remove':{'products':products}}})}},_sendRemoveFromCartToGTM:function(element){var that=this;if(typeof dataLayer!==typeof undefined){var products=[];var productData=this.getGTMEcommerceProductDataFrom(element);productData.quantity=1;products.push(productData);var extraProds=element.closest('.cart-item-container').find('.stay_extra_prod');$.each(extraProds,function(idx,extraProd){extraProd=$(extraProd);var extraProductData=that.getGTMEcommerceProductDataFrom(extraProd);var quantity=extraProd.attr('quantity');if(quantity&&parseInt(quantity)>0){extraProductData.quantity=parseInt(quantity);products.push(extraProductData)}});dataLayer.push({'event':'removeFromCart','ecommerce':{'remove':{'products':products}}})}},_getPopUpOptions:function(){return{title:this.translatedLabels.LBL_cart}},getCartDetail:function(){var details=this.getElement(".gtm_stay");var products=[];var that=this;$.each(details,function(key,value){var element=$(value);var productData=that.getGTMEcommerceProductDataFrom(element);productData.quantity=1;products.push(productData)});$.each(this.getElement('.gtm_stay_extra_prod'),function(idx,extraProd){extraProd=$(extraProd);var productData=that.getGTMEcommerceProductDataFrom(extraProd);var quantity=extraProd.attr('quantity');if(quantity&&parseInt(quantity)>0){productData.quantity=parseInt(quantity);products.push(productData)}});return products},loadFailCallback:function(){if(this.options.badStateRedirectionUrl){this.redirect(this.options.badStateRedirectionUrl)}},_destroy:function(){this._super()},sendPurchaseToGtm:function(transactionId,productToSend){var totalPrice=0;for(var i=0;i<productToSend.length;i++){var price=parseFloat(productToSend[i].price);var quantity=parseFloat(productToSend[i].quantity);totalPrice+=price*quantity}
17if(productToSend.length>0){dataLayer.push({'event':'purchase','ecommerce':{'purchase':{'actionField':{'id':transactionId+"_"+new Date().getTime(),'revenue':totalPrice},'products':productToSend}}})}}})})(astJQuery)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.