1/** 2 * 2007-2020 PrestaShop and Contributors 3 * 4 * NOTICE OF LICENSE 5 * 6 * This source file is subject to the Academic Free License 3.0 (AFL-3.0) 7 * that is bundled with this package in the file LICENSE.txt. 8 * It is also available through the world-wide-web at this URL: 9 * https://opensource.org/licenses/AFL-3.0 10 * If you did not receive a copy of the license and are unable to 11 * obtain it through the world-wide-web, please send an email 12 * to [email protected] so we can send you a copy immediately. 13 * 14 * @author PrestaShop SA <[email protected]> 15 * @copyright 2007-2020 PrestaShop SA and Contributors 16 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) 17 * International Registered Trademark & Property of PrestaShop SA 18 */ 19 20/** 21 * This module exposes an extension point through `showModal` function. 22 * 23 * If you want to customize the way the modal window is displayed, you need to do: 24 * 25 * prestashop.blockcart = prestashop.blockcart || {}; 26 * prestashop.blockcart.showModal = function myOwnShowModal (modalHTML) { 27 * // your own code 28 * // please not that it is your responsibility to handle the modal "close" behavior 29 * }; 30 * 31 * Warning: your custom JavaScript needs to be included **before** this file. 32 * The safest way to do so is to place your "override" inside the theme main JavaScript file. 33 * 34 */ 35 36$(document).ready(function () { 37 prestashop.blockcart = prestashop.blockcart || {}; 38 39 var showModal = prestashop.blockcart.showModal || function (modal) { 40 var $body = $('body'); 41 $body.append(modal); 42 $body.one('click', '#blockcart-modal', function (event) { 43 if (event.target.id === 'blockcart-modal') { 44 $(event.target).remove(); 45 } 46 }); 47 }; 48 49 prestashop.on( 50 'updateCart', 51 function (event) { 52 var refreshURL = $('.blockcart').data('refresh-url'); 53 var requestData = {}; 54 if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) { 55 requestData = { 56 id_customization: event.reason.idCustomization, 57 id_product_attribute: event.reason.idProductAttribute, 58 id_product: event.reason.idProduct, 59 action: event.reason.linkAction 60 }; 61 } 62 if (event && event.resp && event.resp.hasError) { 63 prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')}); 64 } 65 $.post(refreshURL, requestData).then(function (resp) { 66 var html = $('<div />').append($.parseHTML(resp.preview)); 67 $('.blockcart').replaceWith($(resp.preview).find('.blockcart')); 68 if (resp.modal) { 69 showModal(resp.modal); 70 } 71 }).fail(function (resp) { 72 prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp }); 73 }); 74 } 75 ); 76});
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.