PageSourceSearch

https://www.pinglighting.com/modules/nrtwishlist/views/js/front.js

js pinglighting.com collected 2026-10-06 18:27:22 UTC 6,189 bytes, 208 lines download raw bytes

1$(document).ready(function() {
2	
3	wishlistRefreshStatus();
4
5	$('body').on('show.bs.modal','.quickview',(function() {
6		wishlistRefreshStatus();
7	}));
8	
9    prestashop.on('updatedProductList', function (e) {
10        wishlistRefreshStatus();
11    });
12	
13    prestashop.on('updatedProduct', function (e) {
14        wishlistRefreshStatus();
15    });
16	
17    prestashop.on('updatedProductAjax', function (e) {
18        wishlistRefreshStatus();
19    });
20	
21	$('body').on('click', '.js-wishlist-add', function (event) {
22		var self = this;
23		prestashop.emit('clickWishListAdd', {
24			dataset: self.dataset,
25			self: self
26		});
27		event.preventDefault();
28	});
29
30	$('body').on('click', '.js-wishlist-remove', function (event) {
31		var self = this;
32		prestashop.emit('clickWishListRemove', {
33			dataset: self.dataset
34		});
35		event.preventDefault();
36	});
37
38	$('body').on('click', '.js-wishlist-remove-all', function (event) {
39		var self = this;
40		prestashop.emit('clickWishListRemoveAll', {
41			dataset: self.dataset
42		});
43		event.preventDefault();
44	});
45
46	prestashop.on('clickWishListAdd', function (elm) {
47		
48		if($('.js-wishlist-btn-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).hasClass("loading")){
49			return;
50		}
51		
52		var data = {
53			'process': 'add',
54			'ajax': 1,
55			'idProduct': elm.dataset.idProduct,
56			'idProductAttribute': elm.dataset.idProductAttribute
57		};
58		
59		$('.js-wishlist-btn-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).addClass('loading');
60		
61		$.post(opWishList.actions, data, null, 'json').then(function (resp) {
62			if(!resp.is_logged){
63				wishlistShowLogin(elm.dataset.idProduct, elm.dataset.idProductAttribute);
64			}else{
65				opWishList.ids = resp.productsIds;
66				$('.js-wishlist-btn-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).removeClass('loading');
67				wishlistRefreshStatus();	
68			}
69			
70		}).fail(function (resp) {
71			prestashop.emit('handleError', { eventType: 'clickWishListAdd', resp: resp });
72		});
73	});
74
75	prestashop.on('clickWishListRemove', function (elm) {
76
77		if($('.js-wishlist-remove-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).hasClass("loading")){
78			return;
79		}
80		
81		var data = {
82			'process': 'remove',
83			'ajax': 1,
84			'idProduct': elm.dataset.idProduct,
85			'idProductAttribute': elm.dataset.idProductAttribute
86		};
87		
88		$('.js-wishlist-remove-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).addClass('loading');
89		
90		$.post(opWishList.actions, data, null, 'json').then(function (resp) {		
91			
92			if(!resp.is_logged){
93				wishlistShowLogin(elm.dataset.idProduct, elm.dataset.idProductAttribute);
94			}else{
95				$('.js-wishlist-' + elm.dataset.idProduct + '-' + elm.dataset.idProductAttribute).remove();
96				opWishList.ids = resp.productsIds;
97				wishlistRefreshStatus();
98				if (opWishList.ids.length == 0) {
99					$('#js-wishlist-table').remove();
100					$('#js-wishlist-warning').show();
101				}
102			}
103								
104		}).fail(function (resp) {
105			prestashop.emit('handleError', { eventType: 'clickWishListRemove', resp: resp });
106		});
107	});
108
109	prestashop.on('clickWishListRemoveAll', function (elm) {
110		
111		if($('.js-wishlist-remove-all').hasClass('loading')){
112			return;
113		}
114		
115		var data = {
116			'process': 'removeAll',
117			'ajax': 1
118		};
119		
120		$('.js-wishlist-remove-all').addClass('loading');
121		
122		$.post(opWishList.actions, data, null, 'json').then(function (resp) {
123			
124			opWishList.ids = resp.productsIds;
125			wishlistRefreshStatus();
126			
127			$('#js-wishlist-table').remove();
128			$('#js-wishlist-warning').show();
129		}).fail(function (resp) {
130			prestashop.emit('handleError', { eventType: 'clickWishListRemoveAll', resp: resp });
131		});
132	});
133	
134	function wishlistShowLogin($idProduct, $idProductAttribute)
135	{
136		var data = {
137			'process': 'login',
138			'ajax': 1,
139			'current_url': prestashop.urls.current_url
140		};
141		
142		$.post(opWishList.login, data, null, 'json').then(function (resp) {
143			$('#wishlist_login').html(resp.html);
144			$('#wishlist_login').find('input[name=email]').focus();
145			setTimeout(function(){
146				$('.modal:not(#modal_wishlist)').modal('hide');
147				$('#modal_wishlist').modal('show');
148				if(!(typeof $idProduct === 'undefined' || typeof $idProductAttribute === 'undefined')){
149					$('.js-wishlist-btn-' + $idProduct + '-' + $idProductAttribute).removeClass('loading');
150				}
151			}, 300);
152		}).fail(function (resp) {
153			prestashop.emit('handleError', { eventType: 'wishlistShowLogin', resp: resp });
154		});
155		
156	}
157		
158	function wishlistRefreshStatus()
159	{
160		$('.js-wishlist').each(function(){
161			
162			var $el = $(this);
163			var $idProduct = $el.data('id-product');
164			var $idProductAttribute = $el.data('id-product-attribute');		
165			
166			if (opWishList.ids.includes($idProduct + '-' + $idProductAttribute)){
167				$el.removeClass('js-wishlist-add').addClass('added');
168				$el.attr('href', opWishList.url);
169				$el.find('.text').text(opWishList.alert.view);
170				if (typeof $(this).attr('data-original-title') !== typeof undefined && $(this).attr('data-original-title') !== false) {
171					$el.attr('data-original-title', opWishList.alert.view);
172				}else{
173					$el.attr('title', opWishList.alert.view);
174				}
175			}else{
176				$el.addClass('js-wishlist-add').removeClass('added');
177				$el.find('.text').text(opWishList.alert.add);
178				if (typeof $(this).attr('data-original-title') !== typeof undefined && $(this).attr('data-original-title') !== false) {
179					$el.attr('data-original-title', opWishList.alert.add);
180				}else{
181					$el.attr('title', opWishList.alert.add);
182				}
183			}
184			
185			$el.addClass('js-wishlist-btn-'+$idProduct + '-' + $idProductAttribute);
186			
187		});
188		
189		$('.js-wishlist-nb').text(opWishList.ids.length);
190						
191	}
192	
193	$('#wishlist-clipboard-btn').on('click', function () {
194
195		var $this = $(this);
196
197		$this.closest('.input-group').find('input.js-to-clipboard').select();
198
199		if (document.execCommand('copy')) {
200			$this.text($this.data('textCopied'));
201			setTimeout(function () {
202				$this.text($this.data('textCopy'));
203			}, 1500);
204		}
205		
206	});
207	
208});

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.