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 $(document).ready(function () { 33 prestashop.on( 34 'updateCart', 35 function (event) { 36 var refreshURL = $('.blockcart').data('refresh-url'); 37 var requestData = {}; 38 39 if (event && event.reason) { 40 requestData = { 41 id_product_attribute: event.reason.idProductAttribute, 42 id_product: event.reason.idProduct, 43 action: event.reason.linkAction 44 }; 45 } 46 47 if (event.resp.errors.length > 0) { 48 alert(event.resp.errors[0]); 49 return; 50 } 51 52 $.post(refreshURL, requestData).then(function (resp) { 53 $('.blockcart').replaceWith($(resp.preview).find('.blockcart')); 54 $('#blockcart-modal, .modal-backdrop').remove(); 55 if (resp.modal) { 56 showModal(resp.modal, event); 57 } 58 }).fail(function (resp) { 59 prestashop.emit('handleError', {eventType: 'updateShoppingCart', resp: resp}); 60 }); 61 } 62 ); 63 }); 64});
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.