PageSourceSearch

https://truegrace.gr/wp-content/themes/moderno/assets/js/wishlist.js?ver=1.44

js truegrace.gr collected 2026-10-07 22:24:32 UTC 4,121 bytes, 165 lines download raw bytes

1(function ($) {
2	
3	'use strict';
4	
5	window.IP_Wishlist = {
6		
7		init_product_button: function () {
8			if ($.fn.cookie || typeof (Cookies) !== 'undefined') {
9				
10				var wishlistCookie = $.fn.cookie ? $.cookie(ideapark_wp_vars.wishlistCookieName) : Cookies.get(ideapark_wp_vars.wishlistCookieName);
11				if (wishlistCookie) {
12					wishlistCookie = JSON.parse(wishlistCookie);
13					
14					for (var id in wishlistCookie) {
15						if (wishlistCookie.hasOwnProperty(id)) {
16							$('.c-wishlist__item-' + wishlistCookie[id] + '-btn').addClass('c-wishlist__btn--added');
17						}
18					}
19				}
20			}
21		},
22		
23		init: function () {
24			var wishlistAjax = false;
25			
26			this.init_product_button();
27			
28			$(document).on('click', '.js-wishlist-btn', function (e) {
29				e.preventDefault();
30				
31				if (wishlistAjax) {
32					return;
33				}
34				
35				var $button = $(this),
36					productId = $(this).data('product-id'),
37					$buttons = $('.c-wishlist__item-' + productId + '-btn');
38				
39				$buttons.removeClass('c-wishlist__btn--added');
40				
41				var size = $button.data('size');
42				if (size) {
43					size = parseInt(size);
44				} else {
45					size = '';
46				}
47				$button.ideapark_button('loading', size, true);
48				
49				wishlistAjax = $.ajax({
50					type    : 'POST',
51					url     : ideapark_wp_vars.ajaxUrl,
52					data    : {
53						action    : 'ideapark_wishlist_toggle',
54						product_id: productId
55					},
56					dataType: 'json',
57					cache   : false,
58					headers : {'cache-control': 'no-cache'},
59					complete: function () {
60						wishlistAjax = false;
61					},
62					success : function (json) {
63						$(document.body).trigger('wc_fragment_refresh');
64						
65						$button.ideapark_button('reset');
66						
67						if (json.status === '1') {
68							$('body').trigger('wishlist_added_item');
69							$buttons.attr('title', ideapark_wp_vars.wishlistTitleRemove);
70							$buttons.addClass('c-wishlist__btn--added');
71						} else {
72							$('body').trigger('wishlist_removed_item');
73							$buttons.attr('title', ideapark_wp_vars.wishlistTitleAdd);
74						}
75					}
76				});
77			});
78			
79			
80			var $wishlistTable = $('.js-wishlist-table');
81			
82			
83			if ($wishlistTable.length) {
84				
85				var _wishlistRemoveItem = function ($this) {
86					var $thisTr = $this.closest('tr'),
87						productId = $thisTr.data('product-id');
88					
89					$thisTr.addClass('loading');
90					
91					$.ajax({
92						type    : 'POST',
93						url     : ideapark_wp_vars.ajaxUrl,
94						data    : {
95							action    : 'ideapark_wishlist_toggle',
96							product_id: productId
97						},
98						dataType: 'json',
99						cache   : false,
100						headers : {'cache-control': 'no-cache'},
101						success : function (json) {
102							$(document.body).trigger('wc_fragment_refresh');
103							
104							var $share_link = $('#ip-wishlist-share-link');
105							$('body').trigger('wishlist_removed_item');
106							if ($share_link.length === 1 && typeof json.share_link !== 'undefined') {
107								$share_link.val(json.share_link);
108							}
109							if (json.count > 0) {
110							} else {
111								$('.js-wishlist').css('display', 'none');
112								$('.js-wishlist-empty').removeClass('h-hidden');
113							}
114							$thisTr.fadeOut(150, function () {
115								$(this).remove();
116							});
117						}
118						
119					}).fail(function () {
120						$thisTr.removeClass('loading');
121					});
122					
123				};
124				
125				
126				$wishlistTable.on('click', '.js-wishlist-remove', function (e) {
127					e.preventDefault();
128					
129					var $this = $(this);
130					
131					if ($this.hasClass('clicked')) {
132						return;
133					}
134					
135					$this.addClass('clicked');
136					
137					_wishlistRemoveItem($this);
138				});
139			}
140			
141			$('.js-wishlist-fix').each(function (){
142				var productId = $(this).val();
143				$.ajax({
144					type    : 'POST',
145					url     : ideapark_wp_vars.ajaxUrl,
146					data    : {
147						action    : 'ideapark_wishlist_toggle',
148						product_id: productId
149					},
150					dataType: 'json',
151					cache   : false,
152					headers : {'cache-control': 'no-cache'},
153					success : function (json) {
154						$(document.body).trigger('wc_fragment_refresh');
155					}
156				});
157			});
158		}
159	};
160	
161	$(document).ready(function () {
162		IP_Wishlist.init();
163	});
164	
165})(jQuery);

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.