1window.feltrinelliAddToCart = { 2 addToCartCallback: null, 3 4 init: function () { 5 $('#btnCloseAddToCard').click(function (event) { 6 event.preventDefault(); 7 window.closeOverlay(document.getElementById('addToCartModal')); 8 9 if (feltrinelliAddToCart.addToCartCallback) { 10 feltrinelliAddToCart.addToCartCallback(); 11 feltrinelliAddToCart.addToCartCallback = null; 12 } 13 }); 14 15 $('#btnAddToCartGoToCheckout').click(function (event) { 16 17 event.preventDefault(); 18 19 window.closeOverlay(document.getElementById('addToCartModal')); 20 window.showLoader(); 21 22 const type = $(this).data('is-physical') ? 0 : 1; 23 const isUserLogged = $(this).data('is-user-logged'); 24 const isBrowserVersionSupported = $(this).data('is-browser-version-supported'); 25 26 if (isUserLogged) { 27 window.GoogleTagManagerLogic.beginCheckoutEvent(type).then(() => { 28 location.href = '/checkout-init/' + type; 29 }); 30 } else { 31 window.GoogleTagManagerLogic.viewCheckoutLoginEvent() 32 window.hideLoader(); 33 34 window.featureManagementFactory.openContextualLogin( 35 'checkout', 36 type, 37 isBrowserVersionSupported, 38 function () { 39 window.closeOverlay(document.getElementById('addToCartModal')); 40 feltrinelliAddToCart.addToCartCallback = null; 41 }); 42 } 43 }); 44 45 $('#btnAvailabilityInfo').click(function () { 46 const availabilityType = Number($(this).data('availability-type')); 47 const isMarketplace = $(this).data("is-marketplace") ? $(this).data("is-marketplace").toLowerCase() === 'true' : false; 48 const isLibraccio = $(this).data("is-libraccio") ? $(this).data("is-libraccio").toLowerCase() === 'true' : false; 49 const isUsed = $(this).data("is-used") ? $(this).data("is-used").toLowerCase() === 'true' : false; 50 const productType = $(this).data("product-type"); 51 window.feltrinelliAvailabilityInfoTooltip.open(availabilityType, isMarketplace, isLibraccio, isUsed, productType); 52 }); 53 }, 54 open: function (button, ean, inventoryId, isPhysical, quantityId, isGift, isBookAndCollect, callback, origin = '', originDetail = '', additionalInfo = null) { 55 if ($('#addToCartModal').length > 0) { 56 window.showLoader(); 57 58 $(button).addClass('loading'); 59 60 feltrinelliAddToCart.addToCartCallback = callback; 61 62 let quantity = 1; 63 64 if ($('#' + quantityId).length > 0) { 65 quantity = Number($('#' + quantityId).val()); 66 } else if (isNaN(quantityId) && quantityId > 0) { 67 quantity = quantityId; 68 } 69 70 if (isBookAndCollect && feltrinelliAddToCart.addToCartCallback) 71 feltrinelliAddToCart.addToCartCallback(); 72 73 $.ajax({
74 url: '/carrello/action/add-to-cart', 75 type: 'POST', 76 contentType: 'application/json', 77 data: JSON.stringify({ 78 ean: ean, 79 inventoryId: inventoryId, 80 isPhysical: isPhysical, 81 qty: quantity || 1, 82 isGift: isGift || false, 83 isModal: true, 84 additionalInfo: additionalInfo 85 }), 86 success: function (json) { 87 window.hideLoader(); 88 89 $('#addToCartModal .cc-atc-container').empty(); 90 $('#addToCartModal .cc-atc-container').html(json.html); 91 92 window.WebCollectService.trackCartActivity(json.Cart); 93 feltrinelliAddToCart.init(); 94 feltrinelliAddToCart.updateBasketCounters(); 95 $(button).removeClass('loading'); 96 97 if (feltrinelliAddToCart.addToCartCallback) { 98 if (document.location.pathname === "/carrello") { 99 feltrinelliAddToCart.addToCartCallback(isPhysical); 100 } else { 101 feltrinelliAddToCart.addToCartCallback(); 102 } 103 feltrinelliAddToCart.addToCartCallback = null; 104 } 105 106 if (typeof RRDynamic === 'function') { 107 RRDynamic(ean); 108 } 109 110 if (inventoryId != 0) { 111 let GTMDataRequest = [{ InventoryId: inventoryId, Ean: ean, Quantity: quantity, SitePosition: origin, SitePositionDetail: originDetail }]; 112 window.GoogleTagManagerLogic.addAddToCartEvent(GTMDataRequest); 113 } 114 115 window.openOverlay('addToCartModal'); 116 }, 117 error: function (xhr) { 118 window.hideLoader(); 119 window.showGenericErrorModal(); 120 } 121 }); 122 } 123 }, 124 updateBasketCounters: function () { 125 $.get('/basket-counters?a=' + Math.random(), function (r) { 126 globalHeader.header.UpdateBasketCounter(r.total.BasketCounter); 127 globalHeader.header.UpdateWishlistCounter(r.total.WishlistCounter); 128 }); 129 }, 130 oldAddToCartEvent: function (ean, quantity) { 131 if (dataLayer !== null) { 132 if (window.productForDataLayer && window.productForDataLayer !== null && window.productForDataLayer[ean]) { 133 var product = JSON.parse(window.productForDataLayer[ean]); 134 dataLayer.push({ 135 'event': 'addToCart', 136 'ecommerce': { 137 'currencyCode': 'EUR', 138 'add': { 139 'products': product 140 } 141 } 142 }); 143 } else if (typeof addToCart === 'function') { 144 addToCart(quantity !== undefined ? quantity : 1); 145 } 146 } 147 } 148}; 149 150$(document).ready(function () { 151 // feltrinelliAddToCart.init(); 152});
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.