PageSourceSearch

https://martinique.microforce.com/themes/microforce/modules/g_rela…/js/front/g_relatedcrosssellingproducts.js

js microforce.com collected 2026-10-04 09:26:44 UTC 7,833 bytes, 182 lines download raw bytes

1/**
2* This is main js file. Don't edit the file if you want to update module in future.
3* 
4* @author    Globo Software Solution JSC <[email protected]>
5* @copyright 2018 Globo JSC
6* @license   please read license in file license.txt
7* @link	     http://www.globosoftware.net
8*/
9
10function loadOwlSlider(){
11    if($('.owl_slider').length > 0){
12        max_item = 4;
13        if($('body#cart').length > 0) max_item = 3;
14        $('.owl_slider').each(function(){
15            if(!$(this).hasClass('owl-loaded'))
16                $(this).owlCarousel({
17                    loop:true,
18                    margin:10,
19                    autoWidth: true,
20                    stagePadding: 57, // permet de voir les elements precedents et suivants dans la rubrique produits du moment
21                    responsiveClass:true,
22                    navText : [($('#prevtitle').length > 0 ? $('#prevtitle').html() : 'Prev'),($('#nexttitle').length > 0 ? $('#nexttitle').html() : 'Next')],
23                    responsive:{
24                        0:{
25                            items:1,
26                            nav:true
27                        },
28                        320:{
29                            items:1,
30                            nav:true
31                        },
32                        480:{
33                            items:2,
34                            nav:true,
35                            loop:false
36                        },
37                        768:{
38                            items:2,
39                            nav:true,
40                            loop:false
41                        },
42                        992:{
43                            items:3,
44                            nav:true,
45                            loop:false
46                        },
47                        1200:{
48                            items:max_item,
49                            nav:true,
50                            loop:false
51                        }
52                    }
53                });
54        });
55    }
56}
57$(document).ready(function(){
58    loadOwlSlider();
59    /* for prestashop 1.6 */
60    $(document).on('click','.globo_ajax_add_to_cart_button', function(e){
61        e.preventDefault();
62        if(!$(this).hasClass('disabled'))
63        {
64            idCombination = $(this).attr('data-ipa');
65            idProduct = $(this).attr('data-id-product');
66            dc = $(this).attr('data-dc');
67            $.ajax({
68        		type: 'POST',
69        		headers: { "cache-control": "no-cache" },
70        		url: baseUri + '?rand=' + new Date().getTime(),
71        		async: true,
72        		cache: false,
73        		dataType : "json",
74                data: 'controller=cart&add=1&ajax=true&qty=1&id_product=' + idProduct+'&ipa=' + idCombination + '&token=' + static_token+(dc == 1 ? '&dc=1' : '') ,
75                beforeSend: function(){
76                    $(this).addClass('disabled');
77                },
78                success: function(jsonData)
79                {
80                    ajaxCart.updateCartInformation(jsonData, 0);
81                    if (jsonData.crossSelling)
82						$('.crossseling').html(jsonData.crossSelling);
83                    if (idCombination)
84						$(jsonData.products).each(function(){
85							if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination))
86									ajaxCart.updateLayer(this);
87						});
88					else
89						$(jsonData.products).each(function(){
90							if (this.id != undefined && this.id == parseInt(idProduct))
91									ajaxCart.updateLayer(this);
92						});
93                    
94                },
95                error : function(XMLHttpRequest, textStatus, errorThrown){
96                    alert(XMLHttpRequest.responseText);
97                },
98                complete : function(){$(this).removeClass('disabled');}
99            }); 
100        } 
101        return false;
102    });
103    $(document).on('click','.globo_ajax_add_to_cart_button_multi', function(e){
104        e.preventDefault();
105        var parent_box = $(this).parents('.grelated_products_list');
106        parent_box.find('.alert').slideUp(500);
107        if(parent_box.find('.gproducts_multi').length > 0){
108            nbr_checked = parent_box.find('.gproducts_multi:checked').length;
109            if(nbr_checked > 0){ 
110                if(parent_box.hasClass('gps17')){
111                    parent_box.find('.gproducts_multi:checked').each(function(){
112                        idCombination = $(this).attr('data-ipa');
113                        idProduct = $(this).attr('data-id-product');
114                        dc = $(this).attr('data-dc');
115                        $.ajax({
116                    		type: 'POST',
117                    		headers: { "cache-control": "no-cache" },
118                    		url: parent_box.find('.gaction_link').val(),
119                    		async: true,
120                    		cache: false,
121                    		dataType : "json",
122                            data: 'update=1&ajax=true&qty=1&id_product=' + idProduct+'&ipa=' + idCombination + '&token=' 
122+ parent_box.find('.gaction_link_token').val()+(dc == 1 ? '&dc=1' : '') ,
123                            beforeSend: function(){
124                               
125                            },
126                            success: function(jsonData)
127                            {
128                            },
129                            complete : function(){
130                                nbr_checked = nbr_checked - 1;
131                                if(nbr_checked <=0){
132                                    window.location.href = parent_box.find('.gaction_link_show').val();
133                                }
134                            }
135                        }); 
136                      
137                    });
138                }else{
139                    parent_box.find('.gproducts_multi:checked').each(function(){
140                        idCombination = $(this).attr('data-ipa');
141                        idProduct = $(this).attr('data-id-product');
142                        dc = $(this).attr('data-dc');
143                        $.ajax({
144                            type: 'POST',
145                            headers: { "cache-control": "no-cache" },
146                            url: baseUri + '?rand=' + new Date().getTime(),
147                            async: true,
148                            cache: false,
149                            dataType : "json",
150                            data: 'controller=cart&add=1&ajax=true&qty=1&id_product=' + idProduct+'&ipa=' + idCombination + '&token=' + static_token+(dc == 1 ? '&dc=1' : '') ,
151                            beforeSend: function(){},
152                            success: function(jsonData){},
153                            error : function(XMLHttpRequest, textStatus, errorThrown){},
154                            complete : function(){
155                                nbr_checked = nbr_checked - 1;
156                                if(nbr_checked <=0){
157                                    window.location.href = parent_box.find('.gaction_link_show').val();
158                                }
159                            }
160                        });  
161                        });
162                }
163            }else{
164                parent_box.find('.alert-danger').slideDown(500);
165                $('html,body').animate({
166                    scrollTop: parent_box.find('.alert-danger').offset().top - 20
167                }, 'slow');
168            }
169        }else{
170            parent_box.find('.alert-danger').slideDown(500);
171            $('html,body').animate({
172                scrollTop: parent_box.find('.alert-danger').offset().top - 20
173            }, 'slow');
174        }
175        return false;
176    });
177    
178    $('.gproducts_multi').change(function(){
179        $(this).parents('.grelated_products_list').find('.alert-danger').slideUp(500);
180    })
181    
182})

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.