PageSourceSearch

https://jarofishing.pl/modules/leofeature/views/js/leofeature_compare.js

js jarofishing.pl collected 2026-10-06 04:48:35 UTC 8,403 bytes, 236 lines download raw bytes

1/**
2 * 2007-2017 Leotheme
3 *
4 * NOTICE OF LICENSE
5 *
6 * Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list 
7 *
8 * DISCLAIMER
9 *
10 *  @Module Name: Leo Feature
11 *  @author    leotheme <[email protected]>
12 *  @copyright 2007-2018 Leotheme
13 *  @license   http://leotheme.com - prestashop template provider
14 */
15$(document).ready(function(){
16	createLeoCompareModalPopup();
17	LeoCompareButtonAction();
18	prestashop.on('updateProductList', function() {
19		LeoCompareButtonAction();
20	});
21	//DONGND:: recall button action if need when change attribute at product page
22	prestashop.on('updatedProduct', function() {  
23		LeoCompareButtonAction();
24	});
25	prestashop.on('clickQuickView', function() {		
26		check_active_compare = setInterval(function(){
27			if($('.quickview.modal').length)
28			{			
29				$('.quickview.modal').on('shown.bs.modal', function (e) {
30					LeoCompareButtonAction();
31				})
32				clearInterval(check_active_compare);
33			}
34			
35		}, 300);
36		
37	});
38	activeEventModalCompare();
39});
40
41function createLeoCompareModalPopup()
42{
43	var leoCompareModalPopup = '';
44	leoCompareModalPopup += '<div class="modal leo-modal leo-modal-compare fade" tabindex="-1" role="dialog" aria-hidden="true">';
45		leoCompareModalPopup += '<div class="modal-dialog" role="document">';
46			leoCompareModalPopup += '<div class="modal-content">';
47				leoCompareModalPopup += '<div class="modal-header">';
48					leoCompareModalPopup += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">';
49						leoCompareModalPopup += '<span aria-hidden="true">&times;</span>';
50					leoCompareModalPopup += '</button>';
51					leoCompareModalPopup += '<h5 class="modal-title text-xs-center">';
52					leoCompareModalPopup += '</h5>';
53				leoCompareModalPopup += '</div>';
54			leoCompareModalPopup += '</div>';
55		leoCompareModalPopup += '</div>';
56	leoCompareModalPopup += '</div>';
57	$('body').append(leoCompareModalPopup);
58}
59function LeoCompareButtonAction()
60{
61	$('.leo-compare-button').click(function(){
62		if (!$('.leo-compare-button.active').length)
63		{
64			var total_product_compare = compared_products.length;
65			var id_product = $(this).data('id-product');
66			
67			var content_product_compare_mess_remove = productcompare_remove+'. <a href="'+productcompare_url+'" target="_blank"><strong>'+productcompare_viewlistcompare+'.</strong></a>';
68			var content_product_compare_mess_add = productcompare_add+'. <a href="'+productcompare_url+'" target="_blank"><strong>'+productcompare_viewlistcompare+'.</strong></a>';
69			var content_product_compare_mess_max = productcompare_max_item+'. <a href="'+productcompare_url+'" target="_blank"><strong>'+productcompare_viewlistcompare+'.</strong></a>';
70			
71			$(this).addClass('active');
72			$(this).find('.leo-compare-bt-loading').css({'display':'block'});
73			$(this).find('.leo-compare-bt-content').hide();
74			var object_e = $(this);
75			if ($(this).hasClass('added') || $(this).hasClass('delete'))
76			{
77				//DONGND:: remove product form list product compare
78				//DONGND:: add product to list product compare
79				$.ajax({
80					type: 'POST',
81					headers: {"cache-control": "no-cache"},
82					url: productcompare_url+ '?rand=' + new Date().getTime(),
83					async: true,
84					cache: false,
85					data: {
86						"ajax": 1,
87						"action": "remove",
88						"id_product": id_product,
89						"token": leo_token
90					},
91					success: function (result)
92					{
93						// console.log(result);
94						if (result == 1)
95						{
96							//Leotheme add: update number product on icon compare
97							if ($('.ap-btn-compare .ap-total-compare').length)
98							{
99								var old_num_compare = parseInt($('.ap-btn-compare .ap-total-compare').data('compare-total'));
100								var new_num_compare = old_num_compare-1;
101								$('.ap-btn-compare .ap-total-compare').data('compare-total',new_num_compare);
102								$('.ap-btn-compare .ap-total-compare').text(new_num_compare);
103							}
104													
105							compared_products.splice($.inArray(parseInt(id_product), compared_products), 1);
106							if (object_e.hasClass('delete'))
107							{
108								//DONGND:: remove from page product compare
109								if ($('.leo-productscompare-item').length == 1)
110								{								
111									window.location.replace(productcompare_url);
112								}
113								else
114								{
115									$('td.product-'+id_product).fadeOut(function(){
116										$(this).remove();
117										
118									});
119								}
120							}
121							else
122							{
123								//DONGND:: remove from page product list
124								$('.leo-modal-compare .modal-title').html(content_product_compare_mess_remove);
125								$('.leo-modal-compare').modal('show');
126								$('.leo-compare-button[data-id-product='+id_product+']').removeClass('added');
127								$('.leo-compare-button[data-id-product='+id_product+']').attr('title',buttoncompare_title_add);
128								$('.leo-compare-button[data-id-product='+id_product+'] .name-btn-product').html(buttoncompare_title_add);
129								// object_e.find('.leo-compare-bt-loading').hide();
130								// object_e.find('.leo-compare-bt-content').show();
131							}
132						}
133						else
134						{
135							$('.leo-modal-compare .modal-title').html(productcompare_remove_error);
136							$('.leo-modal-compare').modal('show');
137							
138						}
139						object_e.find('.leo-compare-bt-loading').hide();
140						object_e.find('.leo-compare-bt-content').show();
141					},
142					error: function (XMLHttpRequest, textStatus, errorThrown) {
143						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
144					}
145				});
146			}
147			else
148			{
149				if (total_product_compare < comparator_max_item)
150				{
151					//DONGND:: add product to list product compare
152					$.ajax({
153						type: 'POST',
154						headers: {"cache-control": "no-cache"},
155						url: productcompare_url+ '?rand=' + new Date().getTime(),
156						async: true,
157						cache: false,
158						data: {
159							"ajax": 1,
160							"action": "add",
161							"id_product": id_product,
162							"token": leo_token,
163						},
164						success: function (result)
165						{
166							// console.log(result);
167							if (result == 1)
168							{
169								$('.leo-modal-compare .modal-title').html(content_product_compare_mess_add);
170								$('.leo-modal-compare').modal('show');
171								//Leotheme add: update number product on icon compare
172								if ($('.ap-btn-compare .ap-total-compare').length)
173								{								
174									var old_num_compare = parseInt($('.ap-btn-compare .ap-total-compare').data('compare-total'));
175									var new_num_compare = old_num_compare+1;
176									$('.ap-btn-compare .ap-total-compare').data('compare-total',new_num_compare);
177									$('.ap-btn-compare .ap-total-compare').text(new_num_compare);
178								}
179								
180								compared_products.push(id_product);
181								$('.leo-compare-button[data-id-product='+id_product+']').addClass('added');
182								$('.leo-compare-button[data-id-product='+id_product+']').attr('title',buttoncompare_title_remove);
183								$('.leo-compare-button[data-id-product='+id_product+'] .name-btn-product').html(buttoncompare_title_remove);
184							}
185							else
186							{
187								$('.leo-modal-compare .modal-title').html(productcompare_add_error);
188								$('.leo-modal-compare').modal('show');
189							}
190							
191							object_e.find('.leo-compare-bt-loading').hide();
192							object_e.find('.leo-compare-bt-content').show();
193										
194						},
195						error: function (XMLHttpRequest, textStatus, errorThrown) {
196							alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
197						}
198					});
199					
200				}
201				else
202				{
203					//DONGND:: list product compare limited
204					$('.leo-modal-compare .modal-title').html(content_product_compare_mess_max);
205					$('.leo-modal-compare').modal('show');
206					object_e.find('.leo-compare-bt-loading').hide();
207					object_e.find('.leo-compare-bt-content').show();
208				}
209			}
210		}
211		return false;
212	})
213}
214
215function activeEventModalCompare()
216{
217	$('.leo-modal-compare').on('hide.bs.modal', function (e) {
218		// console.log($('.leo-modal-review-bt').length);
219		if ($('.leo-compare-button.active').length)
220		{
221			// console.log('aaa');
222			$('.leo-compare-button.active').removeClass('active');
223		}
224	})
225	$('.leo-modal-compare').on('hidden.bs.modal', function (e) {
226		$('body').css('padding-right', '');
227	})
228	$('.leo-modal-compare').on('shown.bs.modal', function (e) {
229		if ($('.quickview.modal').length)
230		{			
231			$('.quickview.modal').modal('hide');		
232		}
233	});
234}
235
236

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.