PageSourceSearch

https://propperiet.dk/modules/leofeature/views/js/leofeature_compare.js

js propperiet.dk collected 2026-10-04 06:05:12 UTC 8,172 bytes, 234 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								// object_e.find('.leo-compare-bt-loading').hide();
129								// object_e.find('.leo-compare-bt-content').show();
130							}
131						}
132						else
133						{
134							$('.leo-modal-compare .modal-title').html(productcompare_remove_error);
135							$('.leo-modal-compare').modal('show');
136							
137						}
138						object_e.find('.leo-compare-bt-loading').hide();
139						object_e.find('.leo-compare-bt-content').show();
140					},
141					error: function (XMLHttpRequest, textStatus, errorThrown) {
142						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
143					}
144				});
145			}
146			else
147			{
148				if (total_product_compare < comparator_max_item)
149				{
150					//DONGND:: add product to list product compare
151					$.ajax({
152						type: 'POST',
153						headers: {"cache-control": "no-cache"},
154						url: productcompare_url+ '?rand=' + new Date().getTime(),
155						async: true,
156						cache: false,
157						data: {
158							"ajax": 1,
159							"action": "add",
160							"id_product": id_product,
161							"token": leo_token,
162						},
163						success: function (result)
164						{
165							// console.log(result);
166							if (result == 1)
167							{
168								$('.leo-modal-compare .modal-title').html(content_product_compare_mess_add);
169								$('.leo-modal-compare').modal('show');
170								//Leotheme add: update number product on icon compare
171								if ($('.ap-btn-compare .ap-total-compare').length)
172								{								
173									var old_num_compare = parseInt($('.ap-btn-compare .ap-total-compare').data('compare-total'));
174									var new_num_compare = old_num_compare+1;
175									$('.ap-btn-compare .ap-total-compare').data('compare-total',new_num_compare);
176									$('.ap-btn-compare .ap-total-compare').text(new_num_compare);
177								}
178								
179								compared_products.push(id_product);
180								$('.leo-compare-button[data-id-product='+id_product+']').addClass('added');
181								$('.leo-compare-button[data-id-product='+id_product+']').attr('title',buttoncompare_title_remove);
182							}
183							else
184							{
185								$('.leo-modal-compare .modal-title').html(productcompare_add_error);
186								$('.leo-modal-compare').modal('show');
187							}
188							
189							object_e.find('.leo-compare-bt-loading').hide();
190							object_e.find('.leo-compare-bt-content').show();
191										
192						},
193						error: function (XMLHttpRequest, textStatus, errorThrown) {
194							alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
195						}
196					});
197					
198				}
199				else
200				{
201					//DONGND:: list product compare limited
202					$('.leo-modal-compare .modal-title').html(content_product_compare_mess_max);
203					$('.leo-modal-compare').modal('show');
204					object_e.find('.leo-compare-bt-loading').hide();
205					object_e.find('.leo-compare-bt-content').show();
206				}
207			}
208		}
209		return false;
210	})
211}
212
213function activeEventModalCompare()
214{
215	$('.leo-modal-compare').on('hide.bs.modal', function (e) {
216		// console.log($('.leo-modal-review-bt').length);
217		if ($('.leo-compare-button.active').length)
218		{
219			// console.log('aaa');
220			$('.leo-compare-button.active').removeClass('active');
221		}
222	})
223	$('.leo-modal-compare').on('hidden.bs.modal', function (e) {
224		$('body').css('padding-right', '');
225	})
226	$('.leo-modal-compare').on('shown.bs.modal', function (e) {
227		if ($('.quickview.modal').length)
228		{			
229			$('.quickview.modal').modal('hide');		
230		}
231	});
232}
233
234

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.