1/* global $, prestashop */ 2 3/** 4 * This module exposes an extension point in the form of the `showModal` function. 5 * 6 * If you want to override the way the modal window is displayed, simply define: 7 * 8 * prestashop.blockcart = prestashop.blockcart || {}; 9 * prestashop.blockcart.showModal = function myOwnShowModal (modalHTML) { 10 * // your own code 11 * // please not that it is your responsibility to handle closing the modal too 12 * }; 13 * 14 * Attention: your "override" JS needs to be included **before** this file. 15 * The safest way to do so is to place your "override" inside the theme's main JS file. 16 * 17 */ 18 19jQuery.fn.tooltip = window._BStooltip; 20 21$(document).ready(function () { 22 prestashop.blockcart = prestashop.blockcart || {}; 23 24 var showModal = prestashop.blockcart.showModal || function (modal) {}; 25 26 $(document).ready(function () { 27 28 $(document).on('click', '#js-cart-close', function (e) { 29 $('#blockcart, #mobile-cart-wrapper, #_mobile_blockcart-content, #_desktop_blockcart-content').removeClass('show'); 30 e.stopPropagation(); 31 }); 32 33 34 prestashop.on( 35 'updateCart', 36 function (event) { 37 var refreshURL = $('#blockcart').data('refresh-url'); 38 var requestData = {}; 39 40 if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) { 41 42 requestData = { 43 id_customization: event.reason.idCustomization, 44 id_product_attribute: event.reason.idProductAttribute, 45 id_product: event.reason.idProduct, 46 action: event.reason.linkAction 47 }; 48 49 } 50 51 $.post(refreshURL, requestData).then(function (resp) { 52 53 $('#cart-toogle').html($(resp.preview).find('#cart-toogle').html()); 54 $('#blockcart-content').html($(resp.preview).find('#blockcart-content').html()); 55 56 $('#mobile-cart-products-count').text($(resp.preview).find('.cart-products-count-btn').first().text()); 57 58 59 prestashop.emit('updatedAjaxCart', {}); 60 if(event.reason.linkAction == 'delete-from-cart'){ 61 prestashop.emit('updateProductListAddToCart', 62 { 63 id_product: event.reason.idProduct, 64 id_product_attribute: event.reason.idProductAttribute, 65 new_html: event.reason.newAddBtn 66 }); 67 } else{ 68 prestashop.emit('updateProductListAddToCart', 69 { 70 id_product: event.reason.idProduct, 71 id_product_attribute: event.reason.idProductAttribute, 72 new_html: $(resp.preview).find('#updated-add-cart-btn-' + event.reason.idProduct + '-' + event.reason.idProductAttribute).html() 73 }); 74 } 75 if(event.reason.linkPlace == 'cart-preview'){ 76 prestashop.emit('updateProduct', {}); 77 } 78 79 if (resp.modal) { 80 showModal(resp.modal); 81 } 82 }).fail(function (resp) { 83 prestashop.emit('handleError', {eventType: 'updateShoppingCart', resp: resp}); 84 }); 85 86 if (event && event.resp && event.resp.hasError) { 87 prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')}); 88 let $toast = $('#cart-error-toast'); 89 $toast.html(event.resp.errors.join('<br/>')); 90 $toast.toast('show'); 91 } 92 } 93 ); 94 });
95});
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.