PageSourceSearch

https://abest.ru/bitrix/js/arturgolubev.chatpanel/script.js?17538757159378

js abest.ru collected 2026-09-24 09:44:18 UTC 9,378 bytes, 330 lines download raw bytes

1(function(window){
2	'use strict';
3	
4	if (window.AGChatpanel)
5		return;
6	
7	window.AGChatpanel = function(arParams)
8	{
9		this.params = arParams;
10		this.settings = {};
11		this.objs = {};
12		
13		// console.log(this.params);
14
15		this.objs.chatpanel = document.querySelector('#ag-chatpanel-wrap');
16		if(this.objs.chatpanel)
17		{			
18			this.settings.linkCount = this.objs.chatpanel.getAttribute('data-count');
19			this.settings.pulse = this.objs.chatpanel.getAttribute('data-pulse');
20			this.settings.color = this.objs.chatpanel.getAttribute('data-color');
21			this.settings.shadow = this.objs.chatpanel.getAttribute('data-shadow');
22			this.settings.showtype = this.objs.chatpanel.getAttribute('data-showtype');
23			
24			
25			this.settings.leftStyle = parseInt(this.objs.chatpanel.getAttribute('data-left'));
26			this.settings.bottomStyle = parseInt(this.objs.chatpanel.getAttribute('data-bottom'));
27			this.settings.mleftStyle = parseInt(this.objs.chatpanel.getAttribute('data-mleft'));
28			this.settings.mbottomStyle = parseInt(this.objs.chatpanel.getAttribute('data-mbottom'));
29			
30			this.settings.call = this.objs.chatpanel.getAttribute('data-call');
31			this.settings.calltime = parseInt(this.objs.chatpanel.getAttribute('data-calltime'));
32			this.settings.callrepeat = parseInt(this.objs.chatpanel.getAttribute('data-callrepeat'));
33			
34			this.objs.chatpanel_button = document.querySelector('.js-agchatpanel-button');
35			this.objs.chatpanel_href = document.querySelector('.js-agchatpanel-href');
36			this.objs.chatpanel_panel = document.querySelector('.js-agchatpanel-panel');
37			
38			this.objs.animation = document.querySelector('.ag_chatpanel_animation');
39			
40			if(this.settings.shadow == 'Y')
41				this.objs.chatpanel_shadow = document.querySelector('#ag-chatpanel-shadow');
42			
43			
44			if(this.settings.call)
45			{
46				var closeCookieValue = "N";
47				var value = "; " + document.cookie;
48				var parts = value.split("; " + "ag_cp_ch" + "=");
49				if (parts.length == 2) { closeCookieValue = parts.pop().split(";").shift(); };
50				
51				if(closeCookieValue == 'Y'){
52					this.settings.call = 0;
53				}
54			}
55			
56			if(this.settings.call)
57			{
58				this.objs.chatpanel_call = document.querySelector('.js-agchatpanel-call');
59				this.objs.chatpanel_callclose = document.querySelector('.js-agchatpanel-callclose');
60				
61				if(this.settings.calltime <= 0)
62					this.settings.calltime = 100;
63				else
64					this.settings.calltime = this.settings.calltime * 1000;
65			}
66			
67			this.init();
68		}
69	};
70	
71	window.AGChatpanel.prototype = {
72		init: function()
73		{
74			this.initEvents();
75			this.setTheme();
76			this.initLinks();
77			
78			this.objs.chatpanel.style.display = 'block';
79		},
80		
81		initLinks: function(){
82			var self = this;
83
84			var links = document.querySelectorAll('.ag_chatpanel_panel_item_link');
85			if(links.length){
86				links.forEach(function(element){
87					element.onclick = function(){
88						var ctype = element.parentElement.dataset.ctype;
89						if(self.params.chat_list[ctype].YM){
90							self.sendYmGoal(self.params.chat_list[ctype].YM);
91						}
92
93						return true;
94					}
95				});
96			}
97
98			var element = document.querySelector('.ag_chatpanel_panel_item_link_jc');
99			if(element){
100				element.onclick = function(){
101					var apiResult = jivo_api.open();
102					if(apiResult && !!apiResult.opened){
103						jivo_api.close();
104					}
105
106					return false;
107				};
108			}
109			
110			var element = document.querySelector('.ag_chatpanel_panel_item_link_bc');
111			if(element){
112				element.onclick = function(){
113					document.querySelector('.b24-widget-button-crmform span').click();
114					return false;
115				};
116			}
117		},
118
119		setTheme: function()
120		{
121			if(this.settings.color)
122			{
123				if(this.objs.chatpanel_button){
124					this.objs.chatpanel_button.style.backgroundColor = this.settings.color;
125				}
126				
127				if(this.objs.animation){
128					this.objs.animation.style.borderColor = this.settings.color;
129				}
130			}
131			
132			if(this.settings.call)
133			{
134				this.objs.chatpanel_call.style.borderColor = this.settings.color;
135
136				var self = this;
137
138				setTimeout(function(){
139					self.showCall.call(self);
140				}, self.settings.calltime);
141			}
142			
143			if(document.body.clientWidth > 768){
144				if(this.settings.bottomStyle > 0){
145					this.objs.chatpanel.style.bottom = this.settings.bottomStyle+'px';
146				}
147				
148				if(this.settings.leftStyle > 0)
149				{					
150					if(this.objs.chatpanel.classList.contains("desctop_position_right")){
151						this.objs.chatpanel.style.right = this.settings.leftStyle+'px';
152					}
153					else if(this.objs.chatpanel.classList.contains("desctop_position_left")){
154						this.objs.chatpanel.style.left = this.settings.leftStyle+'px';
155					}
156				}
157				
158			}else{
159				if(this.settings.mbottomStyle > 0){
160					this.objs.chatpanel.style.bottom = this.settings.mbottomStyle+'px';
161				}
162				
163				if(this.settings.mleftStyle > 0)
164				{					
165					if(this.objs.chatpanel.classList.contains("mobile_position_right")){
166						this.objs.chatpanel.style.right = this.settings.mleftStyle+'px';
167					}
168					else if(this.objs.chatpanel.classList.contains("mobile_position_left")){
169						this.objs.chatpanel.style.left = this.settings.mleftStyle+'px';
170					}
171				}
172			}
173			
174			
175		},
176
177		sendYmGoal: function(goal){
178			if(typeof Ya == 'object' && goal){
179				Ya._metrika.getCounters().forEach(function(ymetr){
180					ym(ymetr.id, 'reachGoal', goal);
181				});
182			}
183		},
184		
185		initEvents: function()
186		{
187			var self = this;
188
189			if(self.settings.showtype != 'open' && self.objs.chatpanel_button){
190				self.objs.chatpanel_button.addEventListener('click', function(){
191					self.clickChatpanelButton.call(self);
192				});
193			}
194			
195			if(self.settings.shadow == 'Y'){
196				self.objs.chatpanel_shadow.addEventListener('click', function(){
197					self.clickShadow.call(self);
198				});
199			}
200			
201			if(self.settings.call){
202				self.objs.chatpanel_callclose.addEventListener('click', function(){
203					self.hideCall.call(self);
204				});
205			}
206		},
207		
208		clickShadow: function(){
209			if(this.objs.chatpanel_panel.classList.contains("showed"))
210				this.hideChatpanel();
211		},
212		
213		clickChatpanelButton: function(){
214			if(this.objs.chatpanel_panel.classList.contains("showed")){
215				this.hideChatpanel();
216			}else{
217				this.showChatpanel();
218
219				if(this.params.actions.open.YM){
220					this.sendYmGoal(this.params.actions.open.YM);
221				}
222			}
223		},
224		
225		beforeShowCall: function(){
226			this.objs.chatpanel_call.style.display = 'block';
227			
228			if(this.objs.chatpanel_button){
229				var h1 = this.objs.chatpanel_button.offsetHeight;
230			}else if(this.objs.chatpanel_href){
231				var h1 = this.objs.chatpanel_href.offsetHeight;
232			}else{
233				var h1 = 0;
234			}
235			
236			var h2 = this.objs.chatpanel_call.offsetHeight, h3 = (h1-h2) / 2;
237			
238			this.objs.chatpanel_call.style.top = h3 + 'px';
239
240			if(window.innerWidth < 768){
241				if(this.objs.chatpanel.classList.contains('mobile_position_right') || this.objs.chatpanel.classList.contains('mobile_position_left')){
242					var callMaxWidth = window.innerWidth;
243
244					if(parseInt(this.objs.chatpanel.style.left)){
245						callMaxWidth = callMaxWidth - parseInt(this.objs.chatpanel.style.left);
246					}else if(parseInt(this.objs.chatpanel.style.right)){
247						callMaxWidth = callMaxWidth - parseInt(this.objs.chatpanel.style.right);
248					}
249
250					callMaxWidth = callMaxWidth - 68 - 12;
251
252					this.objs.chatpanel_call.style.width = callMaxWidth + 'px';
253				}
254			}
255		},
256		
257		showCall: function(){
258			if(this.settings.call)
259			{
260				this.beforeShowCall();
261				this.objs.chatpanel_call.classList.add('ag_chatpanel_fadein');
262			}
263		},
264		
265		hideCall: function(){
266			if(this.settings.call)
267			{
268				if(this.settings.callrepeat)
269				{
270					var expires = new Date((new Date).getTime() + (1000 * 60 * this.settings.callrepeat));
271					document.cookie = "ag_cp_ch = Y; expires=" + expires.toUTCString() + "; path=" + escape ("/");
272				}
273				
274				this.objs.chatpanel_call.classList.remove('ag_chatpanel_fadein');
275				this.objs.chatpanel_call.style.display = 'none';
276				this.objs.chatpanel_call.style.opacity = '0';
277			}
278		},
279		
280		hideChatpanel: function(){
281			if(this.settings.pulse && this.objs.animation){
282				this.objs.animation.classList.remove("stoppulseanim");
283			}
284			
285			if(this.settings.shadow == 'Y')
286			{
287				var self = this;
288
289				this.objs.chatpanel_shadow.classList.remove('ag_chatpanel_fadein');
290				this.objs.chatpanel_shadow.classList.add('ag_chatpanel_fadeout');
291
292				setTimeout(function(){
293					self.objs.chatpanel_shadow.style.display = 'none';
294				}, self.params.settings.duration);
295			}
296			
297			this.objs.chatpanel_panel.classList.remove("showed");
298
299			if(this.objs.chatpanel_button){
300				this.objs.chatpanel_button.classList.remove("panel_showed");
301			}
302			
303			this.objs.chatpanel_panel.style.height = '0px';
304		},
305		
306		showChatpanel: function(){
307			this.hideCall();
308			this.settings.call = 0;
309			
310			if(this.settings.pulse && this.objs.animation){
311				this.objs.animation.classList.add("stoppulseanim");
312			}
313			
314			if(this.settings.shadow == 'Y')
315			{
316				this.objs.chatpanel_shadow.style.display = 'block';
317				this.objs.chatpanel_shadow.classList.remove('ag_chatpanel_fadeout');
318				this.objs.chatpanel_shadow.classList.add('ag_chatpanel_fadein');
319			}
320			
321			this.objs.chatpanel_panel.classList.add("showed");
322			
323			if(this.objs.chatpanel_button){
324				this.objs.chatpanel_button.classList.add("panel_showed");
325			}
326			
327			this.objs.chatpanel_panel.style.height = (this.settings.linkCount*51+42)+'px';
328		},
329	};
330})(window);

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.