PageSourceSearch

https://montagut.com/modules/hioutofstocknotification/views/js/front.js

js montagut.com collected 2026-10-08 01:33:21 UTC 12,045 bytes, 289 lines download raw bytes

1/**
2 * 2012 - 2024 HiPresta
3 *
4 * NOTICE OF LICENSE
5 *
6 * This source file is subject to the Academic Free License 3.0 (AFL-3.0).
7 * It is also available through the world-wide-web at this URL: https://opensource.org/licenses/AFL-3.0
8 *
9 * @author    HiPresta <[email protected]>
10 * @copyright HiPresta 2024
11 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
12 *
13 * @website   https://hipresta.com
14 */
15var hiOosn = {
16    subscribeUser: function($sel) {
17        $.ajax({
18            type: 'POST',
19            url:oosn_front_controller_url,
20            dataType: 'json',
21            data:{
22                action : 'oosn_email',
23                ajax: true,
24                email : $sel.find('[name=hi_stock_email]').val(),
25                secure_key : oosn_secure_key,
26                combination_id : $('[name=product_combination_id]').val(),
27                id_product : id_product,
28                oosn_qty : $sel.find('[name="oosn_qty"]').val(),
29            },
30            beforeSend: function(){
31                $('.oosn-button span').addClass('hi-oosn-hide');
32                $('.oosn-button img').removeClass('hi-oosn-hide');
33            },
34            success: function(response){
35                $('.oosn-button span').removeClass('hi-oosn-hide');
36                $('.oosn-button img').addClass('hi-oosn-hide');
37                if(response.hasError){
38                    if(response.error){
39                        if(response.field == 'qty'){
40                            $('.hi-oosn-invalid-qty').removeClass('hi-oosn-hide');
41                            $('.hi-oosn-invalid-qty span').html(response.error);
42                        } else {
43                            $('.hi-oosn-invalid-email').removeClass('hi-oosn-hide');
44                            $('.hi-oosn-invalid-email span').html(response.error);
45                        }
46                    }else
47                        $('.hi-oosn-invalid-email').addClass('hi-oosn-hide');
48                }else{
49                    $('.hi-oosn-success').removeClass('hi-oosn-hide');
50                    $('.oosn-popup, #hi-oosn-block').addClass('hi-oosn-hide');
51                    if (oosn_position == 'popup') {
52                        setTimeout(function(){
53                            $.fancybox.close();
54                        }, 2000);
55                    }
56                    
57                }
58            }
59        });
60    },
61
62    subscribeUserPLP: function($sel) {
63        var $this = $sel;
64        var $wrapper = $this.closest('.hi-oosn-popup-pl');
65
66        $.ajax({
67            type: 'POST',
68            url: oosn_front_controller_url,
69            dataType: 'json',
70            data: {
71                action : 'oosn_email',
72                ajax: true,
73                email : $wrapper.find('[name=hi_stock_email]').val(),
74                secure_key : oosn_secure_key,
75                combination_id : $this.attr('data-id-product-attribute'),
76                id_product : $this.attr('data-id-product'),
77                oosn_qty : $wrapper.find('[name="oosn_qty"]').val()
78            },
79            beforeSend: function(){
80                $wrapper.find('.oosn-button span').addClass('hi-oosn-hide');
81                $wrapper.find('.oosn-button img').removeClass('hi-oosn-hide');
82            },
83            success: function(response){
84                $wrapper.find('.oosn-button span').removeClass('hi-oosn-hide');
85                $wrapper.find('.oosn-button img').addClass('hi-oosn-hide');
86                if(response.hasError){
87                    if(response.error){
88                        if(response.field == 'qty'){
89                            $wrapper.find('.hi-oosn-invalid-qty').removeClass('hi-oosn-hide');
90                            $wrapper.find('.hi-oosn-invalid-qty span').html(response.error);
91                        } else {
92                            $wrapper.find('.hi-oosn-invalid-email').removeClass('hi-oosn-hide');
93                            $wrapper.find('.hi-oosn-invalid-email span').html(response.error);
94                        }
95                    }else
96                        $wrapper.find('.hi-oosn-invalid-email').addClass('hi-oosn-hide');
97                }else{
98                    $wrapper.find('.hi-oosn-success').removeClass('hi-oosn-hide');
99                    $wrapper.find('.oosn-popup, .hi-oosn-block-pl').addClass('hi-oosn-hide');
100                    setTimeout(function(){
101                        $.fancybox.close();
102                    }, 2000);
103                }
104            }
105        });
106    }
107};
108
109$(document).ready(function(){
110    if (psv >= 1.7) {
111        if(quantity <= 0){
112            $('.oosn-popup, #hi-oosn-block').removeClass('hi-oosn-hide');
113              $('#availability_statut').removeClass('hi-oosn-hide');
114        }
115        if(!$('[name=product_combination_id]').val() && id_combination){
116            $('[name=product_combination_id]').val(id_combination);
117        }
118
119        prestashop.on('updatedProduct', function (event) {
120            $('[name=product_combination_id]').val(event.id_product_attribute);
121             $.ajax({
122                type: 'POST',
123                dataType: 'json',
124                url:oosn_front_controller_url,
125                data:{
126                    action : 'get_product_combination_quantity',
127                    ajax : true,
128                    secure_key : oosn_secure_key,
129                    id_product : id_product,
130                    combination_id : event.id_product_attribute,
131                },
132                success: function(response){
133                    $('.hi-oosn-success').addClass('hi-oosn-hide');
134                      $('#availability_statut').addClass('hi-oosn-hide');
135                    if(response.quantity <= 0){
136                        $('.oosn-popup, #hi-oosn-block').removeClass('hi-oosn-hide');
137                          $('#availability_statut').removeClass('hi-oosn-hide');
138                    } else {
139                        $('.oosn-popup, #hi-oosn-block').addClass('hi-oosn-hide');
140                          $('#availability_statut').addClass('hi-oosn-hide');
141                    }
142
143                    initGDPROOSN();
144                }
145            });
146        });
147    } else {
148        if(quantity <= 0){
149            $('.oosn-popup, #hi-oosn-block').removeClass('hi-oosn-hide');
150              $('#availability_statut').removeClass('hi-oosn-hide');
151        }
152        if(typeof combinations != 'undefined' && oosn_stock_managment){
153            function hi_findCombination(){
154                setTimeout(function(){
155                    var choice = [];
156                    var radio_inputs = parseInt($('#attributes .checked > input[type=radio]').length);
157                    if (radio_inputs) {
158                        radio_inputs = '#attributes .checked > input[type=radio]';
159                    } else {
160                        radio_inputs = '#attributes input[type=radio]:checked';
161                    }
162                    $('#attributes select, #attributes input[type=hidden], ' + radio_inputs).each(function(){
163                        choice.push(parseInt($(this).val()));
164                    });
165                    for (var combination = 0; combination < combinations.length; ++combination){
166                        var combinationMatchForm = true;
167                        $.each(combinations[combination]['idsAttributes'], function(key, value){
168                            if (!in_array(value, choice)) {
169                                combinationMatchForm = false;
170                            }
171                        });
172                        if (combinationMatchForm){
173                            if (combinations[combination]['quantity'] <= 0) {
174                                $('.hi-oosn-success').addClass("hi-oosn-hide");
175                                $('.oosn-popup, #hi-oosn-block').removeClass('hi-oosn-hide');
176                                  $('#availability_statut').removeClass('hi-oosn-hide');
177                                $('[name=product_combination_id]').val(combinations[combination]['idCombination']);
178                            } else {
179                                $('.oosn-popup, #hi-oosn-block').addClass('hi-oosn-hide');
180                                  $('#availability_statut').addClass('hi-oosn-hide');
181                            }
182                        }
183                    }
184                }, 100);
185            }
186            hi_findCombination();
187            $('.color_pick, .attribute_radio').click(function(){
188                hi_findCombination();
189                $('.hi-oosn-success').addClass('hi-oosn-hide');
190                $('.hi-oosn-invalid-email').addClass('hi-oosn-hide');
191            });
192            $('#attributes select, #attributes input[type=hidden]').change(function(){
193                hi_findCombination();
194                $('.hi-oosn-success').addClass('hi-oosn-hide');
195                $('.hi-oosn-invalid-email').addClass('hi-oosn-hide');
196            });
197        }
198    }
199
200    $(document).on('keypress', '.hi_stock_email_pdp', function(e) {
201        if (e.keyCode == 13) {
202            e.preventDefault();
203
204            hiOosn.subscribeUser($(this).closest('#hi-oosn-block'));
205        }
206    });
207
208    $(document).on('click', '#submit_subscribe', function(e) {
209        e.preventDefault();
210
211        hiOosn.subscribeUser($(this).closest('#hi-oosn-block'));
212    });
213
214    $(document).on('click', '.hi-oosn-pl-submit-form', function(e) {
215        e.preventDefault();
216
217        hiOosn.subscribeUserPLP($(this));
218    });
219
220    $(document).on('keypress', '.hi_stock_email_plp', function(e) {
221        if (e.keyCode == 13) {
222            e.preventDefault();
223
224            hiOosn.subscribeUserPLP($(this).closest('.hi-oosn-popup-pl').find('.hi-oosn-pl-submit-form'));
225        }
226    });
227
228    $(document).on('click', '[name="hi_stock_email"], [name="oosn_qty"], .hi-oosn-invalid-email, .hi-oosn-invalid-qty', function(){
229        $('.hi-oosn-invalid-email, .hi-oosn-invalid-qty').addClass('hi-oosn-hide');
230    });
231
232    if (psv >= 1.7) {
233        prestashop.on('clickQuickView', function (event) {
234            setTimeout(function(){
235                initGDPROOSN();
236            }, 1000);
237            return false;
238        });
239    }
240
241
242    $('.oosn-popup').fancybox({
243        width: 450,
244        height: 'auto',
245        closeBtn: true,
246        fitToView : true,
247        autoSize : false,
248        closeClick : false,
249        autoscale : true,
250        padding: 0,
251        beforeShow : function() {
252            $('.modal.quickview').removeAttr('tabindex');
253        },
254        helpers: {
255            overlay: {
256              locked: false
257            }
258        }
259    });
260
261    // General data protection regulation 
262    initGDPROOSN();
263});
264
265function initGDPROOSN() {
266    var checkbox = $('.hi_psgdpr_consent_checkbox_oosn');
267    var element = $('#hi-oosn-block');
268    if (checkbox.is(':checked')) {
269        element.find('[type="submit"]').removeAttr('disabled');
270    } else if (checkbox.length) {
271        element.find('[type="submit"]').attr('disabled', 'disabled');
272    }
273    $(document).on('change', '.hi_psgdpr_consent_checkbox_oosn', function(){
274        var element = $('#hi-oosn-block');
275        if ($(this).is(':checked')) {
276            if (element.find('[type="submit"]').length > 0) {
277                element.find('[type="submit"]').removeAttr('disabled');
278            } else {
279                element.nextAll('[type="submit"]').removeAttr('disabled');
280            }
281        } else {
282            if (element.find('[type="submit"]').length > 0) {
283                element.find('[type="submit"]').attr('disabled', 'disabled');
284            } else {
285                element.nextAll('[type="submit"]').attr('disabled', 'disabled');
286            }
287        }
288    });
289}

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.