PageSourceSearch

https://igtec.ru/bitrix/js/main/rating_like.js

js igtec.ru collected 2026-10-08 09:23:02 UTC 32,747 bytes, 1,408 lines download raw bytes

1if (!BXRL)
2{
3	var BXRL = {};
4	var BXRLW = null;
5	var lastVoteRepo = {};
6	var lastReactionRepo = {};
7	var BXRLParams = {
8		pathToUserProfile: null
9	};
10}
11
12RatingLike = function(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax)
13{
14	var key = entityTypeId+'_'+entityId;
15
16	this.enabled = true;
17	this.likeId = likeId;
18	this.entityTypeId = entityTypeId;
19	this.entityId = entityId;
20	this.available = (available == 'Y');
21	this.userId = userId;
22	this.localize = localize;
23	this.template = template;
24	this.pathToUserProfile = pathToUserProfile;
25	this.pathToAjax = (
26		BX.type.isNotEmptyString(pathToAjax)
27			? pathToAjax
28			: '/bitrix/components/bitrix/rating.vote/vote.ajax.php'
29	);
30
31	this.box = BX('bx-ilike-button-'+likeId);
32	if (this.box === null)
33	{
34		this.enabled = false;
35		return false;
36	}
37
38	this.button = BX.findChild(this.box, { className: 'bx-ilike-left-wrap' }, true, false);
39	this.buttonText = BX.findChild(this.button, { className: 'bx-ilike-text' }, true, false);
40	this.count = BX.findChild(this.box,  { tagName: 'span', className: 'bx-ilike-right-wrap' }, true, false);
41	if (!this.count)
42	{
43		this.count = BX('bx-ilike-count-' + likeId);
44	}
45	this.countText = BX.findChild(this.count, { className: 'bx-ilike-right' }, true, false);
46	this.topPanelContainer = BX('feed-post-emoji-top-panel-container-' + likeId);
47	this.topPanel = BX('feed-post-emoji-top-panel-' + likeId);
48	this.topUsersText = BX('bx-ilike-top-users-' + likeId);
49	this.topUsersDataNode = BX('bx-ilike-top-users-data-' + likeId);
50	this.userReactionNode = BX('bx-ilike-user-reaction-' + likeId);
51	this.reactionsNode = BX('feed-post-emoji-icons-' + likeId);
52	this.popup = null;
53	this.popupId = null;
54	this.popupTimeoutIdShow = null;
55	this.popupTimeoutIdList = null;
56	this.popupContent = BX.findChild(BX('bx-ilike-popup-cont-' + likeId), {tagName:'span', className:'bx-ilike-popup'}, true, false);
57	this.popupContentPage = 1;
58	this.popupTimeout = false;
59	this.likeTimeout = false;
60	this.mouseOverHandler = null;
61	this.version = (BXRL.render && this.topPanel ? 2 : 1);
62	this.mouseInShowPopupNode = {};
63	this.listXHR = null;
64
65	if (typeof lastVoteRepo[key] != 'undefined')
66	{
67		this.lastVote = lastVoteRepo[key];
68		var ratingNode = (template == 'standart' ? this.button: this.count);
69		if (this.lastVote == 'plus')
70		{
71			BX.addClass(ratingNode, 'bx-you-like');
72		}
73		else
74		{
75			BX.removeClass(ratingNode, 'bx-you-like');
76		}
77	}
78	else
79	{
80		this.lastVote = BX.hasClass(template == 'standart'? this.button: this.count, 'bx-you-like')? 'plus': 'cancel';
81		lastVoteRepo[key] = this.lastVote;
82	}
83
84	if (typeof lastReactionRepo[key] != 'undefined')
85	{
86		this.lastReaction = lastReactionRepo[key];
87		this.count.setAttribute('data-myreaction', this.lastReaction);
88	}
89	else
90	{
91		var lastReaction = this.count.getAttribute('data-myreaction');
92		this.lastReaction = (BX.type.isNotEmptyString(lastReaction) ? lastReaction : 'like');
93		lastReactionRepo[key] = this.lastReaction;
94	}
95
96	if (
97		this.topPanelContainer
98		&& typeof BXRL.manager != 'undefined'
99	)
100	{
101		BXRL.manager.addEntity(key, this);
102	}
103};
104
105RatingLike.Draw = function(likeId, params)
106{
107	var i = likeId;
108
109	var element = BXRL[i];
110	element.countText.innerHTML = parseInt(params.TOTAL_POSITIVE_VOTES);
111
112	if (
113		typeof params.TYPE != 'undefined'
114		&& typeof params.USER_ID != 'undefined'
115		&& parseInt(params.USER_ID) > 0
116		&& typeof params.USER_DATA != 'undefined'
117		&& typeof params.USER_DATA.WEIGHT != 'undefined'
118	)
119	{
120		var userWeight = parseFloat(params.USER_DATA.WEIGHT);
121
122		var usersData = (
123			BXRL[i].topUsersDataNode
124				? JSON.parse(BXRL[i].topUsersDataNode.getAttribute('data-users'))
125				: false
126		);
127
128		if (
129			params.TYPE != 'CHANGE'
130			&& BX.type.isPlainObject(usersData)
131		)
132		{
133			var recalcNeeded = (usersData.TOP.length < 2);
134
135			for(var k in usersData.TOP)
136			{
137				if (recalcNeeded)
138				{
139					break;
140				}
141
142				if (!usersData.TOP.hasOwnProperty(k))
143				{
144					continue;
145				}
146
147				if (
148					(
149						params.TYPE == 'ADD'
150						&& userWeight > usersData.TOP[k].WEIGHT
151					)
152					|| (
153						params.TYPE == 'CANCEL'
154						&& params.USER_ID == usersData.TOP[k].ID
155					)
156				)
157				{
158					recalcNeeded = true;
159				}
160			}
161
162			if (recalcNeeded)
163			{
164				if (
165					params.TYPE == 'ADD'
166					&& params.USER_ID != BX.message('USER_ID')
167				)
168				{
169					if (!usersData.TOP.find(function(a) {
170						return a.ID == params.USER_ID
171					}))
172					{
173						usersData.TOP.push({
174							ID: parseInt(params.USER_ID),
175							NAME_FORMATTED: params.USER_DATA.NAME_FORMATTED,
176							WEIGHT: parseFloat(params.USER_DATA.WEIGHT)
177						});
178					}
179				}
180				else if (params.TYPE == 'CANCEL')
181				{
182					usersData.TOP = usersData.TOP.filter(function(a) {
183						return a.ID != params.USER_ID
184					});
185				}
186
187				usersData.TOP.sort(function(a, b) {
188					if (a.WEIGHT == b.WEIGHT) { return 0; } return (a.WEIGHT > b.WEIGHT) ? -1 : 1;
189				});
190
191				if (
192					usersData.TOP.length > 2
193					&& params.TYPE == 'ADD'
194				)
195				{
196					usersData.TOP.pop();
197					usersData.MORE++;
198				}
199			}
200			else
201			{
202				if (params.TYPE == 'ADD')
203				{
204					usersData.MORE = (
205						typeof usersData.MORE != 'undefined'
206							? parseInt(usersData.MORE) + 1
207							: 1
208					);
209				}
210				else if (params.TYPE == 'CANCEL')
211				{
212					usersData.MORE = (
213						typeof usersData.MORE != 'undefined'
214						&& parseInt(usersData.MORE) > 0
215							? parseInt(usersData.MORE) - 1
216							: 0
217					);
218				}
219			}
220
221			BXRL[i].topUsersDataNode.setAttribute('data-users', JSON.stringify(usersData));
222
223			if (BXRL[i].topUsersText)
224			{
225				BXRL[i].topUsersText.innerHTML = BXRL.render.getTopUsersText({
226					you: (
227						params.USER_ID == BX.message('USER_ID')
228							? params.TYPE != 'CANCEL'
229							: BX.hasClass(BXRL[i].count, 'bx-you-like')
230					),
231					top: usersData.TOP,
232					more: usersData.MORE
233				});
234			}
235		}
236
237		if (
238			BX.type.isNotEmptyString(params.REACTION)
239			&& BX.type.isNotEmptyString(params.REACTION_OLD)
240			&& params.TYPE == 'CHANGE'
241		)
242		{
243			BXRL.render.setReaction({
244				likeId: i,
245				rating: BXRL[i],
246				action: 'change',
247				userReaction: params.REACTION,
248				userReactionOld: params.REACTION_OLD,
249				totalCount: params.TOTAL_POSITIVE_VOTES,
250				userId: params.USER_ID
251			});
252		}
253		else if (
254			BX.type.isNotEmptyString(params.REACTION)
255			&& BX.util.in_array(params.TYPE, ['ADD', 'CANCEL'])
256		)
257		{
258			BXRL.render.setReaction({
259				likeId: i,
260				rating: BXRL[i],
261				userReaction: params.REACTION,
262				action: (params.TYPE == 'ADD' ? 'add' : 'cancel'),
263				totalCount: params.TOTAL_POSITIVE_VOTES,
264				userId: params.USER_ID
265			});
266		}
267	}
268
269	if (BXRL[i].topPanel)
270	{
271		BXRL[i].topPanel.setAttribute('data-popup', 'N');
272	}
273
274	if (!BXRL[i].userReactionNode)
275	{
276		element.count.insertBefore(
277			BX.create("span", { props : { className : "bx-ilike-plus-one" }, style: {width: (element.countText.clientWidth-8)+'px', height: (element.countText.clientHeight-8)+'px'}, html: (params.TYPE == 'ADD'? '+1': '-1')})
278			, element.count.firstChild);
279	}
280
281	if (element.popup)
282	{
283		element.popup.close();
284		element.popupContentPage = 1;
285	}
286};
287
288RatingLike.LiveUpdate = function(params)
289{
290	if (params.USER_ID == BX.message('USER_ID'))
291	{
292		return false;
293	}
294
295	for(var i in BXRL)
296	{
297		if (!BXRL.hasOwnProperty(i))
298		{
299			continue;
300		}
301
302		if (
303			BXRL[i].entityTypeId == params.ENTITY_TYPE_ID
304			&& BXRL[i].entityId == params.ENTITY_ID
305		)
306		{
307			RatingLike.Draw(i, params);
308		}
309	}
310
311	if (typeof BXRL.manager != 'undefined')
312	{
313		BXRL.manager.live(params);
314	}
315};
316
317RatingLike.Set = function(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax, mobile)
318{
319	mobile = !!mobile;
320
321	if (template === undefined)
322		template = 'standart';
323
324	if (BXRLParams.pathToUserProfile)
325	{
326		pathToUserProfile = BXRLParams.pathToUserProfile;
327	}
328
329	if (!BXRL[likeId] || BXRL[likeId].tryToSet <= 5)
330	{
331		var tryToSend = BXRL[likeId] && BXRL[likeId].tryToSet? BXRL[likeId].tryToSet: 1;
332		BXRL[likeId] = new RatingLike(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax);
333		if (BXRL[likeId].enabled)
334		{
335			RatingLike.Init(likeId, {
336				mobile: mobile
337			});
338		}
339		else
340		{
341			setTimeout(function(){
342				BXRL[likeId].tryToSet = tryToSend+1;
343				RatingLike.Set(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax, mobile);
344			}, 500);
345		}
346	}
347};
348
349RatingLike.ClickVote = function(likeId, userReaction, forceAdd)
350{
351	var
352		cont = null,
353		likeNode = null,
354		likeThumbNode = null;
355
356	if (typeof userReaction == 'undefined')
357	{
358		userReaction = 'like';
359	}
360
361	if (
362		BXRL[likeId].version == 2
363		&& BXRL[likeId].userReactionNode
364	)
365	{
366		BXRL.render.hideReactionsPopup({
367			likeId: likeId
368		});
369		BXRL.render.blockReactionsPopup();
370		BX.unbind(document, 'mousemove', BXRL.render.reactionsPopupMouseOutHandler);
371	}
372
373	clearTimeout(BXRL[likeId].likeTimeout);
374
375	var active = (
376		BX.hasClass(
377			(BXRL[likeId].template == 'standart' ? this : BXRL[likeId].count),
378			'bx-you-like'
379		)
380	);
381
382	forceAdd = !!forceAdd;
383	var
384		change = false,
385		userReactionOld = false;
386
387	if (active && !forceAdd)
388	{
389		userReaction = (
390			BXRL[likeId].version == 2
391				? BXRL.render.getUserReaction({
392					userReactionNode: BXRL[likeId].userReactionNode
393				})
394				: false
395		);
396
397		BXRL[likeId].buttonText.innerHTML = BXRL[likeId].localize['LIKE_N'];
398		BXRL[likeId].countText.innerHTML = parseInt(BXRL[likeId].countText.innerHTML)-1;
399		BX.removeClass(BXRL[likeId].template == 'standart'? this: BXRL[likeId].count, 'bx-you-like');
400		BX.removeClass(BXRL[likeId].button, 'bx-you-like-button');
401
402		BXRL[likeId].likeTimeout = setTimeout(function() {
403			if (BXRL[likeId].lastVote != 'cancel')
404			{
405				RatingLike.Vote(likeId, 'cancel', userReaction);
406			}
407		}, 1000);
408	}
409	else if (active && forceAdd)
410	{
411		change = true;
412		userReactionOld = (
413			BXRL[likeId].version == 2
414				? BXRL.render.getUserReaction({
415					userReactionNode: BXRL[likeId].userReactionNode
416				})
417				: false
418		);
419
420		if (userReaction != userReactionOld)
421		{
422			BXRL[likeId].likeTimeout = setTimeout(function(){
423				RatingLike.Vote(likeId, 'change', userReaction, userReactionOld);
424			}, 1000);
425		}
426	}
427	else if (!active)
428	{
429		BXRL[likeId].buttonText.innerHTML = BXRL[likeId].localize['LIKE_Y'];
430		BXRL[likeId].countText.innerHTML = parseInt(BXRL[likeId].countText.innerHTML) + 1;
431		BX.addClass(BXRL[likeId].template == 'standart'? this: BXRL[likeId].count, 'bx-you-like');
432		BX.addClass(BXRL[likeId].button, 'bx-you-like-button');
433
434		BXRL[likeId].likeTimeout = setTimeout(function(){
435			if (BXRL[likeId].lastVote != 'plus')
436			{
437				RatingLike.Vote(likeId, 'plus', userReaction);
438			}
439			else if (userReaction != BXRL[likeId].lastReaction) // http://jabber.bx/view.php?id=99339
440			{
441				RatingLike.Vote(likeId, 'change', userReaction, BXRL[likeId].lastReaction);
442			}
443		}, 1000);
444	}
445
446	if (BXRL[likeId].version == 2)
447	{
448		if (change)
449		{
450			BXRL.render.setReaction({
451				likeId: likeId,
452				rating: BXRL[likeId],
453				action: 'change',
454				userReaction: userReaction,
455				userReactionOld: userReactionOld,
456				totalCount: parseInt(BXRL[likeId].countText.innerHTML)
457			});
458		}
459		else
460		{
461			BXRL.render.setReaction({
462				likeId: likeId,
463				rating: BXRL[likeId],
464				action: (active ? 'cancel' : 'add'),
465				userReaction: userReaction,
466				totalCount: parseInt(BXRL[likeId].countText.innerHTML)
467			});
468		}
469	}
470
471	if (
472		!change
473		&& BXRL[likeId].version == 2
474	)
475	{
476		var dataUsers = (
477			BXRL[likeId].topUsersDataNode
478				? JSON.parse(BXRL[likeId].topUsersDataNode.getAttribute('data-users'))
479				: false
480		);
481
482		if (dataUsers)
483		{
484			BXRL[likeId].topUsersText.innerHTML = BXRL.render.getTopUsersText({
485				you: !active,
486				top: dataUsers.TOP,
487				more: dataUsers.MORE
488			});
489		}
490	}
491
492	if (
493		BXRL[likeId].template == 'light'
494		&& !BXRL[likeId].userReactionNode
495	)
496	{
497		cont = BXRL[likeId].box;
498		likeNode = cont.cloneNode(true);
499		likeNode.id = 'like_anim'; // to not dublicate original id
500
501		var type = 'normal';
502		if (BX.findParent(cont, { 'className': 'feed-com-informers-bottom' }))
503		{
504			type = 'comment';
505		}
506		else if (BX.findParent(cont, { 'className': 'feed-post-informers' }))
507		{
508			type = 'post';
509		}
510
511		BX.removeClass(likeNode, 'bx-ilike-button-hover');
512		BX.addClass(likeNode, 'bx-like-anim');
513
514		BX.adjust(cont.parentNode, { style: { position: 'relative' } });
515
516		BX.adjust(likeNode, {
517			style: {
518				position: 'absolute',
519				whiteSpace: 'nowrap',
520				top: (type == 'post' ? '1px' : (type == 'comment' ? '0' : ''))
521			}
522		});
523
524		BX.adjust(cont, { style: { visibility: 'hidden' } });
525		BX.prepend(likeNode, cont.parentNode);
526
527		new BX.easing({
528			duration: 140,
529			start: { scale: 100 },
530			finish: { scale: (type == 'comment' ? 110 : 115) },
531			transition : BX.easing.transitions.quad,
532			step: function(state) {
533				likeNode.style.transform = "scale(" + state.scale / 100 + ")";
534			},
535			complete: function() {
536				likeThumbNode = BX.create('SPAN', {
537					props: {
538						className: (active ? 'bx-ilike-icon' : 'bx-ilike-icon bx-ilike-icon-orange')
539					}
540				});
541
542				BX.adjust(likeThumbNode, {
543					style: {
544						position: 'absolute',
545						whiteSpace: 'nowrap'
546					}
547				});
548
549				BX.prepend(likeThumbNode, cont.parentNode);
550
551				new BX.easing({
552					duration: 140,
553					start: { scale: (type == 'comment' ? 110 : 115) },
554					finish: { scale: 100 },
555					transition : BX.easing.transitions.quad,
556					step: function(state) {
557						likeNode.style.transform = "scale(" + state.scale / 100 + ")";
558					},
559					complete: function() {
560					}
561				}).animate();
562
563				var propsStart = { opacity: 100, scale: (type == 'comment' ? 110 : 115), top: 0 };
564				var propsFinish = { opacity: 0, scale: 200, top: (type == 'comment' ? -3 : -2) };
565
566				if (type != 'comment')
567				{
568					propsStart.left = -5;
569					propsFinish.left = -13;
570				}
571
572				new BX.easing({
573					duration: 200,
574					start: propsStart,
575					finish: propsFinish,
576					transition : BX.easing.transitions.linear,
577					step: function(state) {
578						likeThumbNode.style.transform = "scale(" + state.scale / 100 + ")";
579						likeThumbNode.style.opacity = state.opacity / 100;
580						if (type != 'comment')
581						{
582							likeThumbNode.style.left = state.left + 'px';
583						}
584						likeThumbNode.style.top = state.top + 'px';
585					},
586					complete: function() {
587						likeNode.parentNode.removeChild(likeNode);
588						likeThumbNode.parentNode.removeChild(likeThumbNode);
589
590						BX.adjust(cont.parentNode, { style: { position: 'static' } });
591						BX.adjust(cont, { style: { visibility: 'visible' } });
592					}
593				}).animate();
594
595			}
596		}).animate();
597	}
598
599	BX.removeClass(this.box, 'bx-ilike-button-hover');
600};
601
602RatingLike.Init = function(likeId, params)
603{
604	if (typeof params == 'undefined')
605	{
606		params = {};
607	}
608
609	if (typeof BXRL.manager != 'undefined')
610	{
611		BXRL.manager.init(params);
612	}
613
614	// like/unlike button
615	if (BXRL[likeId].available)
616	{
617		var eventNode = (
618			BXRL[likeId].template == 'standart'
619				? BXRL[likeId].button
620				: BXRL[likeId].buttonText
621		);
622
623		if (
624			BXRL[likeId].version >= 2
625			&& BXRL.manager.mobile
626		)
627		{
628			BX.bind(
629				eventNode,
630				'touchstart',
631				BX.delegate(function(e) {
632					BXRL.manager.startScrollTop = (
633						(
634							document.documentElement
635							&& document.documentElement.scrollTop
636						)
637						|| document.body.scrollTop
638					);
639				})
640			);
641		}
642
643		var eventName = (
644			typeof BXRL.manager != 'undefined'
645			&& BXRL.manager.mobile
646				? 'touchend'
647				: 'click'
648		);
649
650		BX.bind(
651			eventNode,
652			eventName,
653			BX.delegate(function(e) {
654
655				if (
656					BXRL[likeId].version >= 2
657					&& BXRL.manager.mobile
658					&& BXRL.render.blockTouchEndByScroll
659				)
660				{
661					BXRL.render.blockTouchEndByScroll = false;
662					return;
663				}
664
665				if (
666					BXRL[likeId].version < 2
667					|| !BXRL.manager.mobile
668					|| !BXRL.render.reactionsPopupLikeId
669				)
670				{
671					if (
672						BXRL[likeId].version >= 2
673						&& BXRL.manager.mobile
674					)
675					{
676						var currentScrollTop = (
677							(
678								document.documentElement
679								&& document.documentElement.scrollTop
680							)
681							|| document.body.scrollTop
682						);
683
684						if (Math.abs(currentScrollTop - BXRL.manager.startScrollTop) > 2)
685						{
686							return;
687						}
688					}
689
690					RatingLike.ClickVote(likeId);
691				}
692
693				if (BXRL[likeId].version == 2)
694				{
695					BXRL.render.afterClick({
696						likeId: likeId
697					});
698				}
699
700				e.preventDefault();
701			}, this)
702		);
703
704		if (
705			typeof BXRL.manager == 'undefined'
706			|| !BXRL.manager.mobile
707		)
708		{
709			// Hover/unHover like-button
710			BX.bind(BXRL[likeId].box, 'mouseover', function() {BX.addClass(this, 'bx-ilike-button-hover')});
711			BX.bind(BXRL[likeId].box, 'mouseout', function() {BX.removeClass(this, 'bx-ilike-button-hover')});
712		}
713		else
714		{
715			BXRL[likeId].pathToAjax = BX.message('SITE_DIR') + 'mobile/ajax.php?mobile_action=like';
716			BX.bind(BXRL[likeId].topPanel, 'click', function(e) {
717				BXRL.render.openMobileReactionsPage({
718					entityTypeId: BXRL[likeId].entityTypeId,
719					entityId: BXRL[likeId].entityId
720				});
721				e.stopPropagation();
722			});
723		}
724	}
725	else if (BXRL[likeId].buttonText != undefined)
726	{
727		BXRL[likeId].buttonText.innerHTML = BXRL[likeId].localize['LIKE_D'];
728	}
729	// get like-user-list
730
731	var clickShowPopupNode = (
732		BXRL[likeId].topUsersText
733			? BXRL[likeId].topUsersText
734			: BXRL[likeId].count
735	);
736
737	if (
738		typeof BXRL.manager == 'undefined'
739		|| !BXRL.manager.mobile
740	)
741	{
742		BX.bind(clickShowPopupNode, 'mouseenter', function(e)
743		{
744			RatingLike.onResultMouseEnter({
745				likeId: likeId,
746				event: e,
747				nodeId: e.currentTarget.id
748			});
749		});
750
751		BX.bind(clickShowPopupNode, 'mouseleave', BX.proxy(function()
752		{
753			RatingLike.onResultMouseLeave({
754				likeId: likeId
755			});
756		}, { likeId: likeId }));
757	}
758
759
760	if (
761		typeof BXRL.manager == 'undefined'
762		|| !BXRL.manager.mobile
763	)
764	{
765		BX.bind(clickShowPopupNode, 'click' , function(e)
766		{
767			RatingLike.onResultClick({
768				likeId: likeId,
769				event: e,
770				nodeId: e.currentTarget.id
771			});
772		});
773	}
774
775	if (
776		BXRL[likeId].version == 2
777		&& BXRL[likeId].available
778		&& BXRL[likeId].userReactionNode
779	)
780	{
781		BXRL.render.bindReactionsPopup({
782			likeId: likeId
783		});
784	}
785};
786
787RatingLike.onResultClick = function(params)
788{
789	var
790		likeId = (BX.type.isNotEmptyString(params.likeId) ? params.likeId : false),
791		clickEvent = (typeof params.event != 'undefined' ? params.event : null),
792		reaction = (BX.type.isNotEmptyString(params.reaction) ? params.reaction : '');
793
794	if (BXRL[likeId].resultPopupAnimation)
795	{
796		return;
797	}
798
799	if (
800		BXRL[likeId].popup
801		&& BXRL[likeId].popup.isShown()
802	)
803	{
804		BXRL[likeId].popup.close();
805	}
806	else
807	{
808		clearTimeout(BXRL[likeId].popupTimeoutIdList);
809		clearTimeout(BXRL[likeId].popupTimeoutIdShow);
810
811		if (
812			BXRL[likeId].popupContentPage == 1
813			&& (
814				clickEvent.currentTarget.getAttribute('data-popup') != 'Y'
815				|| BXRL[likeId].popupCurrentReaction != reaction
816			)
817		)
818		{
819			RatingLike.List(likeId, 1, reaction, true);
820		}
821		RatingLike.OpenWindow(
822			likeId,
823			(clickEvent.currentTarget == BXRL[likeId].count ? null : clickEvent),
824			clickEvent.currentTarget,
825			clickEvent.currentTarget.id
826		);
827	}
828};
829
830RatingLike.onResultMouseEnter = function(params)
831{
832	var
833		likeId = (BX.type.isNotEmptyString(params.likeId) ? params.likeId : false),
834		mouseEnterEvent = (typeof params.event != 'undefined' ? params.event : null),
835		reaction = (BX.type.isNotEmptyString(params.reaction) ? params.reaction : ''),
836		nodeId = (mouseEnterEvent && BX.type.isNotEmptyString(mouseEnterEvent.currentTarget.id) ? mouseEnterEvent.currentTarget.id : '');
837
838	BXRL[likeId].mouseInShowPopupNode[reaction] = true;
839
840	clearTimeout(BXRL[likeId].popupTimeoutIdList);
841	clearTimeout(BXRL[likeId].popupTimeoutIdShow);
842
843	BXRL[likeId].popupTimeoutIdList = setTimeout(BX.proxy(function() {
844
845		if (BXRLW == this.likeId)
846		{
847			return false;
848		}
849
850		if (
851			BXRL[this.likeId].popupContentPage == 1
852			&& this.target.getAttribute('data-popup') != 'Y'
853		)
854		{
855			RatingLike.List(this.likeId, 1, this.reaction, true);
856		}
857
858		BXRL[this.likeId].popupTimeoutIdShow = setTimeout(BX.proxy(function() {
859
860			BXRL[this._likeId].resultPopupAnimation = true;
861
862			var _likeId = this._likeId;
863			setTimeout(function() {
864				BXRL[_likeId].resultPopupAnimation = false;
865			}, 500);
866
867			if (BXRL[this._likeId].mouseInShowPopupNode[this._reaction])
868			{
869				RatingLike.OpenWindow(
870					this._likeId,
871					null,
872					this._target,
873					this._nodeId
874				);
875			}
876		}, {
877			_likeId: this.likeId,
878			_reaction: this.reaction,
879			_target: this.target,
880			_nodeId: this.nodeId
881		}), 100);
882	}, {
883		likeId: likeId,
884		target: mouseEnterEvent.currentTarget,
885		reaction: reaction,
886		nodeId: nodeId
887	}), 300);
888};
889
890RatingLike.onResultMouseLeave = function(params) {
891
892	var
893		likeId = (BX.type.isNotEmptyString(params.likeId) ? params.likeId : false),
894		reaction = (BX.type.isNotEmptyString(params.reaction) ? params.reaction : '');
895
896	BXRL[likeId].mouseInShowPopupNode[reaction] = false;
897	BXRL[likeId].resultPopupAnimation = false;
898};
899
900RatingLike.OpenWindow = function(likeId, clickEvent, target, targetId)
901{
902	if (parseInt(BXRL[likeId].countText.innerHTML) == 0)
903	{
904		return;
905	}
906
907	var bindNode = (
908		BXRL[likeId].template == 'standart'
909			? BXRL[likeId].count
910			: (
911				BXRL[likeId].version == 2
912					? (
913						BX(target)
914						? BX(target)
915						: (BX.type.isNotEmptyString(targetId) && BX(targetId) ? BX(targetId): null)
916					)
917					: BXRL[likeId].box
918			)
919	);
920
921	if (!BX(bindNode))
922	{
923		return;
924	}
925
926	if (BXRL[likeId].popup == null)
927	{
928		var globalZIndex = RatingLike.getGlobalIndex(BX(bindNode));
929		BXRL[likeId].popup = new BX.PopupWindow('ilike-popup-'+likeId, bindNode, {
930			lightShadow : true,
931			offsetTop: 0,
932			offsetLeft: (
933				typeof clickEvent != 'undefined'
934				&& clickEvent != null
935				&& typeof clickEvent.offsetX != 'undefined'
936					? (clickEvent.offsetX - 100)
937					: (BXRL[likeId].version == 2 ? -30 : 5)
938			),
939			autoHide: true,
940			closeByEsc: true,
941			zIndexAbsolute: (globalZIndex > 1000 ? globalZIndex + 1 : 1000),
942			bindOptions: { position: "top" },
943			animation: "fading-slide",
944			events : {
945				onPopupClose : function() { BXRLW = null; },
946				onPopupDestroy : function() {  }
947			},
948			content : BX('bx-ilike-popup-cont-'+likeId),
949			className: (BXRL[likeId].topPanel ? 'bx-ilike-wrap-block-react-wrap' : '') + (typeof BXRL.manager != 'undefined' && BXRL.manager.mobile ? ' bx-ilike-mobile-wrap' : '')
950		});
951
952		if (
953			!BXRL[likeId].topPanel
954			&& (
955				typeof BXRL.manager == 'undefined'
956				|| !BXRL.manager.mobile
957			)
958		)
959		{
960			BXRL[likeId].popup.setAngle({});
961
962			BX.bind(BX('ilike-popup-'+likeId), 'mouseout' , function() {
963				clearTimeout(BXRL[likeId].popupTimeout);
964				BXRL[likeId].popupTimeout = setTimeout(function(){
965					BXRL[likeId].popup.close();
966				}, 1000);
967			});
968
969			BX.bind(BX('ilike-popup-'+likeId), 'mouseover' , function() {
970				clearTimeout(BXRL[likeId].popupTimeout);
971			});
972		}
973	}
974	else
975	{
976		if (
977			typeof clickEvent != 'undefined'
978			&& clickEvent != null
979			&& typeof clickEvent.offsetX != 'undefined'
980		)
981		{
982			BXRL[likeId].popup.offsetLeft = (clickEvent.offsetX - 100);
983		}
984
985		if (BX(bindNode))
986		{
987			BXRL[likeId].popup.setBindElement(bindNode);
988		}
989	}
990
991
992	if (
993		BXRLW != null
994		&& BXRLW != likeId
995	)
996	{
997		BXRL[BXRLW].popup.close();
998	}
999
1000	BXRLW = likeId;
1001
1002	BXRL[likeId].popup.show();
1003
1004	if (
1005		typeof BX.SidePanel != 'undefined'
1006		&& BX.SidePanel.Instance.getTopSlider()
1007	)
1008	{
1009		BX.addCustomEvent(
1010			BX.SidePanel.Instance.getTopSlider().getWindow(),
1011			"SidePanel.Slider:onClose",
1012			function removeOnCloseHandler()
1013			{
1014				BX.removeCustomEvent(BX.SidePanel.Instance.getTopSlider().getWindow(), "SidePanel.Slider:onClose", removeOnCloseHandler);
1015				if (typeof BXRL[BXRLW] != 'undefined')
1016				{
1017					BXRL[BXRLW].popup.close();
1018				}
1019			}
1020		);
1021	}
1022
1023	RatingLike.AdjustWindow(likeId);
1024};
1025
1026RatingLike.getGlobalIndex = function(element)
1027{
1028	var index = 0,
1029		propertyValue = "";
1030
1031	do
1032	{
1033		propertyValue = BX.style(element, "z-index");
1034		if (propertyValue !== "auto")
1035		{
1036			index = BX.type.stringToInt(propertyValue);
1037		}
1038		element = element.offsetParent;
1039	}
1040	while (
1041		element && element.tagName !== "BODY"
1042	);
1043
1044	return index;
1045};
1046
1047RatingLike.Vote = function(likeId, voteAction, voteReaction, voteReactionOld)
1048{
1049	if (!BX.type.isNotEmptyString(voteReaction))
1050	{
1051		voteReaction = 'like';
1052	}
1053
1054	var BMAjaxWrapper = null;
1055
1056	if (
1057		typeof BXRL.manager != 'undefined'
1058		&& BXRL.manager.mobile
1059	)
1060	{
1061		BMAjaxWrapper = new MobileAjaxWrapper;
1062	}
1063
1064	var
1065		f = (BMAjaxWrapper ? BX.proxy(BMAjaxWrapper.Wrap, BMAjaxWrapper) : BX.aja
1065x),
1066		callbackSuccessName = (BMAjaxWrapper ? 'callback' : 'onsuccess'),
1067		callbackFailureName = (BMAjaxWrapper ? 'callback_failure' : 'onfailure');
1068
1069	var actionUrl = BXRL[likeId].pathToAjax;
1070	actionUrl = BX.util.add_url_param(actionUrl, {
1071		b24statAction: 'addLike'
1072	});
1073
1074	if (
1075		BXRL[likeId].version >= 2
1076		&& BXRL.manager.mobile
1077	)
1078	{
1079		actionUrl = BX.util.add_url_param(actionUrl, {
1080			b24statContext: 'mobile'
1081		});
1082	}
1083
1084	var ajaxProperties = {
1085		url: actionUrl,
1086		method: 'POST',
1087		dataType: 'json',
1088		type: 'json',
1089		data: {
1090			RATING_VOTE : 'Y',
1091			RATING_VOTE_TYPE_ID : BXRL[likeId].entityTypeId,
1092			RATING_VOTE_ENTITY_ID : BXRL[likeId].entityId,
1093			RATING_VOTE_ACTION : voteAction,
1094			RATING_VOTE_REACTION : voteReaction,
1095			sessid: BX.bitrix_sessid()
1096		}
1097	};
1098
1099	ajaxProperties[callbackSuccessName] = function(data) {
1100		BXRL[likeId].lastVote = data.action;
1101		BXRL[likeId].lastReaction = voteReaction;
1102
1103		lastVoteRepo[BXRL[likeId].entityTypeId + '_' + BXRL[likeId].entityId] = data.action;
1104		lastReactionRepo[BXRL[likeId].entityTypeId + '_' + BXRL[likeId].entityId] = data.voteReaction;
1105
1106		BXRL[likeId].countText.innerHTML = data.items_all;
1107		BXRL[likeId].popupContentPage = 1;
1108
1109		BXRL[likeId].popupContent.innerHTML = '';
1110		spanTag0 = document.createElement("span");
1111		spanTag0.className = "bx-ilike-wait";
1112		BXRL[likeId].popupContent.appendChild(spanTag0);
1113
1114		if (BXRL[likeId].topPanel)
1115		{
1116			BXRL[likeId].topPanel.setAttribute('data-popup', 'N');
1117		}
1118
1119		RatingLike.AdjustWindow(likeId);
1120
1121		if(
1122			BX('ilike-popup-'+likeId)
1123			&& BX('ilike-popup-'+likeId).style.display == "block"
1124		)
1125		{
1126			RatingLike.List(likeId, null, '', true);
1127		}
1128
1129		if (
1130			BXRL[likeId].version >= 2
1131			&& BXRL.manager.mobile
1132		)
1133		{
1134			BXMobileApp.onCustomEvent('onRatingLike', {
1135				action: data.action,
1136				ratingId: likeId,
1137				entityTypeId : BXRL[likeId].entityTypeId,
1138				entityId: BXRL[likeId].entityId,
1139				voteAction: voteAction,
1140				voteReaction: voteReaction,
1141				voteReactionOld: voteReactionOld,
1142				userId: BX.message('USER_ID'),
1143				userData: (typeof data.user_data != 'undefined' ? data.user_data : null),
1144				itemsAll: data.items_all
1145			}, true);
1146		}
1147	};
1148
1149	ajaxProperties[callbackFailureName] = function(data) {
1150
1151		var dataUsers = ((BXRL[likeId].topUsersDataNode)
1152				? JSON.parse(BXRL[likeId].topUsersDataNode.getAttribute('data-users'))
1153				: false
1154		);
1155
1156		if (BXRL[likeId].version == 2)
1157		{
1158			if (voteAction == 'change')
1159			{
1160				BXRL.render.setReaction({
1161					likeId: likeId,
1162					rating: BXRL[likeId],
1163					action: voteAction,
1164					userReaction: voteReaction,
1165					userReactionOld: voteReactionOld,
1166					totalCount: parseInt(BXRL[likeId].countText.innerHTML)
1167				});
1168			}
1169			else
1170			{
1171				BXRL.render.setReaction({
1172					likeId: likeId,
1173					rating: BXRL[likeId],
1174					action: (voteAction == 'cancel' ? 'add' : 'cancel'),
1175					userReaction: voteReaction,
1176					totalCount: (
1177						voteAction == 'cancel'
1178							? parseInt(BXRL[likeId].countText.innerHTML) + 1
1179							: parseInt(BXRL[likeId].countText.innerHTML) - 1
1180					)
1181				});
1182			}
1183
1184			if (BXRL[likeId].buttonText)
1185			{
1186				if (voteAction == 'add')
1187				{
1188					BXRL[likeId].buttonText.innerHTML = BX.message('RATING_LIKE_EMOTION_LIKE_CALC');
1189				}
1190				else if (voteAction == 'change')
1191				{
1192					BXRL[likeId].buttonText.innerHTML = BX.message('RATING_LIKE_EMOTION_' + voteReactionOld.toUpperCase() + '_CALC');
1193				}
1194				else
1195				{
1196					BXRL[likeId].buttonText.innerHTML = BX.message('RATING_LIKE_EMOTION_' + voteReaction.toUpperCase() + '_CALC');
1197				}
1198			}
1199		}
1200
1201		if (
1202			dataUsers
1203			&& voteAction != 'change'
1204			&& BXRL[likeId].version == 2
1205		)
1206		{
1207			BXRL[likeId].topUsersText.innerHTML = BXRL.render.getTopUsersText({
1208				you: (voteAction == 'cancel'), // negative
1209				top: dataUsers.TOP,
1210				more: dataUsers.MORE
1211			});
1212		}
1213	};
1214
1215	f(ajaxProperties);
1216
1217	return false;
1218};
1219
1220RatingLike.List = function(likeId, page, reaction, clear)
1221{
1222	if (parseInt(BXRL[likeId].countText.innerHTML) == 0)
1223	{
1224		return false;
1225	}
1226
1227	reaction = (BX.type.isNotEmptyString(reaction) ? reaction : '');
1228
1229	if (page == null)
1230	{
1231		page = (
1232			BXRL[likeId].version == 2
1233				? (typeof BXRL.render.popupPagesList[reaction] != 'undefined' ? BXRL.render.popupPagesList[reaction] : 1)
1234				: BXRL[likeId].popupContentPage
1235		);
1236	}
1237
1238	if (
1239		clear
1240		&& page == 1
1241		&& BXRL[likeId].version == 2
1242	)
1243	{
1244		BXRL.render.clearPopupContent({
1245			likeId: likeId
1246		});
1247	}
1248
1249	if (BXRL[likeId].listXHR)
1250	{
1251		BXRL[likeId].listXHR.abort();
1252	}
1253
1254	BXRL[likeId].listXHR = BX.ajax({
1255		url: BXRL[likeId].pathToAjax,
1256		method: 'POST',
1257		dataType: 'json',
1258		data: {
1259			RATING_VOTE_LIST : 'Y',
1260			RATING_VOTE_TYPE_ID : BXRL[likeId].entityTypeId,
1261			RATING_VOTE_ENTITY_ID : BXRL[likeId].entityId,
1262			RATING_VOTE_LIST_PAGE : page,
1263			RATING_VOTE_REACTION : (reaction == 'all' ? '' : reaction),
1264			PATH_TO_USER_PROFILE : BXRL[likeId].pathToUserProfile,
1265			sessid: BX.bitrix_sessid()
1266		},
1267		onsuccess: function(data)
1268		{
1269			if (!data)
1270			{
1271				return false;
1272			}
1273
1274			BXRL[likeId].countText.innerHTML = data.items_all;
1275
1276			if (parseInt(data.items_page) == 0)
1277			{
1278				return false;
1279			}
1280
1281			if (BXRL[likeId].version == 2)
1282			{
1283				BXRL.render.buildPopupContent({
1284					likeId: likeId,
1285					reaction: reaction,
1286					rating: BXRL[likeId],
1287					page: page,
1288					data: data,
1289					clear: clear
1290				});
1291				BXRL[likeId].topPanel.setAttribute('data-popup', 'Y');
1292			}
1293			else
1294			{
1295				if (page == 1)
1296				{
1297					BXRL[likeId].popupContent.innerHTML = '';
1298					spanTag0 = document.createElement("span");
1299					spanTag0.className = "bx-ilike-bottom_scroll";
1300					BXRL[likeId].popupContent.appendChild(spanTag0);
1301				}
1302				BXRL[likeId].popupContentPage += 1;
1303
1304				var avatarNode = null;
1305
1306				for (var i = 0; i < data.items.length; i++)
1307				{
1308					if (data.items[i]['PHOTO_SRC'].length > 0)
1309					{
1310						avatarNode = BX.create("IMG", {
1311							attrs: {src: data.items[i]['PHOTO_SRC']},
1312							props: {className: "bx-ilike-popup-avatar-img"}
1313						});
1314					}
1315					else
1316					{
1317						avatarNode = BX.create("IMG", {
1318							attrs: {src: '/bitrix/images/main/blank.gif'},
1319							props: {className: "bx-ilike-popup-avatar-img bx-ilike-popup-avatar-img-default"}
1320						});
1321					}
1322
1323					BXRL[likeId].popupContent.appendChild(
1324						BX.create("A", {
1325							attrs: {
1326								href: data.items[i]['URL'],
1327								target: '_blank'
1328							},
1329							props: {
1330								className: "bx-ilike-popup-img" + (!!data.items[i]['USER_TYPE'] ? " bx-ilike-popup-img-" + data.items[i]['USER_TYPE'] : "")
1331							},
1332							children: [
1333								BX.create("SPAN", {
1334									props: {
1335										className: "bx-ilike-popup-avatar-new"
1336									},
1337									children: [
1338										avatarNode,
1339										BX.create("SPAN", {
1340											props: {className: "bx-ilike-popup-avatar-status-icon"}
1341										})
1342									]
1343								}),
1344								BX.create("SPAN", {
1345									props: {
1346										className: "bx-ilike-popup-name-new"
1347									},
1348									html: data.items[i]['FULL_NAME']
1349								})
1350							]
1351						})
1352					);
1353				}
1354			}
1355
1356			RatingLike.AdjustWindow(likeId);
1357			RatingLike.PopupScroll(likeId);
1358		},
1359		onfailure: function(data) {}
1360	});
1361	return false;
1362};
1363
1364RatingLike.AdjustWindow = function(likeId)
1365{
1366	if (BXRL[likeId].popup != null)
1367	{
1368		BXRL[likeId].popup.bindOptions.forceBindPosition = true;
1369		BXRL[likeId].popup.adjustPosition();
1370		BXRL[likeId].popup.bindOptions.forceBindPosition = false;
1371	}
1372};
1373
1374RatingLike.PopupScroll = function(likeId)
1375{
1376	var contentContainerNodeList = BX.findChildren(BXRL[likeId].popupContent, { className: 'bx-ilike-popup-content' }, true); // reactions
1377	if (contentContainerNodeList.length <= 0)
1378	{
1379		contentContainerNodeList = [ BXRL[likeId].popupContent ];
1380	}
1381
1382	var contentContainerNode = null;
1383
1384	for (var i = 0; i < contentContainerNodeList.length; i++)
1385	{
1386		contentContainerNode = contentContainerNodeList[i];
1387
1388		BX.bind(contentContainerNode, 'scroll' , function() {
1389			if (this.scrollTop > (this.scrollHeight - this.offsetHeight) / 1.5)
1390			{
1391				RatingLike.List(likeId, null, (BXRL[likeId].version == 2 ? BXRL.render.popupCurrentReaction : false));
1392				BX.unbindAll(this);
1393			}
1394		});
1395	}
1396};
1397
1398RatingLike.setParams = function(params)
1399{
1400	if (typeof params != 'undefined')
1401	{
1402		if (typeof params.pathToUserProfile != 'undefined')
1403		{
1404			BXRLParams.pathToUserProfile = params.pathToUserProfile;
1405		}
1406	}
1407};
1408

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.