PageSourceSearch

https://priborelektro.ru/js/addons/ab__stickers/func.js?ver=1790257262

js priborelektro.ru collected 2026-09-25 05:05:32 UTC 8,308 bytes, 220 lines download raw bytes

1/*******************************************************************************************
2*   ___  _          ______                     _ _                _                        *
3*  / _ \| |         | ___ \                   | (_)              | |              © 2021   *
4* / /_\ | | _____  _| |_/ /_ __ __ _ _ __   __| |_ _ __   __ _   | |_ ___  __ _ _ __ ___   *
5* |  _  | |/ _ \ \/ / ___ \ '__/ _` | '_ \ / _` | | '_ \ / _` |  | __/ _ \/ _` | '_ ` _ \  *
6* | | | | |  __/>  <| |_/ / | | (_| | | | | (_| | | | | | (_| |  | ||  __/ (_| | | | | | | *
7* \_| |_/_|\___/_/\_\____/|_|  \__,_|_| |_|\__,_|_|_| |_|\__, |  \___\___|\__,_|_| |_| |_| *
8*                                                         __/ |                            *
9*                                                        |___/                             *
10* ---------------------------------------------------------------------------------------- *
11* This is commercial software, only users who have purchased a valid license and accept    *
12* to the terms of the License Agreement can install and use this program.                  *
13* ---------------------------------------------------------------------------------------- *
14* website: https://cs-cart.alexbranding.com                                                *
15*   email: [email protected]                                                           *
16*******************************************************************************************/
17(function (_, $) {
18	var user_agent = navigator.userAgent || '';
19	var is_bot = /Googlebot|GoogleOther|bingbot|YandexBot|Baiduspider|Bytespider|PetalBot|GPTBot|ClaudeBot|Amazonbot/i.test(user_agent);
20	if (is_bot) {
21		return;
22	}
23	$.ceEvent('on', 'ce.commoninit', function(context) {
24		var cache_key = _.ab__stickers.runtime.cache_key;
25		var items = context.find('[data-ab-sticker-id]');
26		for (var timeout in _.ab__stickers.timeouts) {
27			clearTimeout(_.ab__stickers.timeouts[timeout]);
28		}
29		if (items.length) {
30			var sticker_ids = [];
31			var stickers_storage = JSON.parse(localStorage.getItem(cache_key));
32			var ids_to_remove = [];
33			items.each(function () {
34				var item = $(this);
35				var item_sticker = item.attr('data-ab-sticker-id');
36				if (stickers_storage !== null) {
37					if (stickers_storage.html[item_sticker] != void (0)) {
38						create_sticker(item, stickers_storage.html[item_sticker]);
39						ids_to_remove.push(item_sticker);
40					}
41				}
42				sticker_ids.push(item_sticker);
43			});
44			sticker_ids = sticker_ids.filter(function (value, index, self) {
45				return self.indexOf(value) === index && !(~ids_to_remove.indexOf(value));
46			});
47			if (sticker_ids.length) {
48				var sticker_placeholders = [];
49				sticker_ids.forEach(function(id) {
50					sticker_placeholders.push({placeholders: $('[data-ab-sticker-id="' + id + '"]').data('placeholders'), id: id});
51				});
52				$.ceAjax('request', fn_url('ab__stickers.get_stickers?sl=' + _.cart_language), {
53					method: 'post',
54					hidden: true,
55					data: {
56						sticker_ids: sticker_ids,
57						sticker_placeholders: sticker_placeholders,
58						controller_mode: _.ab__stickers.runtime.controller_mode,
59					},
60					callback: function (data, params) {
61						if (!is_object_empty(data.stickers_html)) {
62							var html = data.stickers_html;
63							var local_storage_assign = {
64								html: {},
65							};
66							items.each(function () {
67								var item = $(this);
68								var item_sticker = item.attr('data-ab-sticker-id');
69								local_storage_assign.html[item_sticker] = html[item_sticker];
70								create_sticker(item, html[item_sticker]);
71							});
72							if (_.ab__stickers.runtime.caching === true) {
73								if (stickers_storage !== null) {
74									local_storage_assign.html = Object.assign(local_storage_assign.html, stickers_storage.html);
75								}
76								try {
77									localStorage.setItem(cache_key, JSON.stringify(local_storage_assign));
78								} catch (e) {
79									localStorage.clear();
80									localStorage.setItem(cache_key, JSON.stringify(local_storage_assign));
81								}
82							}
83						}
84					}
85				});
86			}
87			_.ab__stickers.close_tooltip = function(btn){
88				btn = $(btn);
89				var tooltip = btn.parent();
90				var id = tooltip.data('data-sticker-id');
91				clearTimeout(_.ab__stickers.timeouts[id]);
92				tooltip.css({
93					'display': 'none',
94					'top': '-1000px',
95				});
96				setTimeout(function(){
97					tooltip.css('display', '');
98				}, 50);
99			}
100		}
101		var wrapper = context.find('.ab-stickers-wrapper');
102		if (wrapper.length) {
103			var prev_w_size = 0;
104			var resize = function () {
105				if (prev_w_size !== window.innerWidth) {
106					prev_w_size = window.innerWidth;
107					var add_h = function () {
108						var image = context.find('.ty-product-img a.cm-image-previewer img').first();
109						if (image.length && image[0].complete && image[0].naturalHeight > 0) {
110							wrapper.css('max-height', 'none');
111						} else {
112							setTimeout(function () {
113								add_h();
114							}, 100);
115						}
116					};
117					add_h();
118				}
119			};
120			$(window).on('resize', resize);
121			resize();
122		}
123	});
124
125	$.ceEvent('on', 'ab__vg.on_state_change', (info, state) => {
126		if (_.ab__video_gallery.settings.on_thumbnail_click === 'image_replace') {
127			var stickers = $('#' + info.iframe_id).parents('.ab_vg-images-wrapper').find('.ab-stickers-wrapper');
128			if (stickers.length) {
129				if (info.video_type === 'Y') {
130					if (state.data === 1) {
131						stickers.css('display', 'none');
132					} else if (state.data === 2) {
133						stickers.css('display', '');
134					}
135				} else if (info.video_type === 'V') {
136					if (info.event === 'play') {
137						stickers.css('display', 'none');
138					} else if (info.event === 'pause') {
139						stickers.css('display', '');
140					}
141				}
142			}
143		}
144	});
145
146	function create_sticker(item, sticker_html) {
147		item.html(sticker_html);
148		var sticker = item.find('[data-id]');
149		if (sticker.length) {
150			var id = sticker.data('id');
151			var tooltip = $("[data-sticker-id='" + id + "']").first();
152			sticker.on('touchstart mouseenter', function () {
153				var tooltip_pointer = tooltip.next();
154				if (!tooltip.hasClass('moved')) {
155					$("[data-sticker-id='" + id + "']:not(:first)").remove();
156					$("[data-sticker-p-id='" + id + "']:not(:first)").remove();
157					tooltip.appendTo('#' + _.container).addClass('moved');
158					tooltip_pointer.appendTo('#' + _.container);
159				}
160				clearTimeout(_.ab__stickers.timeouts[id]);
161				var s_height = sticker.outerHeight(true);
162				var s_width = sticker.outerWidth(true);
163				var s_pos = sticker.offset();
164				var tooltip_w = tooltip.outerWidth();
165				var tooltip_pos_y = (s_pos.top + s_height + 10);
166				var tooltip_pos_x = (s_pos.left + s_width / 2) - tooltip_w / 2;
167				var rectangle = {
168					top: tooltip_pos_y,
169					left: tooltip_pos_x,
170					right: tooltip_pos_x + tooltip_w,
171				};
172				if (rectangle.right > window.innerWidth) {
173					rectangle.left -= rectangle.right - window.innerWidth + 25;
174				} else if (rectangle.left < 0) {
175					rectangle.left = 25;
176				}
177				tooltip_pointer.css({
178					top: rectangle.top + 'px',
179					left: sticker.offset().left + sticker.outerWidth() / 2,
180				}).hover(function () {
181					clearTimeout(_.ab__stickers.timeouts[id]);
182					tooltip.addClass('hovered');
183				}, function () {
184					clearTimeout(_.ab__stickers.timeouts[id]);
185					_.ab__stickers.timeouts[id] = setTimeout(function () {
186						tooltip.removeClass('hovered');
187					}, 50);
188				});
189				tooltip.css({
190					top: rectangle.top + 'px',
191					left: rectangle.left + 'px',
192				}).addClass('hovered');
193			});
194			var hide_sticker = function () {
195				clearTimeout(_.ab__stickers.timeouts[id]);
196				_.ab__stickers.timeouts[id] = setTimeout(function () {
197					tooltip.removeClass('hovered');
198				}, 50);
199			};
200			sticker.on('mouseleave', hide_sticker);
201		}
202	}
203	var hide_active_sticker = function() {
204		$(".ab-sticker__tooltip.hovered").each(function(){
205			var id = this.getAttribute('data-sticker-id');
206			$('.ab-sticker[data-id="' + id + '"]').trigger('mouseleave');
207		});
208	};
209	$(_.doc).on('touchstart', function (e) {
210		var selectors = '.ab-sticker, .ab-sticker__tooltip';
211		var jelm = $(e.target);
212		if (!jelm.is(selectors) && !jelm.parents(selectors).length) {
213			hide_active_sticker();
214		}
215	});
216
217	function is_object_empty(obj) {
218		return obj == void(0) || Object.keys(obj).length === 0;
219	}
220})(Tygh, Tygh.$);

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.