1/** 2 * Copyright since 2007 PrestaShop SA and Contributors 3 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA 4 * 5 * NOTICE OF LICENSE 6 * 7 * This source file is subject to the Academic Free License version 3.0 8 * that is bundled with this package in the file LICENSE.md. 9 * It is also available through the world-wide-web at this URL: 10 * https://opensource.org/licenses/AFL-3.0 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to [email protected] so we can send you a copy immediately. 14 * 15 * @author PrestaShop SA and Contributors <[email protected]> 16 * @copyright Since 2007 PrestaShop SA and Contributors 17 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 18 */ 19 20function addNotification(productId, productAttributeId) { 21 // to keep backward compatibility 22 if (typeof productId === 'undefined') { 23 var ids = $('div.js-mailalert > input[type=hidden]'); 24 productId = ids.eq(0).val(); 25 productIdAttribute = ids.eq(1).val(); 26 } 27 28 $.ajax({ 29 type: 'POST', 30 url: $('div.js-mailalert').data('url'), 31 data: 'id_product='+productId+'&id_product_attribute='+productAttributeId+'&customer_email='+$('div.js-mailalert input[type=email]').val(), 32 success: function (resp) { 33 resp = JSON.parse(resp); 34 35 $('.js-mailalert-alerts').html('<article class="mt-1 alert alert-' + (resp.error ? 'danger' : 'success') + '" role="alert" data-alert="' + (resp.error ? 'error' : 'success') + '">'+ resp.message +'</article>').show(); 36 if (!resp.error) { 37 $('div.js-mailalert > .js-mailalert-add, div.js-mailalert > input[type=email], div.js-mailalert .gdpr_consent_wrapper').hide(); 38 } 39 } 40 }); 41 return false; 42} 43 44$(document).on('ready', function() { 45 const mailAlertSubmitButtonClass = '.js-mailalert-add'; 46 const mailAlertWrapper = $('.js-mailalert'); 47 const mailAlertSubmitButton = mailAlertWrapper.find(mailAlertSubmitButtonClass); 48 49 if (mailAlertWrapper.find('#gdpr_consent, .gdpr_consent').length) { 50 // We use a timeout to put this at the end of the callstack, so it's executed after GPDR module. 51 setTimeout(() => { 52 mailAlertSubmitButton.prop('disabled', true); 53 54 mailAlertWrapper.find('[name="psgdpr_consent_checkbox"]').on('change', function (e) { 55 e.stopPropagation(); 56 57 mailAlertSubmitButton.prop('disabled', !$(this).prop('checked')); 58 }); 59 }, 0); 60 } 61 62 $(document).on('click', mailAlertSubmitButtonClass, function (e) 63 { 64 e.preventDefault(); 65 66 addNotification($(this).data('product'), $(this).data('product-attribute')); 67 }); 68 69 $(document).on('click', '.js-remove-email-alert', function() 70 { 71 var self = $(this); 72 var ids = self.attr('rel').replace('js-id-emailalerts-', ''); 73 ids = ids.split('-'); 74 var id_product_mail_alert = ids[0]; 75 var id_product_attribute_mail_alert = ids[1]; 76 var parent = self.closest('li'); 77 78 $.ajax({ 79 url: self.data('url'), 80 type: "POST", 81 data: { 82 'id_product': id_product_mail_alert, 83 'id_product_attribute': id_product_attribute_mail_alert 84 }, 85 success: function(result) 86 { 87 if (result == '0') 88 { 89 parent.fadeOut("normal", function() 90 { 91 parent.remove(); 92 }); 93 } 94 } 95 }); 96 }); 97});
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.