PageSourceSearch

https://www.paris-prix.com/themes/parisprix/modules/ps_emailalerts/js/mailalerts.js

js paris-prix.com collected 2026-09-29 23:02:49 UTC 3,578 bytes, 130 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
26$(document).ready(function() {
27
28  $('#email-alert-modal').on('hidden.bs.modal', function() {
29    resetForm();
30    clearAlert();
31  })
32
33  $(document).on('click', '.js-mailalert-submit', function(e) {
34    e.preventDefault();
35    addNotification(e);
36  });
37
38  $('.js-remove-email-alert').on('click', function(e){
39    e.preventDefault();
40
41    var $self = $(this);
42    var ids = $self.attr('rel').replace('js-id-emailalerts-', '');
43    ids = ids.split('-');
44    var id_product_mail_alert = ids[0];
45    var id_product_attribute_mail_alert = ids[1];
46    var $parent = $self.closest('.js-mailalert-product-miniature');
47
48    $.ajax({
49      url: $self.data('url'),
50      type: "POST",
51      data: {
52        'id_product': id_product_mail_alert,
53        'id_product_attribute': id_product_attribute_mail_alert
54      },
55      success: function(result)
56      {
57        if (result == '0')
58        {
59          $parent.fadeOut("normal", function()
60          {
61            $parent.remove();
62          });
63        }
64      }
65    });
66  });
67
68  function resetForm() {
69    $('.js-mailalert-email').val('');
70    $('.js-mailalert [name=psgdpr_consent_checkbox]').prop('checked', false);
71  }
72
73  function  addNotification(e) {
74    var $idInputs = $('.js-mailalert-id-input');
75    var $emailInput = $('.js-mailalert-email');
76    var $btn = $(e.currentTarget);
77    var $modal = $('#email-alert-modal');
78
79    $btn.attr('disabled', true);
80
81    clearAlert();
82
83    $.ajax({
84      type: 'POST',
85      url: $('.js-mailalert').data('url'),
86      data: 'id_product=' + $idInputs[0].value + '&id_product_attribute=' + $idInputs[1].value + '&customer_email=' + $emailInput.val(),
87      success: function (resp) {
88        resp = JSON.parse(resp);
89        var alertType = resp.error ? 'danger' : 'success';
90
91        setAlert(resp.message, alertType);
92
93
94        if (resp.error) {
95          $btn.removeAttr('disabled');
96        } else {
97          setTimeout(function() {
98            $modal.modal('hide');
99            $('.js-mailalert-modal-btn').hide();
100          }, 2500);
101        }
102      }
103    });
104  }
105
106  function setAlert(message, type) {
107    var $alertBox = $('.js-mailalert-alert-box');
108    var $alert = $('<div>').addClass('alert');
109
110    if (type == 'success') {
111      $alert.addClass('alert-success');
112    } else if (type == 'danger') {
113      $alert.addClass('alert-danger');
114    }
115
116    $alert.text(message);
117
118    $alertBox.html($alert)
119  }
120
121  function clearAlert() {
122    $('.js-mailalert-alert-box').html('');
123  }
124  
125  
126$('.js-parent-focus .form-control').on('focus', function(e) {
127    $('.g-recaptcha').show();
128});
129  
130});

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.