PageSourceSearch

https://www.spets.ru/bitrix/templates/spets_2022/components/bitrix…/bootstrap_v4/script.js?16956664978639

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

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.