PageSourceSearch

https://www.edisaxe.com/modules/ps_emailalerts/js/mailalerts.js

js edisaxe.com collected 2026-10-03 23:56:28 UTC 3,579 bytes, 103 lines download raw bytes

1/**
2 * 2007-2020 PrestaShop.
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 * DISCLAIMER
15 *
16 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
17 * versions in the future. If you wish to customize PrestaShop for your
18 * needs please refer to http://www.prestashop.com for more information.
19 *
20 * @author    PrestaShop SA <[email protected]>
21 * @copyright 2007-2020 PrestaShop SA
22 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
23 * International Registered Trademark & Property of PrestaShop SA
24 */
25
26function  addNotification(productId, productAttributeId) {
27  // to keep backward compatibility
28  if (typeof productId === 'undefined') {
29    var ids = $('div.js-mailalert > input[type=hidden]');
30    productId = ids.eq(0).val();
31    productIdAttribute = ids.eq(1).val();
32  }
33
34  $.ajax({
35    type: 'POST',
36    url: $('div.js-mailalert').data('url'),
37    data: 'id_product='+productId+'&id_product_attribute='+productAttributeId+'&customer_email='+$('div.js-mailalert > input[type=email]').val(),
38    success: function (resp) {
39      resp = JSON.parse(resp);
40
41      $('.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();
42      if (!resp.error) {
43        $('div.js-mailalert > .js-mailalert-add, div.js-mailalert > input[type=email], div.js-mailalert .gdpr_consent_wrapper').hide();
44      }
45    }
46  });
47  return false;
48}
49
50$(document).on('ready', function() {
51  const mailAlertSubmitButtonClass = '.js-mailalert-add';
52  const mailAlertWrapper = $('.js-mailalert');
53  const mailAlertSubmitButton = mailAlertWrapper.find(mailAlertSubmitButtonClass);
54
55  if (mailAlertWrapper.find('#gdpr_consent, .gdpr_consent').length) {
56    // We use a timeout to put this at the end of the callstack, so it's executed after GPDR module. 
57    setTimeout(() => {
58      mailAlertSubmitButton.prop('disabled', true);
59
60      mailAlertWrapper.find('[name="psgdpr_consent_checkbox"]').on('change', function (e) {
61        e.stopPropagation();
62      
63        mailAlertSubmitButton.prop('disabled', !$(this).prop('checked'));
64      });
65    }, 0);
66  }
67
68  $(document).on('click', mailAlertSubmitButtonClass, function (e)
69  {
70    e.preventDefault();
71
72    addNotification($(this).data('product'), $(this).data('product-attribute'));
73  });
74
75  $(document).on('click', '.js-remove-email-alert', function()
76  {
77    var self = $(this);
78    var ids = self.attr('rel').replace('js-id-emailalerts-', '');
79    ids = ids.split('-');
80    var id_product_mail_alert = ids[0];
81    var id_product_attribute_mail_alert = ids[1];
82    var parent = self.closest('li');
83
84    $.ajax({
85      url: self.data('url'),
86      type: "POST",
87      data: {
88        'id_product': id_product_mail_alert,
89        'id_product_attribute': id_product_attribute_mail_alert
90      },
91      success: function(result)
92      {
93        if (result == '0')
94        {
95          parent.fadeOut("normal", function()
96          {
97            parent.remove();
98          });
99        }
100      }
101    });
102  });
103});

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.