PageSourceSearch

https://www.letoshop.gr/themes/sleedex/js/modules/blocknewsletter/blocknewsletter.js

js letoshop.gr collected 2026-10-09 01:53:11 UTC 5,765 bytes, 177 lines download raw bytes

1/*
2* 2007-2017 PrestaShop
3*
4* NOTICE OF LICENSE
5*
6* This source file is subject to the Academic Free License (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* http://opensource.org/licenses/afl-3.0.php
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-2017 PrestaShop SA
22*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
23*  International Registered Trademark & Property of PrestaShop SA
24*/
25$(document).ready(function() {
26    $('#newsletter-input').on({
27        keydown: function() {
28            blockNewsletter.reset();
29        },
30        focus: function() {
31            blockNewsletter.reset();
32        }
33    });
34
35    if (typeof msg_newsl != 'undefined' && msg_newsl) {
36        $('#newsletter-message-container')
37            .addClass('has-errors')
38            .text(alert_blocknewsletter);
39    }
40    
41    blockNewsletter.init();
42});
43
44var blockNewsletter = {
45    init: function() {
46        blockNewsletter.bindButton();
47        blockNewsletter.bindCheckbox();
48        blockNewsletter.bindForm();
49    },
50    reset: function() {
51        let $message = $('#newsletter-message-container');
52        let $label = $('#newsletter_footer_block label.accept-newsletter');
53        
54        $message.removeClass('has-errors');
55        $message.removeClass('success');
56        $message.html('');
57                
58        $label.css({
59            color: '#fff'
60        });
61    },
62    bindButton: function() {
63        let $button = $('#newsletter-register-button');
64        
65        $button.css({
66            cursor: 'not-allowed'
67        });
68        $button.on('click', blockNewsletter.register);
69    },
70    bindCheckbox: function() {
71        let $checkbox = $('#newsletter-checkbox');
72        
73        $checkbox.on('click', blockNewsletter.accept);
74    },
75    bindForm: function() {
76        let $form = $('#newsletter_footer_block form');
77        
78        $form.on('submit', blockNewsletter.register);
79    },
80    alertCheckbox: function() {
81        let $label = $('#newsletter_footer_block label.accept-newsletter');
82        
83        $label.css({
84            color: 'red'
85        });
86    },
87    accept: function() {
88        let $button = $('#newsletter-register-button');
89        let $checkbox = $('#newsletter-checkbox');
90        
91        if ($checkbox.is(':checked')) {
92            blockNewsletter.reset();
93            $button.css({
94                cursor: 'pointer'
95            });
96        } else {
97            $button.css({
98                cursor: 'not-allowed'
99            });
100        }
101    },
102    register: function(e) {
103        let $button = $('#newsletter-register-button');
104        let $checkbox = $('#newsletter-checkbox');
105        let email;
106        
107        e.preventDefault();
108        if (!$checkbox.is(':checked')) {
109            blockNewsletter.alertCheckbox();
110        } else {
111            email = $('#newsletter-input').val();
112            blockNewsletter.registerEmail(email);
113        }
114    },
115    registerEmail: function(email) {
116        $.ajax({
117            type: 'POST',
118            headers: { 
119                "cache-control": "no-cache"
120            },
121            url: baseUri + '?rand=' + new Date().getTime(),
122            async: false,
123            cache: false,
124            dataType : "json",
125            data: {
126                ajax: 1,
127                action: 'Register',
128                fc: 'module',
129                module: 'blocknewsletter',
130                controller: 'verification',
131                email: email,
132                token: static_token
133            },
134            success: function(jsonData) {
135                if (jsonData.hasErrors) {
136                    let errorsHtml = '<ul>';
137                    let error;
138                    
139                    for (error in jsonData.errors) {
140                        errorsHtml += '<li>' + jsonData.errors[error] + '</li>';
141                    }
142                    
143                    errorsHtml += '</ul>';
144                    
145                    $('#newsletter-message-container')
146                        .addClass('has-errors')
147                        .html(errorsHtml)
148                        .slideDown('slow');
149                } else {
150                    $('#newsletter-message-container')
151                        .addClass('success')
152                        .html(jsonData.message)
153                        .slideDown('slow');
154                }
155            },
156            error: function(XMLHttpRequest, textStatus, errorThrown) {
157                if (textStatus !== 'abort') {
158                    error = "TECHNICAL ERROR: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus;
159                    if (!!$.prototype.fancybox) {
160                        $.fancybox.open([
161                            {
162                                type: 'inline',
163                                autoScale: true,
164                                minHeight: 30,
165                                content: '<p class="fancybox-error">' + error + '</p>'
166                            }
167                        ], {
168                            padding: 0
169                        });
170                    } else {
171                        alert(error);
172                    }
173                }
174            }
175        });
176    }
177};

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.