PageSourceSearch

https://www.moscowclimate.ru/bitrix/js/main/core/core_tooltip.js

js moscowclimate.ru collected 2026-09-26 03:38:30 UTC 15,458 bytes, 604 lines download raw bytes

1(function(window) {
2if (BX.tooltip) return;
3
4var arTooltipIndex = {},
5	bDisable = false;
6
7BX.tooltip = function(user_id, anchor_name, loader, rootClassName, bForceUseLoader, params)
8{
9	if (BX.message('TOOLTIP_ENABLED') != "Y")
10	{
11		return;
12	}
13
14	if (
15		BX.browser.IsAndroid()
16		|| BX.browser.IsIOS()
17	)
18	{
19		return;
20	}
21
22	BX.ready(function() {
23		var anchor = BX(anchor_name);
24		if (null == anchor)
25		{
26			return;
27		}
28
29		var tooltipId = user_id;
30		if(bForceUseLoader && BX.type.isNotEmptyString(loader))
31		{
32			// prepare tooltip ID from custom loader
33			var loaderHash = 0;
34			for(var i = 0, len = loader.length; i < len; i++)
35			{
36				loaderHash = (31 * loaderHash + loader.charCodeAt(i)) << 0;
37			}
38
39			tooltipId = loaderHash + user_id;
40		}
41
42		if (null == arTooltipIndex[tooltipId])
43		{
44			arTooltipIndex[tooltipId] = new BX.CTooltip(user_id, anchor, loader, rootClassName, bForceUseLoader, params);
45		}
46		else
47		{
48			arTooltipIndex[tooltipId].ANCHOR = anchor;
49			arTooltipIndex[tooltipId].rootClassName = rootClassName;
50			arTooltipIndex[tooltipId].LOADER = (
51				bForceUseLoader
52				&& BX.type.isNotEmptyString(loader)
53					? loader
54					: '/bitrix/tools/tooltip.php'
55			);
56			arTooltipIndex[tooltipId].params = params;
57			arTooltipIndex[tooltipId].Create();
58		}
59	});
60};
61
62BX.tooltip.disable = function(){ bDisable = true; };
63BX.tooltip.enable = function(){ bDisable = false; };
64
65BX.tooltip.hide = function(userId) {
66	if (BX('user_info_' + userId))
67	{
68		BX('user_info_' + userId).style.display = 'none';
69	}
70};
71
72BX.tooltip.openIM = function(userId) {
73	if (top.BXIM)
74	{
75		top.BXIM.openMessenger(userId);
76		BX.tooltip.hide(userId);
77	}
78	else if (BX('MULSonetMessageChatTemplate'))
79	{
80		window.open(BX('MULSonetMessageChatTemplate').replace('#user_id#', userId).replace('#USER_ID#', userId).replace('#ID#', userId), '', 'location=yes,status=no,scrollbars=yes,resizable=yes,width=700,height=550,top='+Math.floor((screen.height - 550)/2-14)+',left='+Math.floor((screen.width - 700)/2-5));
81		BX.tooltip.hide(userId);
82	}
83	return false;
84};
85
86
87BX.tooltip.openCallTo = function(userId) {
88	if (top.BXIM)
89	{
90		top.BXIM.callTo(userId);
91		BX.tooltip.hide(userId);
92	}
93	return false;
94};
95
96BX.tooltip.checkCallTo = function(nodeId) {
97	if (
98		!top.BXIM
99		|| !top.BXIM.checkCallSupport()
100	)
101	{
102		BX.remove(nodeId);
103	}
104};
105
106BX.tooltip.openVideoCall = function(userId) {
107	if (BX('MULVideoCallTemplate'))
108	{
109		window.open(BX('MULVideoCallTemplate').replace('#user_id#', userId).replace('#USER_ID#', userId).replace('#ID#', userId), '', 'location=yes,status=no,scrollbars=yes,resizable=yes,width=1000,height=600,top='+Math.floor((screen.height - 600)/2-14)+',left='+Math.floor((screen.width - 1000)/2-5));
110		BX.tooltip.hide(userId);
111	}
112	return false;
113};
114
115BX.CTooltip = function(user_id, anchor, loader, rootClassName, bForceUseLoader, params)
116{
117	this.LOADER = (
118		bForceUseLoader
119		&& BX.type.isNotEmptyString(loader)
120			? loader
121			: '/bitrix/tools/tooltip.php'
122	);
123	this.USER_ID = user_id;
124	this.ANCHOR = anchor;
125	this.rootClassName = '';
126	this.params = (typeof params != 'undefined' ? params : {});
127
128	if (
129		rootClassName != 'undefined'
130		&& rootClassName != null
131		&& rootClassName.length > 0
132	)
133	{
134		this.rootClassName = rootClassName;
135	}
136
137	var old = document.getElementById('user_info_' + this.USER_ID);
138	if (null != old)
139	{
140		if (null != old.parentNode)
141			old.parentNode.removeChild(old);
142
143		old = null;
144	}
145
146	var _this = this;
147
148	this.INFO = null;
149
150	this.width = 393;
151	this.height = 302;
152
153	this.RealAnchor = null;
154	this.CoordsLeft = 0;
155	this.CoordsTop = 0;
156	this.AnchorRight = 0;
157	this.AnchorBottom = 0;
158
159	this.DIV = null;
160	this.ROOT_DIV = null;
161
162	if (BX.browser.IsIE())
163	{
164		this.IFRAME = null;
165	}
166
167	this.v_delta = 0;
168	this.classNameAnim = false;
169	this.classNameFixed = false;
170
171	this.left = 0;
172	this.top = 0;
173
174	this.tracking = false;
175	this.active = false;
176	this.showed = false;
177
178	this.Create = function()
179	{
180		_this.ANCHOR.onmouseover = function() {
181			if (!bDisable)
182			{
183				_this.StartTrackMouse(this);
184			}
185		};
186
187		_this.ANCHOR.onmouseout = function() {
188			_this.StopTrackMouse(this);
189		}
190	};
191
192	this.Create();
193
194	this.TrackMouse = function(e)
195	{
196		if(!_this.tracking)
197			return;
198
199		var current;
200		if(e && e.pageX)
201			current = {x: e.pageX, y: e.pageY};
202		else
203			current = {x: e.clientX + document.body.scrollLeft, y: e.clientY + document.body.scrollTop};
204
205		if(current.x < 0)
206			current.x = 0;
207		if(current.y < 0)
208			current.y = 0;
209
210		current.time = _this.tracking;
211
212		if(!_this.active)
213			_this.active = current;
214		else
215		{
216			if(
217				_this.active.x >= (current.x - 1) && _this.active.x <= (current.x + 1)
218				&& _this.active.y >= (current.y - 1) && _this.active.y <= (current.y + 1)
219			)
220			{
221				if((_this.active.time + 20/*2sec*/) <= current.time)
222					_this.ShowTooltip();
223			}
224			else
225				_this.active = current;
226		}
227	};
228
229	this.ShowTooltip = function()
230	{
231		var old = document.getElementById('user_info_' + _this.USER_ID);
232		if(bDisable || old && old.style.display == 'block')
233			return;
234
235		var bIE = (BX.browser.IsIE() && !BX.browser.IsIE10());
236
237		if (!BX.type.isPlainObject(this.params))
238		{
239			this.params = {};
240		}
241
242		if (null == _this.DIV && null == _this.ROOT_DIV)
243		{
244			_this.ROOT_DIV = document.body.appendChild(document.createElement('DIV'));
245			_this.ROOT_DIV.style.position = 'absolute';
246
247			BX.ZIndexManager.register(_this.ROOT_DIV);
248
249			_this.DIV = _this.ROOT_DIV.appendChild(document.createElement('DIV'));
250			if (bIE)
251				_this.DIV.className = 'bx-user-info-shadow-ie';
252			else
253				_this.DIV.className = 'bx-user-info-shadow';
254
255			_this.DIV.style.width = _this.width + 'px';
256			_this.DIV.style.height = _this.height + 'px';
257		}
258
259		var left = _this.CoordsLeft;
260		var top = _this.CoordsTop + 30;
261		var arScroll = BX.GetWindowScrollPos();
262		var body = document.body;
263
264		var h_mirror = false;
265		var v_mirror = false;
266
267		if((body.clientWidth + arScroll.scrollLeft) < (left + _this.width))
268		{
269			left = _this.AnchorRight - _this.width;
270			h_mirror = true;
271		}
272
273		if((top - arScroll.scrollTop) < 0)
274		{
275			top = _this.AnchorBottom - 5;
276			v_mirror = true;
277			_this.v_delta = 40;
278		}
279		else
280			_this.v_delta = 0;
281
282		_this.ROOT_DIV.style.left = parseInt(left) + "px";
283		_this.ROOT_DIV.style.top = parseInt(top) + "px";
284
285		BX.ZIndexManager.bringToFront(_this.ROOT_DIV);
286
287		BX.bind(BX(_this.ROOT_DIV), "click", BX.eventCancelBubble);
288
289		if (
290			this.rootClassName != 'undefined'
291			&& this.rootClassName != null
292			&& this.rootClassName.length > 0
293		)
294			_this.ROOT_DIV.className = this.rootClassName;
295
296		if ('' == _this.DIV.innerHTML)
297		{
298			var url = _this.LOADER +
299				(_this.LOADER.indexOf('?') >= 0 ? '&' : '?') +
300				'MUL_MODE=INFO&USER_ID=' + _this.USER_ID +
301				'&site=' + (BX.message('SITE_ID') || '') +
302				(
303					typeof _this.params != 'undefined'
304					&& typeof _this.params.entityType != 'undefined'
305					&& _this.params.entityType.length > 0
306						? '&entityType=' + _this.params.entityType
307						: ''
308				) +
309				(
310					typeof _this.params != 'undefined'
311					&& typeof _this.params.entityId != 'undefined'
312					&& parseInt(_this.params.entityId) > 0
313						? '&entityId=' + parseInt(_this.params.entityId)
314						: ''
315				);
316
317			BX.ajax.get(url, _this.InsertData);
318			_this.DIV.id = 'user_info_' + _this.USER_ID;
319
320			_this.DIV.innerHTML = '<div class="bx-user-info-wrap">'
321				+ '<div class="bx-user-info-leftcolumn">'
322					+ '<div class="bx-user-photo" id="user-info-photo-' + _this.USER_ID + '"><div class="bx-user-info-data-loading">' + BX.message('JS_CORE_LOADING') + '</div></div>'
323					+ '<div class="bx-user-tb-control bx-user-tb-control-left" id="user-info-toolbar-' + _this.USER_ID + '"></div>'
324				+ '</div>'
325				+ '<div class="bx-user-info-data">'
326					+ '<div id="user-info-data-card-' + _this.USER_ID + '"></div>'
327					+ '<div class="bx-user-info-data-tools">'
328						+ '<div class="bx-user-tb-control bx-user-tb-control-right" id="user-info-toolbar2-' + _this.USER_ID + '"></div>'
329						+ '<div class="bx-user-info-data-clear"></div>'
330					+ '</div>'
331				+ '</div>'
332				+ '</div><div class="bx-user-info-bottomarea"></div>';
333		}
334
335		if (bIE)
336		{
337			_this.DIV.className = 'bx-user-info-shadow-ie';
338			_this.classNameAnim = 'bx-user-info-shadow-anim-ie';
339			_this.classNameFixed = 'bx-user-info-shadow-ie';
340		}
341		else
342		{
343			_this.DIV.className = 'bx-user-info-shadow';
344			_this.classNameAnim = 'bx-user-info-shadow-anim';
345			_this.classNameFixed = 'bx-user-info-shadow';
346		}
347
348		_this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-left-top.png', sizingMethod = 'crop' );";
349
350		if (h_mirror && v_mirror)
351		{
352			if (BX.browser.IsIE6())
353			{
354				_this.DIV.className = 'bx-user-info-shadow-hv-ie6';
355				_this.classNameAnim = 'bx-user-info-shadow-hv-anim-ie6';
356				_this.classNameFixed = 'bx-user-info-shadow-hv-ie6';
357			}
358			else if (bIE)
359			{
360				_this.DIV.className = 'bx-user-info-shadow-hv-ie';
361				_this.classNameAnim = 'bx-user-info-shadow-hv-anim-ie';
362				_this.classNameFixed = 'bx-user-info-shadow-hv-ie';
363			}
364			else
365			{
366				_this.DIV.className = 'bx-user-info-shadow-hv';
367				_this.classNameAnim = 'bx-user-info-shadow-hv-anim';
368				_this.classNameFixed = 'bx-user-info-shadow-hv';
369			}
370
371			_this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-right-bottom.png', sizingMethod = 'crop' );";
372		}
373		else
374		{
375			if (h_mirror)
376			{
377				if (bIE)
378				{
379					_this.DIV.className = 'bx-user-info-shadow-h-ie';
380					_this.classNameAnim = 'bx-user-info-shadow-h-anim-ie';
381					_this.classNameFixed = 'bx-user-info-shadow-h-ie';
382				}
383				else
384				{
385					_this.DIV.className = 'bx-user-info-shadow-h';
386					_this.classNameAnim = 'bx-user-info-shadow-h-anim';
387					_this.classNameFixed = 'bx-user-info-shadow-h';
388				}
389
390				_this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitr
390ix/components/bitrix/main.user.link/templates/.default/images/cloud-right-top.png', sizingMethod = 'crop' );";
391			}
392
393			if (v_mirror)
394			{
395				if (BX.browser.IsIE6())
396				{
397					_this.DIV.className = 'bx-user-info-shadow-v-ie6';
398					_this.classNameAnim = 'bx-user-info-shadow-v-anim-ie6';
399					_this.classNameFixed = 'bx-user-info-shadow-v-ie6';
400				}
401				else if (bIE)
402				{
403					_this.DIV.className = 'bx-user-info-shadow-v-ie';
404					_this.classNameAnim = 'bx-user-info-shadow-v-anim-ie';
405					_this.classNameFixed = 'bx-user-info-shadow-v-ie';
406				}
407				else
408				{
409					_this.DIV.className = 'bx-user-info-shadow-v';
410					_this.classNameAnim = 'bx-user-info-shadow-v-anim';
411					_this.classNameFixed = 'bx-user-info-shadow-v';
412				}
413
414				_this.filterFixed = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/bitrix/components/bitrix/main.user.link/templates/.default/images/cloud-left-bottom.png', sizingMethod = 'crop' );";
415			}
416		}
417
418
419		if (BX.browser.IsIE() && null == _this.IFRAME)
420		{
421			_this.IFRAME = document.body.appendChild(document.createElement('IFRAME'));
422			_this.IFRAME.id = _this.DIV.id + "_frame";
423			_this.IFRAME.style.position = 'absolute';
424			_this.IFRAME.style.width = (_this.width - 60) + 'px';
425			_this.IFRAME.style.height = (_this.height - 100) + 'px';
426			_this.IFRAME.style.borderStyle = 'solid';
427			_this.IFRAME.style.borderWidth = '0px';
428			_this.IFRAME.style.zIndex = 550;
429			_this.IFRAME.style.display = 'none';
430		}
431		if (BX.browser.IsIE())
432		{
433			_this.IFRAME.style.left = (parseInt(left) + 25) + "px";
434			_this.IFRAME.style.top = (parseInt(top) + 30 + _this.v_delta) + "px";
435		}
436
437		_this.DIV.style.display = 'none';
438		_this.ShowOpacityEffect({func: _this.SetVisible, obj: _this.DIV, arParams: []}, 0);
439
440		document.getElementById('user_info_' + _this.USER_ID).onmouseover = function() {
441			_this.StartTrackMouse(this);
442		};
443
444		document.getElementById('user_info_' + _this.USER_ID).onmouseout = function() {
445			_this.StopTrackMouse(this);
446		};
447
448		BX.onCustomEvent('onTooltipShow', [this]);
449	};
450
451	this.InsertData = function(data)
452	{
453		if (null != data && data.length > 0)
454		{
455			eval('_this.INFO = ' + data);
456
457			var cardEl = document.getElementById('user-info-data-card-' + _this.USER_ID);
458			cardEl.innerHTML = _this.INFO.RESULT.Card;
459
460			var photoEl = document.getElementById('user-info-photo-' + _this.USER_ID);
461			photoEl.innerHTML = _this.INFO.RESULT.Photo;
462
463			var toolbarEl = document.getElementById('user-info-toolbar-' + _this.USER_ID);
464			toolbarEl.innerHTML = _this.INFO.RESULT.Toolbar;
465
466			var toolbar2El = document.getElementById('user-info-toolbar2-' + _this.USER_ID);
467			toolbar2El.innerHTML = _this.INFO.RESULT.Toolbar2;
468
469			if(BX.type.isArray(_this.INFO.RESULT.Scripts))
470			{
471				for(var i = 0; i < _this.INFO.RESULT.Scripts.length; i++)
472				{
473					eval(_this.INFO.RESULT.Scripts[i]);
474				}
475			}
476
477			BX.onCustomEvent('onTooltipInsertData', [_this]);
478		}
479	}
480
481};
482BX.CTooltip.prototype.StartTrackMouse = function(ob)
483{
484	var _this = this;
485
486	if(!this.tracking)
487	{
488		var elCoords = BX.pos(ob);
489		this.RealAnchor = ob;
490		this.CoordsLeft = elCoords.left + 0;
491		this.CoordsTop = elCoords.top - 325;
492		this.AnchorRight = elCoords.right;
493		this.AnchorBottom = elCoords.bottom;
494
495		this.tracking = 1;
496		BX.bind(document, "mousemove", _this.TrackMouse);
497
498		setTimeout(function() {_this.tickTimer()}, 500);
499	}
500};
501
502BX.CTooltip.prototype.StopTrackMouse = function()
503{
504	var _this = this;
505	if(this.tracking)
506	{
507		BX.unbind(document, "mousemove", _this.TrackMouse);
508		this.active = false;
509		setTimeout(function() {_this.HideTooltip()}, 500);
510		this.tracking = false;
511	}
512};
513
514BX.CTooltip.prototype.tickTimer = function()
515{
516	var _this = this;
517
518	if(this.tracking)
519	{
520		this.tracking++;
521		if(this.active)
522		{
523			if( (this.active.time + 5/*0.5sec*/)  <= this.tracking)
524				this.ShowTooltip();
525		}
526		setTimeout(function() {_this.tickTimer()}, 100);
527	}
528};
529
530BX.CTooltip.prototype.HideTooltip = function()
531{
532	if(!this.tracking)
533		this.ShowOpacityEffect({func: this.SetInVisible, obj: this.DIV, arParams: []}, 1);
534};
535
536BX.CTooltip.prototype.ShowOpacityEffect = function(oCallback, bFade)
537{
538	var steps = 3;
539	var period = 1;
540	var delta = 1 / steps;
541	var i = 0, op, _this = this;
542
543	if(BX.browser.IsIE() && _this.DIV)
544		_this.DIV.className = _this.classNameAnim;
545
546	var show = function()
547	{
548		i++;
549		if (i > steps)
550		{
551			clearInterval(intId);
552			if (!oCallback.arParams)
553				oCallback.arParams = [];
554			if (oCallback.func && oCallback.obj)
555				oCallback.func.apply(oCallback.obj, oCallback.arParams);
556			return;
557		}
558		op = bFade ? 1 - i * delta : i * delta;
559
560		if (_this.DIV != null)
561		{
562			try{
563				_this.DIV.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (op * 100) + ')';
564				_this.DIV.style.opacity = op;
565				_this.DIV.style.MozOpacity = op;
566				_this.DIV.style.KhtmlOpacity = op;
567			}
568			catch(e){
569			}
570			finally{
571				if (!bFade && i == 1)
572					_this.DIV.style.display = 'block';
573
574				if (bFade && i == steps && _this.DIV)
575					_this.DIV.style.display = 'none';
576
577
578				if (BX.browser.IsIE() && i == 1 && bFade && _this.IFRAME)
579					_this.IFRAME.style.display = 'none';
580
581
582				if (BX.browser.IsIE() && i == steps && _this.DIV)
583				{
584					if (!bFade)
585						_this.IFRAME.style.display = 'block';
586
587					_this.DIV.style.filter = _this.filterFixed;
588					_this.DIV.className = _this.classNameFixed;
589					_this.DIV.innerHTML = ''+_this.DIV.innerHTML;
590				}
591
592				if(bFade)
593				{
594					BX.onCustomEvent('onTooltipHide', [_this]);
595				}
596			}
597		}
598
599	};
600	var intId = setInterval(show, period);
601
602}
603
604})(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.