PageSourceSearch

https://prudtorg.ru/bitrix/js/ui/tooltip/dist/tooltip.bundle.js?178844850617883

js prudtorg.ru collected 2026-10-04 20:10:56 UTC 17,883 bytes, 473 lines download raw bytes

1/* eslint-disable */
2this.BX = this.BX || {};
3(function (exports, main_core, main_core_events) {
4	'use strict';
5
6	const Context = Object.freeze({
7		B24: 'b24'
8	});
9	class Interceptor {
10		static try(context, userId, node) {
11			if (context !== Context.B24) {
12				return false;
13			}
14			if (!main_core.Type.isStringFilled(userId) || !main_core.Type.isNumber(Number(userId))) {
15				return false;
16			}
17			if (BX.Intranet?.User?.UserMiniProfileManager) {
18				const direction = node.getAttribute('bx-tooltip-mini-profile-direction');
19				BX.Intranet.User.UserMiniProfileManager.create({
20					id: userId,
21					userId: Number(userId),
22					bindElement: node,
23					direction: direction === 'viewport' ? 'viewport' : null
24				});
25				return true;
26			}
27			return false;
28		}
29	}
30
31	class Tooltip {
32		static disabled = false;
33		static tooltipsList = {};
34		static disable() {
35			this.disabled = true;
36		}
37		static enable() {
38			this.disabled = false;
39		}
40		static getDisabledStatus() {
41			return this.disabled;
42		}
43		static getLoader() {
44			return '/bitrix/tools/tooltip.php';
45		}
46		static getIdPrefix() {
47			return 'bx-ui-tooltip-';
48		}
49	}
50
51	class TooltipBalloon {
52		constructor(params) {
53			this.node = null;
54			this.userId = null;
55			this.loader = null;
56			this.version = null;
57			this.tracking = false;
58			this.active = false;
59			this.width = 364; // 393
60			this.height = 215; // 302
61			this.realAnchor = null;
62			this.coordsLeft = 0;
63			this.coordsTop = 0;
64			this.anchorRight = 0;
65			this.anchorTop = 0;
66			this.hMirror = false;
67			this.vMirror = false;
68			this.rootClassName = '';
69			this.INFO = null;
70			this.DIV = null;
71			this.ROOT_DIV = null;
72			this.params = {};
73			this.trackMouseHandle = this.trackMouse.bind(this);
74			this.init(params);
75			this.create();
76			return this;
77		}
78		init(params) {
79			this.node = params.node;
80			this.userId = params.userId;
81			this.loader = main_core.Type.isStringFilled(params.loader) ? params.loader : '';
82			this.version = !main_core.Type.isUndefined(params.version) && parseInt(params.version) > 0 ? parseInt(params.version) : main_core.Type.isStringFilled(this.loader) ? 2 : 3;
83			this.rootClassName = this.node.getAttribute('bx-tooltip-classname');
84			const paramsString = this.node.getAttribute('bx-tooltip-params');
85			let anchorParams = {};
86			if (main_core.Type.isStringFilled(paramsString)) {
87				anchorParams = JSON.parse(paramsString);
88				if (!main_core.Type.isPlainObject(anchorParams)) {
89					anchorParams = {};
90				}
91			}
92			this.params = anchorParams;
93			main_core_events.EventEmitter.subscribe('SidePanel.Slider:onOpen', this.onSliderOpen.bind(this));
94		}
95		create() {
96			if (!Tooltip.getDisabledStatus()) {
97				this.startTrackMouse();
98			}
99			main_core.Event.bind(this.node, 'mouseout', this.stopTrackMouse.bind(this));
100		}
101		onSliderOpen() {
102			if (this.tracking) {
103				this.stopTrackMouse();
104			} else {
105				this.hideTooltip();
106			}
107		}
108		startTrackMouse() {
109			if (this.tracking) {
110				return;
111			}
112			this.elCoords = BX.pos(this.node);
113			this.realAnchor = this.node;
114			this.coordsLeft = this.elCoords.width < 40 ? this.elCoords.left - 35 : this.elCoords.left + 0;
115			this.coordsTop = this.elCoords.top - 245; // 325
116			this.anchorRight = this.elCoords.right;
117			this.anchorTop = this.elCoords.top;
118			this.tracking = true;
119			document.addEventListener('mousemove', this.trackMouseHandle);
120			setTimeout(() => {
121				this.tickTimer();
122			}, 500);
123			this.node.addEventListener('mouseout', this.stopTrackMouse.bind(this));
124			this.node.removeEventListener('click', this.handleClick);
125			this.node.addEventListener('click', this.handleClick);
126		}
127		handleClick = () => {
128			this.hideTooltip();
129			this.stopTrackMouse();
130		};
131		stopTrackMouse() {
132			if (!this.tracking) {
133				return;
134			}
135			document.removeEventListener('mousemove', this.trackMouseHandle);
136			this.active = false;
137			setTimeout(() => {
138				this.hideTooltip();
139			}, 100);
140			this.tracking = false;
141		}
142		trackMouse(e) {
143			if (!this.tracking) {
144				return;
145			}
146			const current = e && e.pageX ? {
147				x: e.pageX,
148				y: e.pageY
149			} : {
150				x: e.clientX + document.body.scrollLeft,
151				y: e.clientY + document.body.scrollTop
152			};
153			if (current.x < 0) {
154				current.x = 0;
155			}
156			if (current.y < 0) {
157				current.y = 0;
158			}
159			current.time = this.tracking;
160			if (!this.active) {
161				this.active = current;
162			} else {
163				if (this.active.x >= current.x - 1 && this.active.x <= current.x + 1 && this.active.y >= current.y - 1 && this.active.y <= current.y + 1) {
164					if (this.active.time + 20 /*2sec*/ <= current.time) {
165						this.showTooltip();
166					}
167				} else {
168					this.active = current;
169				}
170			}
171		}
172		tickTimer() {
173			if (!this.tracking) {
174				return;
175			}
176			this.tracking++;
177			if (this.active) {
178				if (this.active.time + 3 /*0.3sec*/ <= this.tracking) {
179					this.showTooltip();
180				}
181			}
182			setTimeout(() => {
183				this.tickTimer();
184			}, 100);
185		}
186		hideTooltip() {
187			if (this.tracking) {
188				return;
189			}
190			this.showOpacityEffect(1);
191		}
192		showOpacityEffect(bFade) {
193			const steps = 3;
194			const period = 1;
195			const delta = 1 / steps;
196			let i = 0;
197			const intId = setInterval(() => {
198				i++;
199				if (i > steps) {
200					clearInterval(intId);
201					return;
202				}
203				const op = bFade ? 1 - i * delta : i * delta;
204				if (this.DIV != null) {
205					try {
206						this.DIV.style.opacity = op;
207					} catch (e) {} finally {
208						if (!bFade && i == 1) {
209							this.DIV.classList.add('ui-tooltip-info-shadow-show');
210							this.DIV.style.display = 'block';
211						}
212						if (bFade && i == steps && this.DIV) {
213							this.DIV.classList.remove('ui-tooltip-info-shadow-show');
214							this.DIV.classList.add('ui-tooltip-info-shadow-hide');
215							setTimeout(() => {
216								this.DIV.style.display = 'none';
217							}, 500);
218						}
219						if (bFade) {
220							main_core_events.EventEmitter.emit('onTooltipHide', new main_core_events.BaseEvent({
221								compatData: [this]
222							}));
223						}
224					}
225				}
226			}, period);
227		}
228		showTooltip() {
229			const old = document.getElementById(`${Tooltip.getIdPrefix()}${this.userId}`);
230			if (Tooltip.getDisabledStatus() || old && old.classList.contains('ui-tooltip-info-shadow-show')) {
231				return;
232			}
233			if (null == this.DIV && null == this.ROOT_DIV) {
234				this.ROOT_DIV = document.body.appendChild(document.createElement('DIV'));
235				this.ROOT_DIV.style.position = 'absolute';
236				BX.ZIndexManager.register(this.ROOT_DIV);
237				this.DIV = this.ROOT_DIV.appendChild(document.createElement('DIV'));
238				this.DIV.className = 'bx-ui-tooltip-info-shadow';
239				this.DIV.style.width = `${this.width}px`;
240			}
241			let left = this.coordsLeft;
242			const top = this.coordsTop + 30;
243			const arScroll = BX.GetWindowScrollPos();
244			const body = document.body;
245			this.hMirror = false;
246			this.vMirror = top - arScroll.scrollTop - 50 < 0;
247			if (body.clientWidth + arScroll.scrollLeft < left + this.width) {
248				left = this.anchorRight - this.width;
249				this.hMirror = true;
250			}
251			this.ROOT_DIV.style.left = `${parseInt(left)}px`;
252			this.ROOT_DIV.style.top = `${parseInt(top)}px`;
253			BX.ZIndexManager.bringToFront(this.ROOT_DIV);
254			this.ROOT_DIV.addEventListener('click', e => {
255				e.stopPropagation();
256			});
257			if (main_core.Type.isStringFilled(this.rootClassName)) {
258				this.ROOT_DIV.className = this.rootClassName;
259			}
260			const loader = main_core.Type.isStringFilled(this.loader) ? this.loader : Tooltip.getLoader();
261
262			// create stub
263			let stubCreated = false;
264			if ('' == this.DIV.innerHTML) {
265				stubCreated = true;
266				if (this.version >= 3) {
267					main_core.ajax.runComponentAction('bitrix:ui.tooltip', 'getData', {
268						mode: 'ajax',
269						data: {
270							userId: this.userId,
271							params: !main_core.Type.isUndefined(this.params) ? this.params : {}
272						}
273					}).then(response => {
274						const detailUrl = main_core.Type.isStringFilled(response.data.user.detailUrl) ? response.data.user.detailUrl : '';
275						let cardUserName = '';
276						if (main_core.Type.isStringFilled(response.data.user.nameFormatted)) {
277							const {
278								nameFormatted = ''
279							} = response.data.user;
280							if (main_core.Type.isStringFilled(detailUrl)) {
281								cardUserName = `
282											<a
283												class="bx-ui-tooltip-user-name"
284												title="${nameFormatted}"
285												href="${detailUrl}"
286											>
287												${response.data.user.nameFormatted}
288											</a>`;
289							} else {
290								cardUserName = `
291											<span 
292												class="bx-ui-tooltip-user-name"
293												title="${nameFormatted}"
294											>
295												response.data.user.nameFormatted
296											</span>`;
297							}
298						}
299						let cardFields = '<div class="bx-ui-tooltip-info-data-info">';
300						Object.keys(response.data.user.cardFields).forEach(fieldCode => {
301							cardFields += `<span class="bx-ui-tooltip-field-row bx-ui-tooltip-field-row-${fieldCode.toLowerCase()}"><span class="bx-ui-tooltip-field-name">${response.data.user.cardFields[fieldCode].name}</span>: <span class="bx-ui-tooltip-field-value">${response.data.user.cardFields[fieldCode].value}</span></span>`;
302						});
303						cardFields += '</div>';
304						const cardFieldsClassName = parseInt(main_core.Loc.getMessage('USER_ID')) > 0 && response.data.currentUserPerms.operations.videocall ? 'bx-ui-tooltip-info-data-cont-video' : 'bx-ui-tooltip-info-data-cont';
305						cardFields = `<div id="bx_user_info_data_cont_${response.data.user.id}" class="${cardFieldsClassName}">${cardFields}</div>`;
306						let photo = '';
307						let photoClassName = 'bx-ui-tooltip-info-data-photo no-photo';
308						if (main_core.Type.isStringFilled(response.data.user.photo)) {
309							photo = response.data.user.photo;
310							photoClassName = 'bx-ui-tooltip-info-data-photo';
311						}
312						photo = main_core.Type.isStringFilled(detailUrl) ? `<a href="${detailUrl}" class="${photoClassName}">${photo}</a>` : `<span class="${photoClassName}">${photo}</span>`;
313						let toolbar = '';
314						let toolbar2 = '';
315						if (parseInt(main_core.Loc.getMessage('USER_ID')) > 0 && response.data.user.active && response.data.user.id != main_core.Loc.getMessage('USER_ID') && response.data.currentUserPerms.operations.message) {
316							toolbar2 += `<li class="bx-icon bx-icon-message"><span onclick="return BX.Messenger.Public.openChat(${response.data.user.id});">${main_core.Loc.getMessage('MAIN_UL_TOOLBAR_MESSAGES_CHAT')}</span></li>`;
317							toolbar2 += `<li id="im-video-call-button${response.data.user.id}" class="bx-icon bx-icon-video"><span onclick="return BX.tooltip.openCallTo(${response.data.user.id});">${main_core.Loc.getMessage('MAIN_UL_TOOLBAR_VIDEO_CALL')}</span></li>`;
318							toolbar2 += `<script>Event.ready(() => { BX.tooltip.checkCallTo("im-video-call-button${response.data.user.id}"); };</script>`;
319						}
320						toolbar2 = main_core.Type.isStringFilled(toolbar2) ? `<div class="bx-ui-tooltip-info-data-separator"></div><ul>${toolbar2}</ul>` : '';
321						if (response.data.user.hasBirthday) {
322							toolbar += `<li class="bx-icon bx-icon-birth">${main_core.Loc.getMessage('MAIN_UL_TOOLBAR_BIRTHDAY')}</li>`;
323						}
324						if (response.data.user.hasHonour) {
325							toolbar += `<li class="bx-icon bx-icon-featured">${main_core.Loc.getMessage('MAIN_UL_TOOLBAR_HONORED')}</li>`;
326						}
327						if (response.data.user.hasAbsence) {
328							toolbar += `<li class="bx-icon bx-icon-away">${main_core.Loc.getMessage('MAIN_UL_TOOLBAR_ABSENT')}</li>`;
329						}
330						toolbar = main_core.Type.isStringFilled(toolbar) ? `<ul>${toolbar}</ul>` : '';
331						this.insertData({
332							RESULT: {
333								Name: cardUserName,
334								Position: main_core.Type.isStringFilled(response.data.user.position) ? response.data.user.position : '',
335								Card: cardFields,
336								Photo: photo,
337								Toolbar: toolbar,
338								Toolbar2: toolbar2
339							}
340						});
341						this.adjustPosition();
342					}, () => {});
343				} else {
344					const url = loader + (loader.indexOf('?') >= 0 ? '&' : '?') + `MODE=UI&MUL_MODE=INFO&USER_ID=${this.userId}` + `&site=${main_core.Loc.getMessage('SITE_ID') || ''}` + `&version=${this.version}` + (!main_core.Type.isUndefined(this.params) && !main_core.Type.isUndefined(this.params.entityType) && main_core.Type.isStringFilled(this.params.entityType) ? `&entityType=${this.params.entityType}` : '') + (!main_core.Type.isUndefined(this.params) && !main_core.Type.isUndefined(this.params.entityId) && parseInt(this.params.entityId) > 0 ? `&entityId=${parseInt(this.params.entityId)}` : '');
345					main_core.ajax.get(url, data => {
346						this.insertData(data);
347						this.adjustPosition();
348					});
349				}
350				this.DIV.id = `${Tooltip.getIdPrefix()}${this.userId}`;
351				this.DIV.innerHTML = '<div class="bx-ui-tooltip-info-wrap">' + '<div class="bx-ui-tooltip-info-leftcolumn">' + `<div class="bx-ui-tooltip-photo" id="${Tooltip.getIdPrefix()}photo-${this.userId}"><div class="bx-ui-tooltip-info-data-loading">${main_core.Loc.getMessage('JS_CORE_LOADING')}</div></div>` + '</div>' + '<div class="bx-ui-tooltip-info-data">' + `<div id="${Tooltip.getIdPrefix()}data-card-${this.userId}"></div>` + '<div class="bx-ui-tooltip-info-data-tools">' + `<div class="bx-ui-tooltip-tb-control bx-ui-tooltip-tb-control-left" id="${Tooltip.getIdPrefix()}toolbar-${this.userId}"></div>` + `<div class="bx-ui-tooltip-tb-control bx-ui-tooltip-tb-control-right" id="${Tooltip.getIdPrefix()}toolbar2-${this.userId}"></div>` + '<div class="bx-ui-tooltip-info-data-clear"></div>' + '</div>' + '</div>' + '</div><div class="bx-ui-tooltip-info-bottomarea"></div>';
352			}
353			this.DIV.className = 'bx-ui-tooltip-info-shadow';
354			this.classNameAnim = 'bx-ui-tooltip-info-shadow-anim';
355			this.classNameFixed = 'bx-ui-tooltip-info-shadow';
356			if (this.hMirror && this.vMirror) {
357				this.DIV.className = 'bx-ui-tooltip-info-shadow-hv';
358				this.classNameAnim = 'bx-ui-tooltip-info-shadow-hv-anim';
359				this.classNameFixed = 'bx-ui-tooltip-info-shadow-hv';
360			} else {
361				if (this.hMirror) {
362					this.DIV.className = 'bx-ui-tooltip-info-shadow-h';
363					this.classNameAnim = 'bx-ui-tooltip-info-shadow-h-anim';
364					this.classNameFixed = 'bx-ui-tooltip-info-shadow-h';
365				}
366				if (this.vMirror) {
367					this.DIV.className = 'bx-ui-tooltip-info-shadow-v';
368					this.classNameAnim = 'bx-ui-tooltip-info-shadow-v-anim';
369					this.classNameFixed = 'bx-ui-tooltip-info-shadow-v';
370				}
371			}
372			this.DIV.style.display = 'block';
373			if (!stubCreated) {
374				this.adjustPosition();
375			}
376			this.showOpacityEffect(0);
377			document.getElementById(`${Tooltip.getIdPrefix()}${this.userId}`).onmouseover = () => {
378				this.startTrackMouse(this);
379			};
380			document.getElementById(`${Tooltip.getIdPrefix()}${this.userId}`).onmouseout = () => {
381				this.stopTrackMouse(this);
382			};
383			main_core_events.EventEmitter.emit('onTooltipShow', new main_core_events.BaseEvent({
384				compatData: [this]
385			}));
386		}
387		adjustPosition() {
388			const tooltipCoords = BX.pos(this.DIV);
389			if (this.vMirror) {
390				this.ROOT_DIV.style.top = `${parseInt(this.anchorTop + this.elCoords.height)}px`;
391			} else {
392				this.ROOT_DIV.style.top = `${parseInt(this.anchorTop - tooltipCoords.height - 13 + 12)}px`; // 12 - bottom block
393			}
394		}
395		insertData(data) {
396			if (null != data && (this.version >= 3 || data.length > 0)) {
397				if (this.version >= 3) {
398					this.INFO = data;
399				} else {
400					eval(`this.INFO = ${data}`);
401				}
402				const cardEl = document.getElementById(`${Tooltip.getIdPrefix()}data-card-${this.userId}`);
403				cardEl.innerHTML = '';
404				if (main_core.Type.isStringFilled(this.INFO.RESULT.Name)) {
405					cardEl.innerHTML += `<div class="bx-ui-tooltip-user-name-block">${this.INFO.RESULT.Name}</div>`;
406				}
407				if (main_core.Type.isStringFilled(this.INFO.RESULT.Position)) {
408					cardEl.innerHTML += `<div class="bx-ui-tooltip-user-position">${this.INFO.RESULT.Position}</div>`;
409				}
410				cardEl.innerHTML += this.INFO.RESULT.Card;
411				const photoEl = document.getElementById(`${Tooltip.getIdPrefix()}photo-${this.userId}`);
412				photoEl.innerHTML = this.INFO.RESULT.Photo;
413				const toolbarEl = document.getElementById(`${Tooltip.getIdPrefix()}toolbar-${this.userId}`);
414				toolbarEl.innerHTML = this.INFO.RESULT.Toolbar;
415				const toolbar2El = document.getElementById(`${Tooltip.getIdPrefix()}toolbar2-${this.userId}`);
416				toolbar2El.innerHTML = this.INFO.RESULT.Toolbar2;
417				if (main_core.Type.isArray(this.INFO.RESULT.Scripts)) {
418					this.INFO.RESULT.Scripts.forEach(script => {
419						eval(script);
420					});
421				}
422				main_core_events.EventEmitter.emit('onTooltipInsertData', new main_core_events.BaseEvent({
423					compatData: [this]
424				}));
425			}
426		}
427	}
428
429	main_core.Event.ready(() => {
430		if (main_core.Browser.isAndroid() || main_core.Browser.isIOS()) {
431			return;
432		}
433		main_core.Event.bind(document, 'mouseover', e => {
434			const node = e.target;
435			if (!main_core.Type.isElementNode(node)) {
436				return;
437			}
438			const userId = node.getAttribute('bx-tooltip-user-id');
439			const loader = node.getAttribute('bx-tooltip-loader');
440			const context = node.getAttribute('bx-tooltip-context');
441			if (main_core.Type.isStringFilled(context) && Interceptor.try(context, userId, node)) {
442				return;
443			}
444			let tooltipId = userId; // don't use integer value!
445
446			if (main_core.Type.isStringFilled(loader)) {
447				let loaderHash = 0;
448				[...loader].forEach((c, i) => {
449					loaderHash = 31 * loaderHash + loader.charCodeAt(i) << 0;
450				});
451				tooltipId = loaderHash + userId;
452			}
453			if (main_core.Type.isStringFilled(userId)) {
454				if (null == Tooltip.tooltipsList[tooltipId]) {
455					Tooltip.tooltipsList[tooltipId] = new TooltipBalloon({
456						userId: userId,
457						node: node,
458						loader: loader
459					});
460				} else {
461					Tooltip.tooltipsList[tooltipId].node = node;
462					Tooltip.tooltipsList[tooltipId].create();
463				}
464				e.preventDefault();
465			}
466		});
467	});
468
469	exports.Tooltip = Tooltip;
470	exports.TooltipBalloon = TooltipBalloon;
471
472})(this.BX.UI = this.BX.UI || {}, BX, BX.Event);
473//# sourceMappingURL=tooltip.bundle.js.map

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.