PageSourceSearch

https://maskirovka.club/t/v2981/images/site.addons2.js

js maskirovka.club collected 2026-09-28 18:54:33 UTC 6,928 bytes, 172 lines download raw bytes

1shop2.queue.favorite = function(){
2
3	function popupDeleteFavorite($kind_id){
4		var popupWr = '<div class="shop2-popup_favorite"><div class="popup_inner"><div class="text">Удалить товар из избранного?</div><div class="btns"><div class="shop2-btn delete_fovorite" data-kind_id="' + $kind_id + '">Удалить</div><div class="shop2-btn-close close_favorite">Закрыть</div></div></div></div>';
5		
6		$(popupWr).appendTo('body');
7	}
8	
9	function popupClearFavorite(){
10		var popupWr = '<div class="shop2-popup_favorite"><div class="popup_inner"><div class="text">Удалить все товары из избранного?</div><div class="btns"><div class="shop2-btn clear_fovorite">Удалить</div><div class="shop2-btn-close close_favorite">Закрыть</div></div></div></div>';
11		
12		$(popupWr).appendTo('body');
13	}
14	
15	$(document).on('click', '.favorite_btn:not(.active)', function(){
16		let $this   = $(this),
17			kind_id = $this.parents('form').find('input[name="kind_id"]').val();
18		
19		
20			
21		if($.cookie('set_user_new_token') !='is_set' && is_user){
22			$.cookie('s3_user_token','',{path:"/"});
23			$.cookie('set_user_new_token','is_set');
24		} 
25
26		shop2.trigger('beforeFavoriteAddItem');
27		
28		$.ajax({
29            url: '/-/x-api/v1/public/?method=shop2/addFavoriteProduct&param[kind_id]=' + kind_id,
30            type: 'post',
31            dataType: 'json',
32            data: kind_id,
33            
34            success: function(data) {
35            	console.log(data)
36            	if (data.error){
37            		alert(data.error.message)
38            		return
39            	}
40            	let res   = data.result.count;
41            	let $text = /*window._s3Lang.JS_ADD_FOVARITE;*/"Добавлено в <a href='%s'>избранное</a>";
42            	
43            	let template_html = `<a href="${shop2.uri + '/favorites'}">${window._s3Lang.FORUM_FAVORITES}(<span>${res}</span>)</a>`;
44            	
45                $('.favorite_btn.active a > span').text(res);
46                $('.shop2_favorite_cart_link span').text(res);
47                $('.favorite_panel').removeClass('not-null');
48                
49	            //shop2.msg($text.replace('%s', shop2.uri + '/favorites'), $this);
50	            $(document).find('#shop2-msg').addClass('msg-favorite');
51	            $this.addClass('active').find('.text-favorite').replaceWith(template_html);
52				shop2.trigger('afterFavoriteAddItem', data);
53            }
54        });
55        
56        
57	});
58	
59	$(document).on('click', '.favorite_btn.active .icon', function(){
60		let kind_id = $(this).parents('form').find('input[name="kind_id"]').val();
61			//popupDeleteFavorite(kind_id); // Всплывающее окно удаления из избранного. 
62		
63		// Удаление без всплывающего окна
64		var product  = $('body').find('form input[value="' + kind_id + '"]').closest('form'),
65			button = product.find('.favorite_btn');
66		
67		// Для поправки если авторизованный пользоваль так же добавлял избранное как не аквторизованный	
68		if($.cookie('set_user_new_token') !='is_set' && is_user){
69			$.cookie('s3_user_token','',{path:"/"});
70			$.cookie('set_user_new_token','is_set');
71		} 
72		shop2.trigger('beforeFavoriteRemoveItem');
73		
74		$.ajax({
75            url: '/-/x-api/v1/public/?method=shop2/removeFavoriteProduct&param[kind_id]=' + kind_id,
76            type: 'post',
77            dataType: 'json',
78            data: kind_id,
79            success: function(data) {
80            	let res = data.result.count;
81            	let temlate = `<span class="text-favorite">${window._s3Lang.ADD_TO_FAVORITE}</span>`;
82                $('.favorite_btn.active a > span').text(res);
83                $('.shop2_favorite_cart_link span').text(res);
84                if (res == 0){
85                	$('.favorite_panel').addClass('not-null');
86                }
87                button.removeClass('active');
88                button.find('a').replaceWith(temlate);
89
90				shop2.trigger('afterFavoriteRemoveItem', data);
91            }
92        });
93		// Удаление без всплывающего окна
94	});
95	
96	$(document).on('click', '.delete_fovorite', function(){
97		var kind_id  = $(this).data('kind_id'),
98			product  = $('body').find('form input[value="' + kind_id + '"]').closest('form'),
99			button = product.find('.favorite_btn');
100		
101		// Для поправки если авторизованный пользоваль так же добавлял избранное как не аквторизованный	
102		if($.cookie('set_user_new_token') !='is_set' && is_user){
103			$.cookie('s3_user_token','',{path:"/"});
104			$.cookie('set_user_new_token','is_set');
105		} 
106		
107		
108		shop2.trigger('beforeFavoriteRemoveItem');
109		
110		$.ajax({
111            url: '/-/x-api/v1/public/?method=shop2/removeFavoriteProduct&param[kind_id]=' + kind_id,
112            type: 'post',
113            dataType: 'json',
114            data: kind_id,
115            success: function(data) {
116            	let res = data.result.count;
117            	let temlate = `<span class="text-favorite">${window._s3Lang.ADD_TO_FAVORITE}</span>`;
118                $('.favorite_btn.active a > span').text(res);
119                $('.shop2_favorite_cart_link span').text(res);
120                if (res == 0){
121                	$('.favorite_panel').addClass('not-null');
122                }
123                button.removeClass('active');
124                button.find('a').replaceWith(temlate);
125
126				shop2.trigger('afterFavoriteRemoveItem', data);
127            }
128        });
129        
130        
131		$('.shop2-popup_favorite').remove();
132	});
133	
134	$(document).on('click', '.close_favorite', function(){
135		$('.shop2-popup_favorite').remove();
136	});
137	
138	$(document).on('click', '.shop2-btn_popup_favorite', function(e){
139		popupClearFavorite();
140		e.preventDefault();
141	});
142	
143	$(document).on('click', '.clear_fovorite', function(e){
144		if($.cookie('set_user_new_token') !='is_set' && is_user){
145			$.cookie('s3_user_token','',{path:"/"});
146			$.cookie('set_user_new_token','is_set');
147		} 
148		$.ajax({
149            url: '/-/x-api/v1/public/?method=shop2/clearFavoriteProducts',
150            type: 'post',
151            dataType: 'json',
152            success: function(data) {
153            
154            }
155        });
156        location.reload()
157	});
158};
159
160shop2.on('afterFavoriteAddItem', function(d){
161	$(document).find('.favorite_top .favorite_link span').text(d.result.count)
162	if (d.result.count>0){
163		$(document).find('.favorite_top').removeClass('is-null');
164	}
165});
166
167shop2.on('afterFavoriteRemoveItem', function(d){
168	$(document).find('.favorite_top .favorite_link span').text(d.result.count)
169	if (d.result.count==0){
170		$(document).find('.favorite_top').addClass('is-null');
171	}
172});

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.