This commit is contained in:
2025-03-21 20:24:43 +01:00
parent 224398df90
commit f34c9162d4
12427 changed files with 5329941 additions and 373384 deletions

View File

@@ -1,52 +1,72 @@
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <contact@prestashop.com>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
function addNotification() {
var ids = $('div.js-mailalert > input[type=hidden]');
function addNotification(productId, productAttributeId) {
// to keep backward compatibility
if (typeof productId === 'undefined') {
var ids = $('div.js-mailalert > input[type=hidden]');
productId = ids.eq(0).val();
productIdAttribute = ids.eq(1).val();
}
$.ajax({
type: 'POST',
url: $('div.js-mailalert').data('url'),
data: 'id_product='+ids[0].value+'&id_product_attribute='+ids[1].value+'&customer_email='+$('div.js-mailalert > input[type=email]').val(),
data: 'id_product='+productId+'&id_product_attribute='+productAttributeId+'&customer_email='+$('div.js-mailalert input[type=email]').val(),
success: function (resp) {
resp = JSON.parse(resp);
$('div.js-mailalert > span').html('<article class="alert alert-info" role="alert" data-alert="success">'+resp.message+'</article>').show();
$('.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();
if (!resp.error) {
$('div.js-mailalert > button').hide();
$('div.js-mailalert > input[type=email]').hide();
$('div.js-mailalert > #gdpr_consent').hide();
$('div.js-mailalert > .js-mailalert-add, div.js-mailalert > input[type=email], div.js-mailalert .gdpr_consent_wrapper').hide();
}
}
});
return false;
}
$('document').ready(function()
{
$('.js-remove-email-alert').click(function()
$(document).on('ready', function() {
const mailAlertSubmitButtonClass = '.js-mailalert-add';
const mailAlertWrapper = $('.js-mailalert');
const mailAlertSubmitButton = mailAlertWrapper.find(mailAlertSubmitButtonClass);
if (mailAlertWrapper.find('#gdpr_consent, .gdpr_consent').length) {
// We use a timeout to put this at the end of the callstack, so it's executed after GPDR module.
setTimeout(() => {
mailAlertSubmitButton.prop('disabled', true);
mailAlertWrapper.find('[name="psgdpr_consent_checkbox"]').on('change', function (e) {
e.stopPropagation();
mailAlertSubmitButton.prop('disabled', !$(this).prop('checked'));
});
}, 0);
}
$(document).on('click', mailAlertSubmitButtonClass, function (e)
{
e.preventDefault();
addNotification($(this).data('product'), $(this).data('product-attribute'));
});
$(document).on('click', '.js-remove-email-alert', function()
{
var self = $(this);
var ids = self.attr('rel').replace('js-id-emailalerts-', '');