PageSourceSearch

https://sklepwaneko.pl/modules/stfeature/views/js/stfeature_wishlist.js

js sklepwaneko.pl collected 2026-10-02 23:59:18 UTC 41,352 bytes, 1,135 lines download raw bytes

1/**
2 * 2010-2019 Codezeel
3 *
4 * NOTICE OF LICENSE
5 *
6 * Tm feature for prestashop 1.7: compare, wishlist at product list 
7 *
8 * DISCLAIMER
9 *
10 *  @Module Name: CZ Feature
11 *  @author    codezeel <[email protected]>
12 *  @copyright 2010-2019 codezeel
13 *  @license   http://www.codezeel.com - prestashop template provider
14 */
15$(document).ready(function(){
16	createStWishlistModalPopup();
17	StWishlistButtonAction();
18	prestashop.on('updateProductList', function() {
19		StWishlistButtonAction();
20	});
21	prestashop.on('clickQuickView', function() {		
22		check_active_wishlist = setInterval(function(){
23			if($('.quickview.modal').length)
24			{			
25				$('.quickview.modal').on('shown.bs.modal', function (e) {
26					StWishlistButtonAction();
27				})
28				clearInterval(check_active_wishlist);
29			}
30			
31		}, 300);
32		
33	});
34	
35	// $('.quickview.modal').on('shown.bs.modal', function (e) {
36			// console.log('aaa');
37	// })
38	activeEventModalWishlist();
39	StListWishlistAction();
40	$('.st-save-wishlist-bt').click(function(){
41		if (!$(this).hasClass('active'))
42		{
43			$(this).addClass('active');
44			$('.new-wishlist .has-danger .form-control-feedback').html('');
45			$('.new-wishlist .has-success .form-control-feedback').html('');
46			var name_wishlist = $.trim($('#wishlist_name').val());
47			if (!name_wishlist)
48			{
49				$('#wishlist_name').parent().addClass('has-error');
50				$(this).removeClass('active');
51			}
52			else
53			{
54				var object_e = $(this);
55				$('#wishlist_name').parent().removeClass('has-error');
56				$('.st-save-wishlist-bt-text').hide();
57				$('.st-save-wishlist-loading').css({'display':'block'});
58				$.ajax({
59					type: 'POST',
60					headers: {"cache-control": "no-cache"},
61					url: wishlist_url,
62					async: true,
63					cache: false,
64					data: {
65						"ajax": 1,
66						"action": "add-wishlist",
67						"name_wishlist": name_wishlist,					
68					},
69					success: function (result)
70					{
71						var object_result = $.parseJSON(result);
72						if (object_result.errors.length)
73						{
74							// console.log(object_result.errors);
75							$('.new-wishlist .has-success .form-control-feedback').html('');
76							$('.new-wishlist .has-danger .form-control-feedback').html(object_result.errors).fadeIn();
77						}
78						else
79						{
80							$('.new-wishlist .has-danger .form-control-feedback').html('');
81							$('.new-wishlist .has-success .form-control-feedback').html(object_result.result.message).fadeIn();
82							setTimeout(function() {
83								$('.new-wishlist .has-success .form-control-feedback').fadeOut();
84							}, 3000);
85							$('#wishlist_name').val('');
86							
87							$('.list-wishlist table tbody').append(object_result.result.wishlist);
88							$('html, body').animate({
89								scrollTop: $('.list-wishlist table tr.new').offset().top
90							}, 500, function (){
91								$('.list-wishlist table tr.new').removeClass('new');
92							});
93							StListWishlistAction();
94							//DONGND:: reload list product if a wishlist current view
95							$('.list-wishlist tr.show .view-wishlist-product').trigger('click');
96						}
97						$('.st-save-wishlist-bt-text').show();
98						$('.st-save-wishlist-loading').hide();
99						object_e.removeClass('active');
100					},
101					error: function (XMLHttpRequest, textStatus, errorThrown) {
102						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
103					}
104				});
105				
106			}
107		}
108		return false;
109	})
110});
111
112function createStWishlistModalPopup()
113{
114	var leoWishlistModalPopup = '';
115	leoWishlistModalPopup += '<div class="modal st-modal st-modal-wishlist fade" tabindex="-1" role="dialog" aria-hidden="true">';
116		leoWishlistModalPopup += '<div class="modal-dialog" role="document">';
117			leoWishlistModalPopup += '<div class="modal-content">';
118				leoWishlistModalPopup += '<div class="modal-header">';
119					leoWishlistModalPopup += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">';
120						leoWishlistModalPopup += '<span aria-hidden="true">&times;</span>';
121					leoWishlistModalPopup += '</button>';
122					leoWishlistModalPopup += '<h5 class="modal-title text-xs-center">';
123					leoWishlistModalPopup += '</h5>';
124				leoWishlistModalPopup += '</div>';
125				leoWishlistModalPopup += '<div class="modal-footer">';			
126					leoWishlistModalPopup += '<button type="button" class="btn btn-secondary" data-dismiss="modal">'+wishlist_cancel_txt+'</button>';
127					leoWishlistModalPopup += '<button type="button" class="st-modal-wishlist-bt btn btn-primary">';						
128						leoWishlistModalPopup += '<span class="st-modal-wishlist-loading cssload-speeding-wheel"></span>';
129						leoWishlistModalPopup += '<span class="st-modal-wishlist-bt-text">';
130							leoWishlistModalPopup += wishlist_ok_txt;
131						leoWishlistModalPopup += '</span>';
132					leoWishlistModalPopup += '</button>';				
133				leoWishlistModalPopup += '</div>';
134			leoWishlistModalPopup += '</div>';
135		leoWishlistModalPopup += '</div>';
136	leoWishlistModalPopup += '</div>';
137	$('body').append(leoWishlistModalPopup);
138}
139
140function StWishlistButtonAction()
141{
142	if (!$('.st-wishlist-button').hasClass('show-list'))
143	{
144		$('.st-wishlist-button').click(function(){
145			if (!$('.st-wishlist-button.active').length)
146			{			
147				var id_product = $(this).data('id-product');
148				var id_wishlist = $(this).data('id-wishlist');
149				var id_product_attribute = $(this).data('id-product-attribute');
150				var content_wishlist_mess_remove = wishlist_remove+'. <a href="'+wishlist_url+'" target="_blank"><strong>'+wishlist_viewwishlist+'.</strong></a>';
151				var content_wishlist_mess_add = wishlist_add+'. <a href="'+wishlist_url+'" target="_blank"><strong>'+wishlist_viewwishlist+'.</strong></a>';			
152				
153				$(this).addClass('active');
154				
155				if (!isLogged)
156				{
157					$('.st-modal-wishlist .modal-title').html(wishlist_loggin_required);
158					$('.st-modal-wishlist').modal('show');
159					return false;
160				}
161				
162				var object_e = $(this);
163				object_e.find('.st-wishlist-bt-loading').css({'display':'block'});
164				//object_e.find('.st-wishlist-bt-content').hide();
165				if ($(this).hasClass('added') || $(this).hasClass('delete'))
166				{
167					//DONGND:: remove product form wishlist				
168					$.ajax({
169						type: 'POST',
170						headers: {"cache-control": "no-cache"},
171						url: wishlist_url,
172						async: true,
173						cache: false,
174						data: {
175							"ajax": 1,
176							"action": "remove",
177							"id_product": id_product,
178							"id_wishlist": id_wishlist,
179							"id_product_attribute": id_product_attribute,
180							"quantity": 1,
181						},
182						success: function (result)
183						{
184							var object_result = $.parseJSON(result);
185							if (object_result.errors.length)
186							{
187								$('.st-modal-wishlist .modal-title').html(object_result.errors);
188								$('.st-modal-wishlist').modal('show');
189							}
190							else
191							{
192								//Sttheme add: update number product on icon wishlist after remove from wishlist								
193								if ($('.ap-btn-wishlist .ap-total-wishlist').length)
194								{								
195									var old_num_wishlist = parseInt($('.ap-btn-wishlist .ap-total-wishlist').text());
196									var new_num_wishlist = old_num_wishlist-1;
197									$('.ap-btn-wishlist .ap-total-wishlist').text(new_num_wishlist);
198								}
199								
200								// compared_products.splice($.inArray(parseInt(id_product), compared_products), 1);
201								if (object_e.hasClass('delete'))
202								{
203									//DONGND:: remove from page wishlist
204									$('td.product-'+id_product).fadeOut(function(){
205										$(this).remove();
206									});
207								}
208								else
209								{	
210									//DONGND:: remove from page product list
211									$('.st-modal-wishlist .modal-title').html(content_wishlist_mess_remove);
212									$('.st-modal-wishlist').modal('show');
213									$('.st-wishlist-button[data-id-product='+id_product+']').removeClass('added');
214									$('.st-wishlist-button[data-id-product='+id_product+']').attr('title',buttonwishlist_title_add);
215									$('.st-wishlist-button[data-id-product='+id_product+'] .st-wishlist-bt-content .ajax_wishlist_text').text(buttonwishlist_title_add);
216									object_e.find('.st-wishlist-bt-loading').hide();
217									//object_e.find('.st-wishlist-bt-content').show();
218								}
219							}
220						},
221						error: function (XMLHttpRequest, textStatus, errorThrown) {
222							alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
223						}
224					});
225				}
226				else
227				{
228
229					//DONGND:: add product to list product wishlist
230					$.ajax({
231						type: 'POST',
232						headers: {"cache-control": "no-cache"},
233						url: wishlist_url,
234						async: true,
235						cache: false,
236						data: {
237							"ajax": 1,
238							"action": "add",
239							"id_product": id_product,
240							"id_wishlist": id_wishlist,
241							"id_product_attribute": id_product_attribute,
242							"quantity": 1,
243						},
244						success: function (result)
245						{
246							var object_result = $.parseJSON(result);
247							if (object_result.errors.length)
248							{
249								$('.st-modal-wishlist .modal-title').html(object_result.errors);
250								$('.st-modal-wishlist').modal('show');
251							}
252							else
253							{
254								$('.st-modal-wishlist .modal-title').html(content_wishlist_mess_add);
255								$('.st-modal-wishlist').modal('show');
256								//Sttheme add: update number product on icon wishlist after add from wishlist								
257								if ($('.ap-btn-wishlist .ap-total-wishlist').length)
258								{								
259									var old_num_wishlist = parseInt($('.ap-btn-wishlist .ap-total-wishlist').text());
260									var new_num_wishlist = old_num_wishlist+1;
261									$('.ap-btn-wishlist .ap-total-wishlist').text(new_num_wishlist);
262								}
263								
264								// console.log(object_result.result.id_wishlist);
265								//DONGND:: update id wishlist if the first add of user
266								if (id_wishlist == '')
267								{
268									$('.st-wishlist-button').data('id-wishlist', object_result.result.id_wishlist);
269									// wishlist_products[object_result.result.id_wishlist].push(id_product);
270								}
271								// else
272								// {
273									// wishlist_products[id_wishlist].push(id_product);
274								// }
275								
276								$('.st-wishlist-button[data-id-product='+id_product+']').addClass('added');
277								$('.st-wishlist-button[data-id-product='+id_product+']').attr('title',buttonwishlist_title_remove);
278								$('.st-wishlist-button[data-id-product='+id_product+'] .st-wishlist-bt-content .ajax_wishlist_text').text(buttonwishlist_title_remove);
279								object_e.find('.st-wishlist-bt-loading').hide();
280								//object_e.find('.st-wishlist-bt-content').show();
281							}
282																		
283						},
284						error: function (XMLHttpRequest, textStatus, errorThrown) {
285							alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
286						}
287					});										
288				}
289			}
290			return false;
291		})
292	}
293	else
294	{
295			//DONGND:: add/remove wishlist with list wishlist
296			$('.wishlist-item').click(function(){
297				if (!$('.wishlist-item.active-add').length)
298				{			
299					var id_product = $(this).data('id-product');
300					var id_wishlist = $(this).data('id-wishlist');
301					var id_product_attribute = $(this).data('id-product-attribute');
302					var content_wishlist_mess_remove = wishlist_remove+'. <a href="'+wishlist_url+'" target="_blank"><strong>'+wishlist_viewwishlist+'.</strong></a>';
303					var content_wishlist_mess_add = wishlist_add+'. <a href="'+wishlist_url+'" target="_blank"><strong>'+wishlist_viewwishlist+'.</strong></a>';			
304					
305					$(this).addClass('active-add');
306					
307					if (!isLogged)
308					{
309						$('.st-modal-wishlist .modal-title').html(wishlist_loggin_required);
310						$('.st-modal-wishlist').modal('show');
311						return false;
312					}
313					
314					var object_e = $(this);
315					var parents_e = object_e.parents('.st-wishlist-button-dropdown');
316					parents_e.find('.st-wishlist-button').addClass('active');
317					parents_e.find('.st-wishlist-bt-loading').css({'display':'block'});
318					//parents_e.find('.st-wishlist-bt-content').hide();
319					if ($(this).hasClass('added') || $(this).hasClass('delete'))
320					{
321						//DONGND:: remove product form wishlist				
322						$.ajax({
323							type: 'POST',
324							headers: {"cache-control": "no-cache"},
325							url: wishlist_url,
326							async: true,
327							cache: false,
328							data: {
329								"ajax": 1,
330								"action": "remove",
331								"id_product": id_product,
332								"id_wishlist": id_wishlist,
333								"id_product_attribute": id_product_attribute,
334								"quantity": 1,
335							},
336							success: function (result)
337							{
338								var object_result = $.parseJSON(result);
339								if (object_result.errors.length)
340								{
341									$('.st-modal-wishlist .modal-title').html(object_result.errors);
342									$('.st-modal-wishlist').modal('show');
343								}
344								else
345								{
346									//Sttheme add: update number product on icon wishlist after remove from wishlist								
347									if ($('.ap-btn-wishlist .ap-total-wishlist').length)
348									{								
349										var old_num_wishlist = parseInt($('.ap-btn-wishlist .ap-total-wishlist').text());
350										var new_num_wishlist = old_num_wishlist-1;
351										$('.ap-btn-wishlist .ap-total-wishlist').text(new_num_wishlist);
352									}
353									
354									// compared_products.splice($.inArray(parseInt(id_product), compared_products), 1);
355									if (object_e.hasClass('delete'))
356									{
357										//DONGND:: remove from page wishlist
358										$('td.product-'+id_product).fadeOut(function(){
359											$(this).remove();
360										});
361									}
362									else
363									{
364										//DONGND:: remove from page product list
365										$('.st-modal-wishlist .modal-title').html(content_wishlist_mess_remove);
366										$('.st-modal-wishlist').modal('show');
367										
368										$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+']').removeClass('added');
369										$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+']').attr('title',buttonwishlist_title_add);
370										$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+'] .st-wishlist-bt-content .ajax_wishlist_text').text(buttonwishlist_title_add);
371										if (!$('.wishlist-item[data-id-product='+id_product+']').hasClass('added'))
372										{
373											$('.st-wishlist-button[data-id-product='+id_product+']').removeClass('added');
374										}
375										
376										parents_e.find('.st-wishlist-bt-loading').hide();
377										//parents_e.find('.st-wishlist-bt-content').show();
378										parents_e.find('.st-wishlist-button').removeClass('active');
379									}
380								}
381							},
382							error: function (XMLHttpRequest, textStatus, errorThrown) {
383								alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
384							}
385						});
386					}
387					else
388					{
389
390						//DONGND:: add product to list product wishlist
391						$.ajax({
392							type: 'POST',
393							headers: {"cache-control": "no-cache"},
394							url: wishlist_url,
395							async: true,
396							cache: false,
397							data: {
398								"ajax": 1,
399								"action": "add",
400								"id_product": id_product,
401								"id_wishlist": id_wishlist,
402								"id_product_attribute": id_product_attribute,
403								"quantity": 1,
404							},
405							success: function (result)
406							{
407								// console.log(result);
408								var object_result = $.parseJSON(result);
409								if (object_result.errors.length)
410								{
411									$('.st-modal-wishlist .modal-title').html(object_result.errors);
412									$('.st-modal-wishlist').modal('show');
413								}
414								else
415								{
416									$('.st-modal-wishlist .modal-title').html(content_wishlist_mess_add);
417									$('.st-modal-wishlist').modal('show');
418									//Sttheme add: update number product on icon wishlist after add from wishlist								
419									if ($('.ap-btn-wishlist .ap-total-wishlist').length)
420									{								
421										var old_num_wishlist = parseInt($('.ap-btn-wishlist .ap-total-wishlist').text());
422										var new_num_wishlist = old_num_wishlist+1;
423										$('.ap-btn-wishlist .ap-total-wishlist').text(new_num_wishlist);
424									}
425									
426									// console.log(object_result.result.id_wishlist);
427						
428									$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+']').addClass('added');
429									$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+']').attr('title',buttonwishlist_title_remove);
430									$('.wishlist-item[data-id-wishlist='+id_wishlist+'][data-id-product='+id_product+'] .st-wishlist-bt-content .ajax_wishlist_text').text(buttonwishlist_title_remove);
431									if (!$('.st-wishlist-button[data-id-product='+id_product+']').hasClass('added'))
432									{
433										$('.st-wishlist-button[data-id-product='+id_product+']').addClass('added');
434									}
435									
436									parents_e.find('.st-wishlist-bt-loading').hide();
437									//parents_e.find('.st-wishlist-bt-content').show();
438									parents_e.find('.st-wishlist-button').removeClass('active');
439								}
440																			
441							},
442							error: function (XMLHttpRequest, textStatus, errorThrown) {
443								alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
444							}
445						});										
446					}
447				}
448				return false;
449			});
450		// });
451		
452	}
453	
454}
455
456function StListWishlistAction()
457{
458	//DONGND:: click delete wishlist
459	$('.delete-wishlist').click(function(){
460		if (!$(this).hasClass('active'))
461		{
462			$(this).addClass('active');
463			$(this).parents('tr').addClass('active');
464			if ($('.list-wishlist tr.active .default-wishlist').is(":checked"))
465			{
466				$('.st-modal-wishlist .modal-title').html(wishlist_del_default_txt);
467				$('.st-modal-wishlist').removeClass('enable-action').modal('show');
468			}
469			else
470			{
471				$('.st-modal-wishlist .modal-title').html(wishlist_confirm_del_txt);
472				$('.st-modal-wishlist').addClass('enable-action').modal('show');
473			}
474		}
475		
476		return false;
477	});
478	
479	//DONGND:: confirm delete wishlist
480	$('.st-modal-wishlist-bt').click(function(){
481		if (!$(this).hasClass('active'))
482		{
483			// console.log('test');
484			$(this).addClass('active');
485			var object_e = $(this);
486			var id_wishlist = $('.delete-wishlist.active').data('id-wishlist');
487			$('.st-modal-wishlist-bt-text').hide();
488			$('.st-modal-wishlist-loading').css({'display':'block'});
489			
490			$.ajax({
491				type: 'POST',
492				headers: {"cache-control": "no-cache"},
493				url: wishlist_url,
494				async: true,
495				cache: false,
496				data: {
497					"ajax": 1,
498					"action": "delete-wishlist",
499					"id_wishlist": id_wishlist,					
500				},
501				success: function (result)
502				{
503					var object_result = $.parseJSON(result);
504					if (object_result.errors.length)
505					{
506						
507						$('.st-modal-wishlist .modal-title').html(object_result.errors);
508						$('.st-modal-wishlist').removeClass('enable-action').modal('show');
509					}
510					else
511					{				
512						var object_delete = $('.list-wishlist tr.active');
513						$('.st-modal-wishlist').modal('hide');
514						object_delete.fadeOut(function(){
515							if ($(this).hasClass('show'))
516							{
517								$('.st-wishlist-product').fadeOut().html('');
518							}
519							else
520							{
521								//DONGND:: reload list product if a wishlist current view
522								$('.list-wishlist tr.show .view-wishlist-product').trigger('click');
523							}
524							$(this).remove();
525						})
526						
527					}
528					$('.st-modal-wishlist-loading').hide();
529					$('.st-modal-wishlist-bt-text').show();
530					object_e.removeClass('active');
531								
532				},
533				error: function (XMLHttpRequest, textStatus, errorThrown) {
534					alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
535				}
536			});
537		}
538	})
539	
540	//DONGND:: change default wishlist
541	$('.default-wishlist').click(function(){
542		if ($(this).is(":checked"))
543		{
544			// console.log('test');
545			if (!$('.default-wishlist.active').length)
546			{
547				$(this).addClass('active');
548				var object_e = $(this);
549				var id_wishlist = $('.default-wishlist.active').data('id-wishlist');
550				$.ajax({
551					type: 'POST',
552					headers: {"cache-control": "no-cache"},
553					url: wishlist_url,
554					async: true,
555					cache: false,
556					data: {
557						"ajax": 1,
558						"action": "default-wishlist",
559						"id_wishlist": id_wishlist,					
560					},
561					success: function (result)
562					{
563						var object_result = $.parseJSON(result);
564						if (object_result.errors.length)
565						{
566							
567							$('.st-modal-wishlist .modal-title').html(object_result.errors);
568							$('.st-modal-wishlist').removeClass('enable-action').modal('show');
569						}
570						else
571						{				
572							$('.default-wishlist:checked').removeAttr('checked');
573							object_e.prop('checked', true);
574						}
575						
576						object_e.removeClass('active');
577									
578					},
579					error: function (XMLHttpRequest, textStatus, errorThrown) {
580						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
581					}
582				});
583			}
584		}
585		// else
586		// {
587			// console.log('test1');
588			
589		// }
590		return false;
591	})
592	
593	//DONGND:: show list product of wishlist
594	$('.view-wishlist-product').click(function(){
595		if (!$('.view-wishlist-product.active').length)
596		{
597			$(this).addClass('active');
598			$(this).next('.st-view-wishlist-product-loading').show();
599			$('.list-wishlist tr.show').removeClass('show');
600			$(this).parents('tr').addClass('show');
601			var object_e = $(this);
602			var id_wishlist = $(this).data('id-wishlist');
603			// $('.send-wishlist').fadeOut();
604			// $('.st-wishlist-product').fadeOut(function(){
605				//$('.st-wishlist-product').html('');			
606				$.ajax({
607					type: 'POST',
608					headers: {"cache-control": "no-cache"},
609					url: wishlist_url,
610					async: true,
611					cache: false,
612					data: {
613						"ajax": 1,
614						"action": "show-wishlist-product",
615						"id_wishlist": id_wishlist,					
616					},
617					success: function (result)
618					{
619						var object_result = $.parseJSON(result);
620						if (object_result.errors.length)
621						{
622							
623							$('.st-modal-wishlist .modal-title').html(object_result.errors);
624							$('.st-modal-wishlist').removeClass('enable-action').modal('show');
625						}
626						else
627						{				
628							$('.st-wishlist-product').hide();
629							$('.st-wishlist-product').html(object_result.result.html).fadeIn();
630							if (object_result.result.show_send_wishlist)
631							{
632								$('.send-wishlist').fadeIn();
633								// StWishlistButtonAction();						
634								if (!$('.leo-modal-send-wishlist').length)
635								{
636									createStSendWishlistModalPopup();					
637									StListWishlistProductModalAction();
638								}
639								else
640								{
641									$('.leo-modal-reset-send-wishlist-bt').trigger('click');
642								}
643								StListWishlistProductAction();
644								
645							}
646							else
647							{
648								$('.send-wishlist').hide();
649							}
650							refeshWishlist(id_wishlist);
651							
652						}
653						
654						object_e.removeClass('active');
655						object_e.next('.st-view-wishlist-product-loading').hide();
656									
657					},
658					error: function (XMLHttpRequest, textStatus, errorThrown) {
659						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
660					}
661				});
662			// })
663		}
664		return false;
665	})
666}
667function StListWishlistProductModalAction()
668{
669	//DONGND:: send wishlist
670	$('.st-send-wishlist-button').click(function(){
671		var name_wishlist = $('.list-wishlist tr.show .view-wishlist-product').data('name-wishlist');
672		$('.leo-modal-send-wishlist .modal-title').html(wishlist_send_wishlist_txt+' "'+name_wishlist+'"');
673		$('.leo-modal-send-wishlist').modal('show');
674		
675		return false;
676	})
677	
678	$('.leo-modal-send-wishlist').submit(function(){
679		// if ($(this).find('.form-group.leo-has-error').length)
680		if ($('.leo-fake-send-wishlist-button').hasClass('validate-ok'))
681		{
682			return false;
683		}
684	});
685	
686	//DONGND:: submit send wishlist
687	$('.leo-modal-send-wishlist-bt').click(function(){
688		if (!$(this).hasClass('active'))
689		{
690			var check_submit_wishlist = true;
691			var list_email = [];
692			$(this).addClass('active');
693			var object_e = $(this);
694			$('.leo-modal-reset-send-wishlist-bt').fadeOut();
695			
696			$('.wishlist_email').each(function(key, val){
697				if ($(this).val() !== '' && !$(this).parents('.form-group').hasClass('has-success') && !$(this).parents('.form-group').hasClass('has-warning'))
698				{
699					if (!validateEmail($(this).val()))
700					{
701						$(this).parents('.form-group').addClass('leo-has-error');
702						check_submit_wishlist = false;
703					}
704					else
705					{
706						$(this).parents('.form-group').removeClass('leo-has-error');
707						list_email.push(key);
708					}
709				}
710				
711			})
712			// console.log(check_submit_wishlist);
713			if (check_submit_wishlist)
714			{
715				// if (list_email.length == 0)
716				// console.log(list_email.length);
717				// console.log(list_email);
718				if (list_email.length == 0)
719				{
720					$('.wishlist_email').each(function(key, val){
721						if ($(this).val() == '')
722						{
723							$(this).parents('.form-group').addClass('leo-has-error');
724							$(this).attr("required", "");
725							return false;
726						}
727					})
728					object_e.removeClass('active');
729					$('.leo-modal-reset-send-wishlist-bt').fadeIn();
730				}
731				else
732				{
733					$('.leo-fake-send-wishlist-button').addClass('validate-ok');
734					var id_wishlist = $('.list-wishlist tr.show .view-wishlist-product').data('id-wishlist');
735					// console.log(list_email);
736				
737					$('.leo-modal-send-wishlist-bt-text').hide();
738					$('.leo-modal-send-wishlist-loading').css({'display':'block'});
739					
740					$.each(list_email,function(key, val){
741						var index_wishlist_email = val + 1;
742						var email = $('#wishlist_email_'+index_wishlist_email).val();
743						var object_parent_e = $('#wishlist_email_'+index_wishlist_email).parents('.form-group');
744						object_parent_e.find('.wishlist_email_status_loading').show();
745						
746						$.ajax({
747							type: 'POST',
748							headers: {"cache-control": "no-cache"},
749							url: wishlist_url,
750							async: true,
751							cache: false,
752							data: {
753								"ajax": 1,
754								"action": "send-wishlist",
755								"id_wishlist": id_wishlist,
756								"email": email
757							},
758							success: function (result)
759							{
760								object_parent_e.find('.wishlist_email_status_loading').hide();
761								var object_result = $.parseJSON(result);
762								if (object_result.errors.length)
763								{
764									object_parent_e.addClass('has-warning').find('.send_wishlist_error').fadeIn();
765								}
766								else
767								{				
768									object_parent_e.addClass('has-success').find('.send_wishlist_success').fadeIn();
769								}
770																								
771							},
772							error: function (XMLHttpRequest, textStatus, errorThrown) {
773								alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
774							}
775						});
776						
777					});
778					$(document).ajaxStop(function() {
779						// console.log('test');
780						$('.leo-modal-send-wishlist-loading').hide();
781						$('.leo-modal-send-wishlist-bt-text').show();
782						$('.leo-fake-send-wishlist-button').removeClass('validate-ok');
783						object_e.removeClass('active');
784						$('.leo-modal-reset-send-wishlist-bt').fadeIn();
785					});				
786					
787				}
788				if ($('.form-send-wishlist .form-group.leo-has-error').length)
789				{
790					$('.leo-fake-send-wishlist-button').trigger('click');
791				}
792			}
793			else
794			{
795				object_e.removeClass('active');
796				$('.leo-modal-reset-send-wishlist-bt').fadeIn();
797					$('.leo-fake-send-wishlist-button').trigger('click');
798			}
799			
800		}
801	})
802	
803	//DONGND:: reset from send wishlist
804	$('.leo-modal-reset-send-wishlist-bt').click(function(){
805		$('.wishlist_email').val('').removeAttr('required');
806		$('.send_wishlist_form_content .form-group').removeClass('leo-has-error has-success has-warning');
807		$('.wishlist_email_status_loading').fadeOut();
808		$('.send_wishlist_msg').fadeOut();
809	})
810}
811
812function StListWishlistProductAction()
813{
814	//DONGND:: delete product of wishlist
815	$('.st-wishlist-button-delete').click(function(){
816		if (!$(this).hasClass('active'))
817		{
818			$(this).addClass('active');
819			var object_e = $(this);
820			var object_parent_e = object_e.parents('.st-wishlist-product');
821			var id_wishlist_product = $(this).data('id-wishlist-product');
822			var id_wishlist = $(this).data('id-wishlist');
823			$.ajax({
824				type: 'POST',
825				headers: {"cache-control": "no-cache"},
826				url: wishlist_url,
827				async: true,
828				cache: false,
829				data: {
830					"ajax": 1,
831					"action": "delete-wishlist-product",
832					"id_wishlist": id_wishlist,	
833					"id_wishlist_product": id_wishlist_product,				
834				},
835				success: function (result)
836				{
837					var object_result = $.parseJSON(result);
838					if (object_result.errors.length)
839					{
840						
841						$('.st-modal-wishlist .modal-title').html(object_result.errors);
842						$('.st-modal-wishlist').removeClass('enable-action').modal('show');
843					}
844					else
845					{				
846						object_e.parents('.st-wishlistproduct-item').fadeOut(function(){
847							$(this).remove();
848							// console.log(object_parent_e);
849							// console.log(object_parent_e.find('.st-wishlistproduct-item'));
850							// console.log(object_parent_e.find('.st-wishlistproduct-item').length);
851							if (!object_parent_e.find('.st-wishlistproduct-item').length)
852							{							
853								$('.send-wishlist').hide();
854								$('.list-wishlist tr.show .view-wishlist-product').trigger('click');
855							}
856						});
857						//Sttheme add: update number product on icon wishlist after remove from wishlist								
858						if ($('.ap-btn-wishlist .ap-total-wishlist').length)
859						{								
860							var old_num_wishlist = parseInt($('.ap-btn-wishlist .ap-total-wishlist').text());
861							var new_num_wishlist = old_num_wishlist-1;
862							$('.ap-btn-wishlist .ap-total-wishlist').text(new_num_wishlist);
863						}
864						refeshWishlist(id_wishlist);
865					}
866					
867					object_e.removeClass('active');
868					
869				},
870				error: function (XMLHttpRequest, textStatus, errorThrown) {
871					alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
872				}
873			});
874		}
875		return false;
876	})
877	
878	//DONGND::
879	$('.st-wishlist-product-save-button').click(function(){
880		if (!$(this).hasClass('active'))
881		{
882			$(this).addClass('active');
883			var object_e = $(this);
884			var id_wishlist_product = $(this).data('id-wishlist-product');
885			var id_wishlist = $(this).data('id-wishlist');
886			// $('.st-wishlistproduct-item-'+id_wishlist_product).addClass('update');
887			var quantity = $('.wishlist-product-quantity-'+id_wishlist_product).val();		
888			var priority = $('.wishlist-product-priority-'+id_wishlist_product).val();		
889			
890			if(Math.floor(quantity) == quantity && $.isNumeric(quantity) && quantity > 0)
891			{
892				$('.wishlist-product-quantity-'+id_wishlist_product).parents('.form-group').removeClass('has-error');
893				$.ajax({
894					type: 'POST',
895					headers: {"cache-control": "no-cache"},
896					url: wishlist_url,
897					async: true,
898					cache: false,
899					data: {
900						"ajax": 1,
901						"action": "update-wishlist-product",
902						"id_wishlist": id_wishlist,	
903						"id_wishlist_product": id_wishlist_product,
904						"quantity": quantity,	
905						"priority": priority,		
906					},
907					success: function (result)
908					{
909						var object_result = $.parseJSON(result);
910						if (object_result.errors.length)
911						{
912							
913							$('.st-modal-wishlist .modal-title').html(object_result.errors);
914							$('.st-modal-wishlist').removeClass('enable-action').modal('show');
915						}
916						else
917						{
918							$('.st-wishlistproduct-item-'+id_wishlist_product).hide();
919							$('.st-wishlistproduct-item-'+id_wishlist_product).fadeIn();
920							refeshWishlist(id_wishlist);
921						}
922						
923						object_e.removeClass('active');
924						
925					},
926					error: function (XMLHttpRequest, textStatus, errorThrown) {
927						alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
928					}
929				});
930			}
931			else
932			{
933				$('.wishlist-product-quantity-'+id_wishlist_product).parents('.form-group').addClass('has-error');			
934				$('.st-modal-wishlist .modal-title').html(wishlist_quantity_required);
935				$('.st-modal-wishlist').removeClass('enable-action').modal('show');
936				object_e.removeClass('active');
937			}
938		}
939		return false;
940	})
941	
942	$('.move-wishlist-item').click(function(){
943		if (!$(this).hasClass('active'))
944		{
945			$(this).addClass('active');
946			var object_e = $(this);
947			var object_parent_e = object_e.parents('.st-wishlist-product');
948			var id_wishlist_product = $(this).data('id-wishlist-product');
949			var id_product = $(this).data('id-product');
950			var id_product_attribute = $(this).data('id-product-attribute');
951			var id_old_wishlist = $('.list-wishlist tr.show .view-wishlist-product').data('id-wishlist');
952			var id_new_wishlist = $(this).data('id-wishlist');
953			var priority = $('.wishlist-product-priority-'+id_wishlist_product).val();
954			var quantity = $('.wishlist-product-quantity-'+id_wishlist_product).val();
955			$.ajax({
956				type: 'POST',
957				headers: {"cache-control": "no-cache"},
958				url: wishlist_url,
959				async: true,
960				cache: false,
961				data: {
962					"ajax": 1,
963					"action": "move-wishlist-product",
964					"id_new_wishlist": id_new_wishlist,	
965					"id_wishlist_product": id_wishlist_product,
966					"id_old_wishlist": id_old_wishlist,	
967					"id_product" : id_product,
968					"id_product_attribute": id_product_attribute,
969					"quantity": quantity,
970					"priority": priority,
971				},
972				success: function (result)
973				{
974					var object_result = $.parseJSON(result);
975					if (object_result.errors.length)
976					{
977						
978						$('.st-modal-wishlist .modal-title').html(object_result.errors);
979						$('.st-modal-wishlist').removeClass('enable-action').modal('show');
980					}
981					else
982					{
983						object_e.parents('.st-wishlistproduct-item').fadeOut(function(){
984							$(this).remove();
985							if (!object_parent_e.find('.st-wishlistproduct-item').length)
986							{							
987								$('.send-wishlist').hide();
988								$('.list-wishlist tr.show .view-wishlist-product').trigger('click');
989							}
990						});
991						refeshWishlist(id_new_wishlist);
992						refeshWishlist(id_old_wishlist);
993					}
994					
995					object_e.removeClass('active');
996					
997				},
998				error: function (XMLHttpRequest, textStatus, errorThrown) {
999					alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
1000				}
1001			});		
1002		}
1003		return false;
1004	})
1005}
1006
1007function activeEventModalWishlist()
1008{
1009	$('.st-modal-wishlist').on('hide.bs.modal', function (e) {
1010		// console.log($('.leo-modal-review-bt').length);
1011		if ($('.st-wishlist-button.active').length)
1012		{
1013			// console.log('aaa');
1014			$('.st-wishlist-button.active').removeClass('active');
1015		}
1016		
1017		if ($('.wishlist-item.active-add').length)
1018		{
1019			// console.log('aaa');
1020			$('.wishlist-item.active-add').removeClass('active-add');
1021		}
1022		// $('.leo-list-wishlist').fadeOut();
1023		$('.default-wishlist.active').removeClass('active');
1024		$('.delete-wishlist.active').removeClass('active');
1025		
1026		$('.list-wishlist tr.active').removeClass('active');
1027		
1028		// $('.st-modal-wishlist').removeClass('enable-action');
1029	})
1030	
1031	$('.st-modal-wishlist').on('hidden.bs.modal', function (e) {
1032		$('body').css('padding-right', '');
1033	})
1034	$('.st-modal-wishlist').on('show.bs.modal', function (e) {
1035		if ($('.quickview.modal').length)
1036		{			
1037			$('.quickview.modal').modal('hide');		
1038		}
1039		
1040	});
1041}
1042
1043function createStSendWishlistModalPopup()
1044{
1045	var leoSendWishlistModalPopup = '';
1046	leoSendWishlistModalPopup += '<div class="modal leo-modal leo-modal-send-wishlist fade" tabindex="-1" role="dialog" aria-hidden="true">';
1047		leoSendWishlistModalPopup += '<div class="modal-dialog" role="document">';
1048			leoSendWishlistModalPopup += '<div class="modal-content">';
1049				leoSendWishlistModalPopup += '<div class="modal-header">';
1050					leoSendWishlistModalPopup += '<button type="button" class="close" data-dismiss="modal" aria-label="Close">';
1051						leoSendWishlistModalPopup += '<span aria-hidden="true">&times;</span>';
1052					leoSendWishlistModalPopup += '</button>';
1053					leoSendWishlistModalPopup += '<h5 class="modal-title text-xs-center">';
1054					leoSendWishlistModalPopup += '</h5>';
1055				leoSendWishlistModalPopup += '</div>';
1056				leoSendWishlistModalPopup += '<div class="modal-body">';
1057					leoSendWishlistModalPopup += '<div class="send_wishlist_form_content">';
1058						leoSendWishlistModalPopup += '<form class="form-send-wishlist" action="#" method="post">'
1059							for (var $i=1; $i<= 10; $i++)
1060							{								
1061								leoSendWishlistModalPopup += '<div class="form-group row">';
1062								  leoSendWishlistModalPopup += '<label class="col-form-label col-sm-2 text-sm-left" for="wishlist_email_'+$i+'">'+wishlist_email_txt+' '+$i+'</label>';
1063									leoSendWishlistModalPopup += '<div class="wishlist_email_status col-sm-1">';
1064										leoSendWishlistModalPopup += '<div class="wishlist_email_status_loading cssload-speeding-wheel">';
1065										leoSendWishlistModalPopup += '</div>';
1066										leoSendWishlistModalPopup += '<i class="send_wishlist_msg send_wishlist_success material-icons">&#xE876;</i>';
1067										leoSendWishlistModalPopup += '<i class="send_wishlist_msg send_wishlist_error material-icons">&#xE033;</i>';									
1068									leoSendWishlistModalPopup += '</div>';
1069									leoSendWishlistModalPopup += '<div class="col-sm-9">';		
1070								  leoSendWishlistModalPopup += '<input class="form-control wishlist_email" id="wishlist_email_'+$i+'" name="wishlist_email_'+$i+'" type="email">';
1071									leoSendWishlistModalPopup += '</div>';
1072								leoSendWishlistModalPopup += '</div>';
1073							}
1074							leoSendWishlistModalPopup += '<button class="btn btn-primary form-control-submit leo-fake-send-wishlist-button pull-xs-right" type="submit"></button>';					  				
1075						leoSendWishlistModalPopup += '</form>';
1076					leoSendWishlistModalPopup += '</div>';
1077				leoSendWishlistModalPopup += '</div>';
1078				leoSendWishlistModalPopup += '<div class="modal-footer">';	
1079					leoSendWishlistModalPopup += '<button type="button" class="btn btn-primary leo-modal-reset-send-wishlist-bt">'+wishlist_reset_txt+'</button>';	
1080					leoSendWishlistModalPopup += '<button type="button" class="btn btn-secondary" data-dismiss="modal">'+wishlist_cancel_txt+'</button>';
1081					leoSendWishlistModalPopup += '<button type="button" class="leo-modal-send-wishlist-bt btn btn-primary">';						
1082						leoSendWishlistModalPopup += '<span class="leo-modal-send-wishlist-loading cssload-speeding-wheel"></span>';
1083						leoSendWishlistModalPopup += '<span class="leo-modal-send-wishlist-bt-text">';
1084							leoSendWishlistModalPopup += wishlist_send_txt;
1085						leoSendWishlistModalPopup += '</span>';
1086					leoSendWishlistModalPopup += '</button>';				
1087				leoSendWishlistModalPopup += '</div>';
1088			leoSendWishlistModalPopup += '</div>';
1089		leoSendWishlistModalPopup += '</div>';
1090	leoSendWishlistModalPopup += '</div>';
1091	$('body').append(leoSendWishlistModalPopup);
1092}
1093
1094function validateEmail(email) {
1095  // var regex = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
1096  // return regex.test(email);
1097	var reg = /^[a-z\p{L}0-9!#$%&'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/i;
1098	return reg.test(email);
1099}
1100
1101//DONGND:: update quantity of wishlist
1102function refeshWishlist(id_wishlist)
1103{
1104	$('.st-view-wishlist-product-loading-'+id_wishlist).show();
1105	$.ajax({
1106		type: 'POST',
1107		headers: {"cache-control": "no-cache"},
1108		url: wishlist_url,
1109		async: true,
1110		cache: false,
1111		data: {
1112			"ajax": 1,
1113			"action": "get-wishlist-info",
1114			"id_wishlist": id_wishlist,					
1115		},
1116		success: function (result)
1117		{
1118			var object_result = $.parseJSON(result);
1119			if (object_result.errors.length)
1120			{
1121				
1122				$('.st-modal-wishlist .modal-title').html(object_result.errors);
1123				$('.st-modal-wishlist').removeClass('enable-action').modal('show');
1124			}
1125			else
1126			{				
1127				$('.wishlist-numberproduct-'+id_wishlist).html(object_result.result.number_product);
1128			}
1129			$('.st-view-wishlist-product-loading-'+id_wishlist).hide();
1130		},
1131		error: function (XMLHttpRequest, textStatus, errorThrown) {
1132			alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
1133		}
1134	});
1135}

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.