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 $(document).on('click', '#blockcart-content', function (e) { 34 e.stopPropagation(); 35 }); 36 37 38 prestashop.on( 39 'updateCart', 40 function (event) { 41 var refreshURL = $('#blockcart').data('refresh-url'); 42 var requestData = {}; 43 44 if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) { 45 46 requestData = { 47 id_customization: event.reason.idCustomization, 48 id_product_attribute: event.reason.idProductAttribute, 49 id_product: event.reason.idProduct, 50 action: event.reason.linkAction 51 }; 52 53 } 54 55 $.post(refreshURL, requestData).then(function (resp) { 56 57 $('#cart-toogle').html($(resp.preview).find('#cart-toogle').html()); 58 $('#blockcart-content').html($(resp.preview).find('#blockcart-content').html()); 59 60 $('#mobile-cart-products-count').text($(resp.preview).find('.cart-products-count-btn').first().text()); 61 62 63 prestashop.emit('updatedAjaxCart', {}); 64 if(event.reason.linkAction == 'delete-from-cart'){ 65 prestashop.emit('updateProductListAddToCart', 66 { 67 id_product: event.reason.idProduct, 68 id_product_attribute: event.reason.idProductAttribute, 69 new_html: event.reason.newAddBtn 70 }); 71 } else{ 72 prestashop.emit('updateProductListAddToCart', 73 { 74 id_product: event.reason.idProduct, 75 id_product_attribute: event.reason.idProductAttribute, 76 new_html: $(resp.preview).find('#updated-add-cart-btn-' + event.reason.idProduct + '-' + event.reason.idProductAttribute).html() 77 }); 78 } 79 if(event.reason.linkPlace == 'cart-preview'){ 80 prestashop.emit('updateProduct', {}); 81 } 82 83 if (resp.modal) { 84 showModal(resp.modal); 85 } 86 }).fail(function (resp) { 87 prestashop.emit('handleError', {eventType: 'updateShoppingCart', resp: resp}); 88 }); 89 90 if (event && event.resp && event.resp.hasError) { 91 prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')}); 92 let $toast = $('#cart-error-toast'); 93 $toast.html(event.resp.errors.join('<br/>')); 94 $toast.toast('show'); 95 } 96 } 97 ); 98 }); 99});
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.