PageSourceSearch

https://booksrus.fr/local/templates/aspro_max/js/rating_likes.js

js booksrus.fr collected 2026-09-30 02:36:42 UTC 10,797 bytes, 356 lines download raw bytes

1if (!BXRL)
2{
3	var BXRL = {};
4	var BXRLW = null;
5}
6
7RatingLikes = function(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax)
8{
9	this.enabled = true;
10	this.likeId = likeId;
11	this.entityTypeId = entityTypeId;
12	this.entityId = entityId;
13	this.available = (available == 'Y');
14	this.userId = userId;
15	this.localize = localize;
16	this.template = template;
17	this.pathToUserProfile = pathToUserProfile;
18	this.pathToAjax = typeof(pathToAjax) == "string"? pathToAjax: '/bitrix/components/bitrix/rating.vote/vote.ajax.php';
19
20	this.box = BX('bx-ilike-button-'+likeId);
21	if (this.box === null)
22	{
23		this.enabled = false;
24		return false;
25	}
26
27	this.button = BX.findChild(this.box, {className:'bx-ilike-left-wrap'}, true, false);
28	this.wrapp = BX.findChild(this.box, {className:'all-wrapper'}, true, false);
29	this.buttonText = BX.findChild(this.button, {className:'bx-ilike-text'}, true, false);
30	this.count = BX.findChild(this.box,  {tagName:'span', className:'bx-ilike-right-wrap'}, true, false);
31	this.countText	= BX.findChild(this.count, {tagName:'span', className:'bx-ilike-right'}, true, false);
32	this.popup = null;
33	this.popupId = null;
34	this.popupOpenId = null;
35	this.popupTimeoutId = null;
36	this.popupContent = BX.findChild(BX('bx-ilike-popup-cont-'+likeId), {tagName:'span', className:'bx-ilike-popup'}, true, false);
37	this.popupContentPage = 1;
38	this.popupListProcess = false;
39	this.popupTimeout = false;
40	this.likeTimeout = false;
41
42	this.lastVote = BX.hasClass(template == 'standart'? this.button: this.count, 'bx-you-like')? 'plus': 'cancel';
43};
44
45RatingLikes.LiveUpdate = function(params)
46{
47	if (params.USER_ID == BX.message('USER_ID'))
48		return false;
49
50	for(var i in BXRL)
51	{
52		if (BXRL.hasOwnProperty(i))
53		{
54			if (BXRL[i].entityTypeId == params.ENTITY_TYPE_ID && BXRL[i].entityId == params.ENTITY_ID)
55			{
56				var element = BXRL[i];
57				element.countText.innerHTML = parseInt(params.TOTAL_POSITIVE_VOTES);
58				element.count.insertBefore(
59					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')})
60					, element.count.firstChild);
61
62				if (element.popup)
63				{
64					element.popup.close();
65					element.popupContentPage = 1;
66				}
67			}
68		}
69	}
70};
71
72RatingLikes.Set = function(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax)
73{
74	if (template === undefined)
75		template = 'standart';
76
77	if (!BXRL[likeId] || BXRL[likeId].tryToSet <= 5)
78	{
79		var tryToSend = BXRL[likeId] && BXRL[likeId].tryToSet? BXRL[likeId].tryToSet: 1;
80		BXRL[likeId] = new RatingLikes(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax);
81		if (BXRL[likeId].enabled)
82		{
83			RatingLikes.Init(likeId);
84		}
85		else
86		{
87			setTimeout(function(){
88				BXRL[likeId].tryToSet = tryToSend+1;
89				RatingLikes.Set(likeId, entityTypeId, entityId, available, userId, localize, template, pathToUserProfile, pathToAjax);
90			}, 500);
91		}
92	}
93};
94
95RatingLikes.Init = function(likeId)
96{
97	// like/unlike button
98	if (BXRL[likeId].available)
99	{
100
101		BX.bind(BXRL[likeId].template == 'standart'? BXRL[likeId].button: BXRL[likeId].buttonText, 'click' ,function(e) {
102			clearTimeout(BXRL[likeId].likeTimeout);
103			if (BX.hasClass(BXRL[likeId].template == 'standart'? this: BXRL[likeId].count, 'bx-you-like'))
104			{
105				BXRL[likeId].buttonText.innerHTML	=	BXRL[likeId].localize['LIKE_N'];
106				BXRL[likeId].countText.innerHTML		= 	parseInt(BXRL[likeId].countText.innerHTML)-1;
107				BX.removeClass(BXRL[likeId].template == 'standart'? this: BXRL[likeId].count, 'bx-you-like');
108
109				BXRL[likeId].likeTimeout = setTimeout(function(){
110					if (BXRL[likeId].lastVote != 'cancel')
111						RatingLikes.Vote(likeId, 'cancel');
112				}, 1000);
113			}
114			else
115			{
116				BXRL[likeId].buttonText.innerHTML	=	BXRL[likeId].localize['LIKE_Y'];
117				BXRL[likeId].countText.innerHTML 	= 	parseInt(BXRL[likeId].countText.innerHTML)+1;
118				BX.addClass(BXRL[likeId].template == 'standart'? this: BXRL[likeId].count, 'bx-you-like');
119
120				BXRL[likeId].likeTimeout = setTimeout(function(){
121					if (BXRL[likeId].lastVote != 'plus')
122						RatingLikes.Vote(likeId, 'plus');
123				}, 1000);
124			}
125			BX.removeClass(this.box, 'bx-ilike-button-hover');
126			BX.PreventDefault(e);
127		});
128		// Hover/unHover like-button
129		BX.bind(BXRL[likeId].box, 'mouseover', function() {BX.addClass(this, 'bx-ilike-button-hover')});
130		BX.bind(BXRL[likeId].box, 'mouseout', function() {BX.removeClass(this, 'bx-ilike-button-hover')});
131
132	}
133	else
134	{
135		if (BXRL[likeId].buttonText != undefined)
136			BXRL[likeId].buttonText.innerHTML	=	BXRL[likeId].localize['LIKE_D'];
137	}
138	// get like-user-list
139	RatingLikes.PopupScroll(likeId);
140	console.log();
141	BX.bind(BXRL[likeId].wrapp, 'mouseover' , function() {
142		clearTimeout(BXRL[likeId].popupTimeoutId);
143		BXRL[likeId].popupTimeoutId = setTimeout(function(){
144			if (BXRLW == likeId)
145				return false;
146			if (BXRL[likeId].popupContentPage == 1)
147				RatingLikes.List(likeId, 1);
148			BXRL[likeId].popupTimeoutId = setTimeout(function() {
149				RatingLikes.OpenWindow(likeId);
150			}, 400);
151		}, 400);
152	});
153	BX.bind(BXRL[likeId].wrapp, 'mouseout' , function() {
154		clearTimeout(BXRL[likeId].popupTimeoutId);
155	});
156	/*BX.bind(BXRL[likeId].count, 'click' , function() {
157		clearTimeout(BXRL[likeId].popupTimeoutId);
158		if (BXRL[likeId].popupContentPage == 1)
159			RatingLikes.List(likeId, 1);
160		RatingLikes.OpenWindow(likeId);
161	});*/
162
163	BX.bind(BXRL[likeId].box, 'mouseover' , function() {
164		clearTimeout(BXRL[likeId].popupTimeout);
165	});
166	BX.bind(BXRL[likeId].box, 'mouseout' , function() {
167		clearTimeout(BXRL[likeId].popupTimeout);
168		BXRL[likeId].popupTimeout = setTimeout(function(){
169			if (BXRL[likeId].popup !== null)
170			{
171				BXRL[likeId].popup.close();
172				BXRLW = null;
173			}
174		}, 1000);
175	});
176};
177
178RatingLikes.OpenWindow = function(likeId)
179{
180	if (parseInt(BXRL[likeId].countText.innerHTML) == 0)
181		return false;
182
183	if (BXRL[likeId].popup == null)
184	{
185		BXRL[likeId].popup = new BX.PopupWindow('ilike-popup-'+likeId, (BXRL[likeId].template == 'standart'? BXRL[likeId].count: BXRL[likeId].box), {
186			lightShadow : true,
187			offsetLeft: 5,
188			autoHide: true,
189			closeByEsc: true,
190			zIndex: 2005,
191			bindOptions: {position: "top"},
192			events : {
193				onPopupClose : function() { BXRLW = null; },
194				onPopupDestroy : function() {  }
195			},
196			content : BX('bx-ilike-popup-cont-'+likeId)
197		});
198		BXRL[likeId].popup.setAngle({});
199
200		BX.bind(BX('ilike-popup-'+likeId), 'mouseout' , function() {
201			clearTimeout(BXRL[likeId].popupTimeout);
202			BXRL[likeId].popupTimeout = setTimeout(function(){
203				BXRL[likeId].popup.close();
204			}, 1000);
205		});
206
207		BX.bind(BX('ilike-popup-'+likeId), 'mouseover' , function() {
208			clearTimeout(BXRL[likeId].popupTimeout);
209		});
210	}
211
212	if (BXRLW != null)
213		BXRL[BXRLW].popup.close();
214
215	BXRLW = likeId;
216	BXRL[likeId].popup.show();
217
218	RatingLikes.AdjustWindow(likeId);
219};
220
221RatingLikes.Vote = function(likeId, voteAction)
222{
223	BX.ajax({
224		url: BXRL[likeId].pathToAjax,
225		method: 'POST',
226		dataType: 'json',
227		data: {'RATING_VOTE' : 'Y', 'RATING_VOTE_TYPE_ID' : BXRL[likeId].entityTypeId, 'RATING_VOTE_ENTITY_ID' : BXRL[likeId].entityId, 'RATING_VOTE_ACTION' : voteAction, 'sessid': BX.bitrix_sessid()},
228		onsuccess: function(data)	{
229			BXRL[likeId].lastVote = data.action;
230			BXRL[likeId].countText.innerHTML = data.items_all;
231			BXRL[likeId].popupContentPage = 1;
232
233			BXRL[likeId].popupContent.innerHTML = '';
234			spanTag0 = document.createElement("span");
235			spanTag0.className = "bx-ilike-wait";
236			BXRL[likeId].popupContent.appendChild(spanTag0);
237			RatingLikes.AdjustWindow(likeId);
238
239			if(BX('ilike-popup-'+likeId) && BX('ilike-popup-'+likeId).style.display == "block")
240				RatingLikes.List(likeId, null);
241		},
242		onfailure: function(data)	{}
243	});
244	return false;
245};
246
247RatingLikes.List = function(likeId, page)
248{
249	if (parseInt(BXRL[likeId].countText.innerHTML) == 0)
250		return false;
251
252	if (page == null)
253		page = BXRL[likeId].popupContentPage;
254	BXRL[likeId].popupListProcess = true;
255	BX.ajax({
256		url: BXRL[likeId].pathToAjax,
257		method: 'POST',
258		dataType: 'json',
259		data: {'RATING_VOTE_LIST' : 'Y', 'RATING_VOTE_TYPE_ID' : BXRL[likeId].entityTypeId, 'RATING_VOTE_ENTITY_ID' : BXRL[likeId].entityId, 'RATING_VOTE_LIST_PAGE' : page, 'PATH_TO_USER_PROFILE' : BXRL[likeId].pathToUserProfile, 'sessid': BX.bitrix_sessid()},
260		onsuccess: function(data)
261		{
262			BXRL[likeId].countText.innerHTML = data.items_all;
263
264			if ( parseInt(data.items_page) == 0 )
265				return false;
266
267			if (page == 1)
268			{
269				BXRL[likeId].popupContent.innerHTML = '';
270				spanTag0 = document.createElement("span");
271				spanTag0.className = "bx-ilike-bottom_scroll";
272				BXRL[likeId].popupContent.appendChild(spanTag0);
273			}
274			BXRL[likeId].popupContentPage += 1;
275
276			var avatarNode = null;
277
278			for (var i = 0; i < data.items.length; i++)
279			{
280				if (data.items[i]['PHOTO_SRC'].length > 0)
281				{
282					avatarNode = BX.create("IMG", {
283						attrs: {src: data.items[i]['PHOTO_SRC']},
284						props: {className: "bx-ilike-popup-avatar-img"}
285					});
286				}
287				else
288				{
289					avatarNode = BX.create("IMG", {
290						attrs: {src: '/bitrix/images/main/blank.gif'},
291						props: {className: "bx-ilike-popup-avatar-img bx-ilike-popup-avatar-img-default"}
292					});
293				}
294
295				BXRL[likeId].popupContent.appendChild(
296					BX.create("div", {
297						/*attrs: {
298							href: data.items[i]['URL'],
299							target: '_blank'
300						},*/
301						props: {
302							className: "bx-ilike-popup-img" + (!!data.items[i]['USER_TYPE'] ? " bx-ilike-popup-img-" + data.items[i]['USER_TYPE'] : "")
303						},
304						children: [
305							BX.create("SPAN", {
306								props: {
307									className: "bx-ilike-popup-avatar-new"
308								},
309								children: [
310									avatarNode,
311									BX.create("SPAN", {
312										props: {className: "bx-ilike-popup-avatar-status-icon"}
313									})
314								]
315							}),
316							BX.create("SPAN", {
317								props: {
318									className: "bx-ilike-popup-name-new"
319								},
320								html: data.items[i]['FULL_NAME']
321							})
322						]
323					})
324				);
325			}
326
327			RatingLikes.AdjustWindow(likeId);
328			RatingLikes.PopupScroll(likeId);
329
330			BXRL[likeId].popupListProcess = false;
331		},
332		onfailure: function(data)	{}
333	});
334	return false;
335};
336
337RatingLikes.AdjustWindow = function(likeId)
338{
339	if (BXRL[likeId].popup != null)
340	{
341		BXRL[likeId].popup.bindOptions.forceBindPosition = true;
342		BXRL[likeId].popup.adjustPosition();
343		BXRL[likeId].popup.bindOptions.forceBindPosition = false;
344	}
345};
346
347RatingLikes.PopupScroll = function(likeId)
348{
349	BX.bind(BXRL[likeId].popupContent, 'scroll' , function() {
350		if (this.scrollTop > (this.scrollHeight - this.offsetHeight) / 1.5)
351		{
352			RatingLikes.List(likeId, null);
353			BX.unbindAll(this);
354		}
355	});
356};

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.