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 19$(document).ready(function () { 20 prestashop.blockcart = prestashop.blockcart || {}; 21 22 var showModal = prestashop.blockcart.showModal || function (modal) { 23 var $body = $('body'); 24 $body.append(modal); 25 $body.one('click', '#blockcart-modal', function (event) { 26 if (event.target.id === 'blockcart-modal') { 27 $(event.target).remove(); 28 } 29 }); 30 }; 31 32 prestashop.on( 33 'updateCart', 34 function (event) { 35 var refreshURL = $('.blockcart').data('refresh-url'); 36 var requestData = {}; 37 if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) { 38 requestData = { 39 id_customization: event.reason.idCustomization, 40 id_product_attribute: event.reason.idProductAttribute, 41 id_product: event.reason.idProduct, 42 action: event.reason.linkAction 43 }; 44 45 $.post(refreshURL, requestData).then(function (resp) { 46 $('.blockcart').replaceWith($(resp.preview).find('.blockcart')); 47 if (resp.modal) { 48 showModal(resp.modal); 49 } 50 }).fail(function (resp) { 51 prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp }); 52 }); 53 } 54 if (event && event.resp && event.resp.hasError) { 55 prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')}); 56 } 57 } 58 ); 59});
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.