PageSourceSearch

https://lexmer.ru/local/templates/.default/components/bitrix/catalog.section/product-new-searched/script.js

js lexmer.ru collected 2026-09-26 10:38:32 UTC 8,651 bytes, 360 lines download raw bytes

1(function() {
2	'use strict';
3
4	if (!!window.JCCatalogSectionComponent)
5		return;
6
7	window.JCCatalogSectionComponent = function(params) {
8		this.formPosting = false;
9		this.siteId = params.siteId || '';
10		this.ajaxId = params.ajaxId || '';
11		this.template = params.template || '';
12		this.componentPath = params.componentPath || '';
13		this.parameters = params.parameters || '';
14
15		if (params.navParams)
16		{
17			this.navParams = {
18				NavNum: params.navParams.NavNum || 1,
19				NavPageNomer: parseInt(params.navParams.NavPageNomer) || 1,
20				NavPageCount: parseInt(params.navParams.NavPageCount) || 1
21			};
22		}
23
24		this.bigData = params.bigData || {enabled: false};
25		this.container = document.querySelector('[data-entity="' + params.container + '"]');
26		this.lazyLoadContainer = document.querySelector('[data-entity="lazy-' + params.container + '"]');
27		this.showMoreButton = null;
28		this.showMoreButtonMessage = null;
29
30		if (this.bigData.enabled && BX.util.object_keys(this.bigData.rows).length > 0)
31		{
32			BX.cookie_prefix = this.bigData.js.cookiePrefix || '';
33			BX.cookie_domain = this.bigData.js.cookieDomain || '';
34			BX.current_server_time = this.bigData.js.serverTime;
35
36			BX.ready(BX.delegate(this.bigDataLoad, this));
37		}
38
39		if (params.initiallyShowHeader)
40		{
41			BX.ready(BX.delegate(this.showHeader, this));
42		}
43
44		if (params.deferredLoad)
45		{
46			BX.ready(BX.delegate(this.deferredLoad, this));
47		}
48
49		if (params.lazyLoad)
50		{
51			this.showMoreButton = document.querySelector('[data-use="show-more-' + this.navParams.NavNum + '"]');
52			this.showMoreButtonMessage = this.showMoreButton.innerHTML;
53			BX.bind(this.showMoreButton, 'click', BX.proxy(this.showMore, this));
54		}
55
56		if (params.loadOnScroll)
57		{
58			BX.bind(window, 'scroll', BX.proxy(this.loadOnScroll, this));
59		}
60	};
61
62	window.JCCatalogSectionComponent.prototype =
63	{
64		checkButton: function()
65		{
66			if (this.showMoreButton)
67			{
68				if (this.navParams.NavPageNomer == this.navParams.NavPageCount)
69				{
70					BX.remove(this.showMoreButton);
71				}
72				else
73				{
74					this.lazyLoadContainer.appendChild(this.showMoreButton);
75				}
76			}
77		},
78
79		enableButton: function()
80		{
81			if (this.showMoreButton)
82			{
83				BX.removeClass(this.showMoreButton, 'disabled');
84				this.showMoreButton.innerHTML = this.showMoreButtonMessage;
85			}
86		},
87
88		disableButton: function()
89		{
90			if (this.showMoreButton)
91			{
92				BX.addClass(this.showMoreButton, 'disabled');
93				this.showMoreButton.innerHTML = BX.message('BTN_MESSAGE_LAZY_LOAD_WAITER');
94			}
95		},
96
97		loadOnScroll: function()
98		{
99			var scrollTop = BX.GetWindowScrollPos().scrollTop,
100				containerBottom = BX.pos(this.container).bottom;
101
102			if (scrollTop + window.innerHeight > containerBottom)
103			{
104				this.showMore();
105			}
106		},
107
108		showMore: function()
109		{
110			if (this.navParams.NavPageNomer < this.navParams.NavPageCount)
111			{
112				var data = {};
113				data['action'] = 'showMore';
114				data['PAGEN_' + this.navParams.NavNum] = this.navParams.NavPageNomer + 1;
115
116				if (!this.formPosting)
117				{
118					this.formPosting = true;
119					this.disableButton();
120					// this.sendRequest(data);
121				}
122			}
123		},
124
125		bigDataLoad: function()
126		{
127			var url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php',
128				data = BX.ajax.prepareData(this.bigData.params);
129
130			if (data)
131			{
132				url += (url.indexOf('?') !== -1 ? '&' : '?') + data;
133			}
134
135			var onReady = BX.delegate(function(result){
136				this.sendRequest({
137					action: 'deferredLoad',
138					bigData: 'Y',
139					items: result && result.items || [],
140					rid: result && result.id,
141					count: this.bigData.count,
142					rowsRange: this.bigData.rowsRange,
143					shownIds: this.bigData.shownIds
144				});
145			}, this);
146
147			BX.ajax({
148				method: 'GET',
149				dataType: 'json',
150				url: url,
151				timeout: 3,
152				onsuccess: onReady,
153				onfailure: onReady
154			});
155		},
156
157		deferredLoad: function()
158		{
159			this.sendRequest({action: 'deferredLoad'});
160		},
161
162		sendRequest: function(data)
163		{
164			var defaultData = {
165				siteId: this.siteId,
166				template: this.template,
167				parameters: this.parameters
168			};
169
170			if (this.ajaxId)
171			{
172				defaultData.AJAX_ID = this.ajaxId;
173			}
174
175			BX.ajax({
176				url: this.componentPath + '/ajax.php' + (document.location.href.indexOf('clear_cache=Y') !== -1 ? '?clear_cache=Y' : ''),
177				method: 'POST',
178				dataType: 'json',
179				timeout: 60,
180				data: BX.merge(defaultData, data),
181				onsuccess: BX.delegate(function(result){
182					if (!result || !result.JS)
183						return;
184
185					BX.ajax.processScripts(
186						BX.processHTML(result.JS).SCRIPT,
187						false,
188						BX.delegate(function(){this.showAction(result, data);}, this)
189					);
190				}, this)
191			});
192		},
193
194		showAction: function(result, data)
195		{
196			if (!data)
197				return;
198
199			switch (data.action)
200			{
201				case 'showMore':
202					this.processShowMoreAction(result);
203					break;
204				case 'deferredLoad':
205					this.processDeferredLoadAction(result, data.bigData === 'Y');
206					break;
207			}
208		},
209
210		processShowMoreAction: function(result)
211		{
212			this.formPosting = false;
213			this.enableButton();
214
215			if (result)
216			{
217				this.navParams.NavPageNomer++;
218				this.processItems(result.items);
219				this.processPagination(result.pagination);
220				this.processEpilogue(result.epilogue);
221				this.checkButton();
222			}
223		},
224
225		processDeferredLoadAction: function(result, bigData)
226		{
227			if (!result)
228				return;
229
230			var position = bigData ? this.bigData.rows : {};
231
232			this.processItems(result.items, BX.util.array_keys(position));
233		},
234
235		processItems: function(itemsHtml, position)
236		{
237			if (!itemsHtml)
238				return;
239
240			var processed = BX.processHTML(itemsHtml, false),
241				temporaryNode = BX.create('DIV');
242
243			var items, k, origRows;
244
245			temporaryNode.innerHTML = processed.HTML;
246			items = temporaryNode.querySelectorAll('[data-entity="items-row"]');
247
248			if (items.length)
249			{
250				this.showHeader(true);
251
252				for (k in items)
253				{
254					if (items.hasOwnProperty(k))
255					{
256						origRows = position ? this.container.querySelectorAll('[data-entity="items-row"]') : false;
257						items[k].style.opacity = 0;
258
259						if (origRows && BX.type.isDomNode(origRows[position[k]]))
260						{
261							origRows[position[k]].parentNode.insertBefore(items[k], origRows[position[k]]);
262						}
263						else
264						{
265							this.container.appendChild(items[k]);
266						}
267					}
268				}
269
270				new BX.easing({
271					duration: 2000,
272					start: {opacity: 0},
273					finish: {opacity: 100},
274					transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
275					step: function(state){
276						for (var k in items)
277						{
278							if (items.hasOwnProperty(k))
279							{
280								items[k].style.opacity = state.opacity / 100;
281							}
282						}
283					},
284					complete: function(){
285						for (var k in items)
286						{
287							if (items.hasOwnProperty(k))
288							{
289								items[k].removeAttribute('style');
290							}
291						}
292					}
293				}).animate();
294			}
295
296			BX.ajax.processScripts(processed.SCRIPT);
297		},
298
299		processPagination: function(paginationHtml)
300		{
301			if (!paginationHtml)
302				return;
303
304			var pagination = document.querySelectorAll('[data-pagination-num="' + this.navParams.NavNum + '"]');
305			for (var k in pagination)
306			{
307				if (pagination.hasOwnProperty(k))
308				{
309					pagination[k].innerHTML = paginationHtml;
310				}
311			}
312		},
313
314		processEpilogue: function(epilogueHtml)
315		{
316			if (!epilogueHtml)
317				return;
318
319			var processed = BX.processHTML(epilogueHtml, false);
320			BX.ajax.processScripts(processed.SCRIPT);
321		},
322
323		showHeader: function(animate)
324		{
325			var parentNode = BX.findParent(this.container, {attr: {'data-entity': 'parent-container'}}),
326				header;
327
328			if (parentNode && BX.type.isDomNode(parentNode))
329			{
330				header = parentNode.querySelector('[data-entity="header"]');
331
332				if (header && header.getAttribute('data-showed') != 'true')
333				{
334					header.style.display = '';
335
336					if (animate)
337					{
338						new BX.easing({
339							duration: 2000,
340							start: {opacity: 0},
341							finish: {opacity: 100},
342							transition: BX.easing.makeEaseOut(BX.easing.transitions.quad),
343							step: function(state){
344								header.style.opacity = state.opacity / 100;
345							},
346							complete: function(){
347								header.removeAttribute('style');
348								header.setAttribute('data-showed', 'true');
349							}
350						}).animate();
351					}
352					else
353					{
354						header.style.opacity = 100;
355					}
356				}
357			}
358		}
359	};
360})();

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.