PageSourceSearch

https://ceresit-market.ru/bitrix/templates/elektro_flat/components…/.default/script.js?177684179716284

js ceresit-market.ru collected 2026-10-04 20:08:40 UTC 16,284 bytes, 565 lines download raw bytes

1(function (window) {
2
3	if(!!window.JCCatalogBigdataProducts) {
4		return;
5	}	
6
7	var BasketButton = function(params) {
8		BasketButton.superclass.constructor.apply(this, arguments);		
9		this.buttonNode = BX.create("button", {
10			text: params.text,
11			attrs: { 
12				name: params.name,
13				className: params.className
14			},
15			events : this.contextEvents
16		});
17	};
18	BX.extend(BasketButton, BX.PopupWindowButton);
19
20	window.JCCatalogBigdataProducts = function (arParams) {
21		this.productType = 0;
22
23		this.checkQuantity = false;
24		this.maxQuantity = 0;
25		this.stepQuantity = 1;
26		this.isDblQuantity = false;
27
28		this.precision = 6;
29		this.precisionFactor = Math.pow(10, this.precision);
30
31		this.visual = {
32			ID: ""
33		};
34		
35		this.product = {			
36			id: 0,
37			name: "",
38			pict: {},
39			checkQuantity: false,
40			maxQuantity: 0,
41			stepQuantity: 1,			
42			isDblQuantity: false
43		};
44			
45		this.offer = {
46			id: 0,
47			iblockId: 0
48		};
49
50		this.obPopupBtn = null;
51		this.obPropsBtn = null;
52		this.obBtnBuy = null;
53		
54		this.obPopupWin = null;
55		this.basketParams = {};
56			
57		this.errorCode = 0;
58
59		if("object" === typeof arParams) {
60			this.productType = parseInt(arParams.PRODUCT_TYPE, 10);
61			this.visual = arParams.VISUAL;
62			
63			if(!!arParams.PRODUCT && "object" === typeof(arParams.PRODUCT)) {
64				this.product.id = arParams.PRODUCT.ID;
65				this.product.name = arParams.PRODUCT.NAME;
66				this.product.pict = arParams.PRODUCT.PICT;
67
68				this.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY;
69				this.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT;
70				if(this.checkQuantity)
71					this.maxQuantity = (this.isDblQuantity ? parseFloat(arParams.PRODUCT.MAX_QUANTITY) : parseInt(arParams.PRODUCT.MAX_QUANTITY, 10));
72				this.stepQuantity = (this.isDblQuantity ? parseFloat(arParams.PRODUCT.STEP_QUANTITY) : parseInt(arParams.PRODUCT.STEP_QUANTITY, 10));
73				if(this.isDblQuantity)
74					this.stepQuantity = Math.round(this.stepQuantity * this.precisionFactor) / this.precisionFactor;
75				
76				if(!!arParams.OFFER) {
77					this.offer.id = arParams.OFFER.ID;
78					this.offer.iblockId = arParams.OFFER.IBLOCK_ID;
79				}
80			} else {
81				this.errorCode = -1;
82			}
83		}
84		if(0 === this.errorCode) {
85			BX.ready(BX.delegate(this.Init,this));
86		}
87	};
88
89	window.JCCatalogBigdataProducts.prototype.Init = function() {
90		this.obQuantityUp = BX("quantity_plus_" + this.visual.ID);
91		if(!!this.obQuantityUp)
92			BX.bind(this.obQuantityUp, "click", BX.delegate(this.QuantityUp, this));
93				
94		this.obQuantityDown = BX("quantity_minus_" + this.visual.ID);
95		if(!!this.obQuantityDown)
96			BX.bind(this.obQuantityDown, "click", BX.delegate(this.QuantityDown, this));
97
98		this.obQuantity = BX("quantity_" + this.visual.ID);
99		if(!!this.obQuantity)
100			BX.bind(this.obQuantity, "change", BX.delegate(this.QuantityChange, this));
101
102		if(!!this.visual.POPUP_BTN_ID) {
103			this.obPopupBtn = BX(this.visual.POPUP_BTN_ID);
104			BX.bind(this.obPopupBtn, "click", BX.delegate(this.OpenFormPopup, this));
105		}
106		
107		if(!!this.visual.PROPS_BTN_ID) {
108			this.obPropsBtn = BX(this.visual.PROPS_BTN_ID);
109			BX.bind(this.obPropsBtn, "click", BX.delegate(this.OpenPropsPopup, this));
110		}
111		
112		if(!!this.visual.BTN_BUY_ID) {
113			this.obBtnBuy = BX(this.visual.BTN_BUY_ID);
114			BX.bind(this.obBtnBuy, "click", BX.delegate(this.Add2Basket, this));
115		}
116	};
117
118	window.JCCatalogBigdataProducts.prototype.QuantityUp = function() {
119		var curValue = 0,
120			boolSet = true;
121		
122		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
123		if(!isNaN(curValue)) {
124			curValue += this.stepQuantity;
125			if(this.checkQuantity) {
126				if(curValue > this.maxQuantity) {
127					boolSet = false;
128				}
129			}
130			if(boolSet) {
131				if(this.isDblQuantity) {
132					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
133				}
134				this.obQuantity.value = curValue;
135			}
136		}
137	};
138
139	window.JCCatalogBigdataProducts.prototype.QuantityDown = function() {
140		var curValue = 0,
141			boolSet = true;
142		
143		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
144		if(!isNaN(curValue)) {
145			curValue -= this.stepQuantity;
146			if(curValue < this.stepQuantity) {
147				boolSet = false;
148			}
149			if(boolSet) {
150				if(this.isDblQuantity) {
151					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
152				}
153				this.obQuantity.value = curValue;
154			}
155		}
156	};
157
158	window.JCCatalogBigdataProducts.prototype.QuantityChange = function() {
159		var curValue = 0,
160			intCount,
161			count;
162		
163		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
164		if(!isNaN(curValue)) {
165			if(this.checkQuantity) {
166				if(curValue > this.maxQuantity) {
167					curValue = this.maxQuantity;
168				}
169			}
170			if(curValue < this.stepQuantity) {
171				curValue = this.stepQuantity;
172			} else {
173				count = Math.round((curValue * this.precisionFactor) / this.stepQuantity) / this.precisionFactor;
174				intCount = parseInt(count, 10);
175				if(isNaN(intCount)) {
176					intCount = 1;
177					count = 1.1;
178				}
179				if(count > intCount) {
180					curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity);
181					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
182				}
183			}
184			this.obQuantity.value = curValue;
185		} else {
186			this.obQuantity.value = this.stepQuantity;
187		}
188	};
189
190	window.JCCatalogBigdataProducts.prototype.OpenPropsPopup = function() {
191		var visualId = this.visual.ID,
192			elementId = this.product.id,
193			offerId = this.offer.id,
194			offersIblockId = this.offer.iblockId;
195		BX.PropsSet =
196		{			
197			popup: null
198		};
199		BX.PropsSet.popup = BX.PopupWindowManager.create(visualId, null, {
200			autoHide: BX.message("BIGDATA_OFFERS_VIEW") == "LIST" ? false : true,
201			offsetLeft: 0,
202			offsetTop: 0,
203			overlay: {
204				opacity: 100
205			},
206			draggable: false,
207			closeByEsc: false,
208			className: "pop-up more_options" + (offerId > 0 && BX.message("BIGDATA_OFFERS_VIEW") == "LIST" ? " offers-list" : ""),
209			closeIcon: { right : "-10px", top : "-10px"},
210			titleBar: {content: BX.create("span", {html: BX.message("BIGDATA_POPUP_WINDOW_MORE_OPTIONS")})},
211			content: "<div class='popup-window-wait'><i class='fa fa-spinner fa-pulse'></i></div>",
212			events: {
213				onAfterPopupShow: function()
214				{
215					if(!BX(visualId + "_info")) {
216						BX.ajax.post(
217							BX.message("BIGDATA_COMPONENT_TEMPLATE") + "/popup.php",
218							{
219								sessid: BX.bitrix_sessid(),
220								action: "props",
221								arParams: BX.message("BIGDATA_COMPONENT_PARAMS"),
222								ELEMENT_ID: elementId,
223								STR_MAIN_ID: visualId,
224								OFFERS_IBLOCK_ID: offersIblockId > 0 ? offersIblockId : ""
225							},
226							BX.delegate(function(result)
227							{
228								this.setContent(result);
229								var windowSize =  BX.GetWindowInnerSize(),
230								windowScroll = BX.GetWindowScrollPos(),
231								popupHeight = BX(visualId).offsetHeight;
232								BX(visualId).style.top = windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop + "px";
233							},
234							this)
235						);
236					} else {
237						if(offerId > 0) {
238							var parentQntInput = BX("quantity_" + visualId),
239								qntInput = BX("quantity_" + visualId + "_" + offerId);
240							if(!!parentQntInput && !!qntInput)
241								qntInput.value = parentQntInput.value;
242						}
243						var parentQntSelectInput = BX("quantity_" + visualId),
244							qntSelectInput = BX("quantity_select_" + visualId);
245						if(!!parentQntSelectInput && !!qntSelectInput)
246							qntSelectInput.value = parentQntSelectInput.value;
247					}
248				}
249			}
250		});
251
252		var close = BX.findChild(BX(visualId), {className: "popup-window-close-icon"}, true, false);
253		if(!!close)
254			close.innerHTML = "<i class='fa fa-times'></i>";
255
256		BX.PropsSet.popup.show();
257	};
258
259	window.JCCatalogBigdataProducts.prototype.OpenFormPopup = function() {
260		var target = BX.proxy_context,
261			action = target.getAttribute("data-action"),
262			visualId = action + "_" + this.visual.ID,
263			elementId = this.product.id,
264			elementName = this.product.name;
265		BX.PopupForm =
266		{						
267			arParams: {}
268		};
269		BX.PopupForm.popup = BX.PopupWindowManager.create(visualId, null, {
270			autoHide: true,
271			offsetLeft: 0,
272			offsetTop: 0,			
273			overlay: {
274				opacity: 100
275			},
276			draggable: false,
277			closeByEsc: false,
278			className: "pop-up forms full",
279			closeIcon: { right : "-10px", top : "-10px"},			
280			titleBar: true,
281			content: "<div class='popup-window-wait'><i class='fa fa-spinner fa-pulse'></i></div>",			
282			events: {
283				onAfterPopupShow: function()
284				{
285					if(!BX(visualId + "_form")) {
286						BX.ajax.post(
287							BX.message("BIGDATA_COMPONENT_TEMPLATE") + "/popup.php",
288							{							
289								sessid: BX.bitrix_sessid(),
290								action: action,
291								arParams: {
292									ELEMENT_ID: elementId,
293									ELEMENT_AREA_ID: visualId,
294									ELEMENT_NAME: elementName
295								}
296							},
297							BX.delegate(function(result)
298							{
299								this.setContent(result);
300								var windowSize =  BX.GetWindowInnerSize(),
301								windowScroll = BX.GetWindowScrollPos(),
302								popupHeight = BX(visualId).offsetHeight;
303								BX(visualId).style.top = windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop + "px";
304							},
305							this)
306						);
307					}					
308				}
309			}			
310		});
311		
312		var close = BX.findChild(BX(visualId), {className: "popup-window-close-icon"}, true, false);
313		if(!!close)
314			close.innerHTML = "<i class='fa fa-times'></i>";
315
316		BX.PopupForm.popup.show();		
317	};
318
319	window.JCCatalogBigdataProducts.prototype.Add2Basket = function() {
320		var target = BX.proxy_context,
321			form = BX.findParent(target, {"tag" : "form"}),
322			formInputs = BX.findChildren(form, {"tag" : "input"}, true);
323		
324		if(!!formInputs && 0 < formInputs.length) {
325			for(i = 0; i < formInputs.length; i++) {
326				this.basketParams[formInputs[i].getAttribute("name")] = formInputs[i].value;
327			}
328		}
329		
330		BX.ajax.post(
331			form.getAttribute("action"),			
332			this.basketParams,			
333			BX.delegate(function(result) {
334				if(location.pathname != BX.message("BIGDATA_SITE_DIR") + "personal/cart/") {
335					BX.ajax.post(
336						BX.message("BIGDATA_SITE_DIR") + "ajax/basket_line.php",
337						"",
338						BX.delegate(function(data) {
339							refreshCartLine(data);
340						}, this)
341					);
342					BX.ajax.post(
343						BX.message("BIGDATA_SITE_DIR") + "ajax/delay_line.php",
344						"",
345						BX.delegate(function(data) {
346							var delayLine = BX.findChild(document.body, {className: "delay_line"}, true, false);
347							if(!!delayLine)
348								delayLine.innerHTML = data;
349						}, this)
350					);
351				}
352				BX.adjust(target, {
353					props: {disabled: true},
354					html: "<i class='fa fa-check'></i><span>" + BX.message("BIGDATA_ADDITEMINCART_ADDED") + "</span>"
355				});
356				if(location.pathname != BX.message("BIGDATA_SITE_DIR") + "personal/cart/") {
357					this.BasketResult();
358				} else {
359					this.BasketRedirect();
360				}
361			}, this)			
362		);		
363	};
364
365	window.JCCatalogBigdataProducts.prototype.BasketResult = function() {
366		var close,
367			strContent,
368			strPictSrc,
369			strPictWidth,
370			strPictHeight,
371			buttons = [];
372
373		if(!!this.obPopupWin) {
374			this.obPopupWin.close();
375		}
376		
377		this.obPopupWin = BX.PopupWindowManager.create("addItemInCart", null, {
378			autoHide: true,
379			offsetLeft: 0,
380			offsetTop: 0,
381			overlay: {
382				opacity: 100
383			},
384			draggable: false,
385			closeByEsc: false,
386			className: "pop-up modal",
387			closeIcon: {top: "-10px", right: "-10px"},
388			titleBar: {content: BX.create("span", {html: BX.message("BIGDATA_POPUP_WINDOW_TITLE")})}			
389		});
390		
391		close = BX.findChild(BX("addItemInCart"), {className: "popup-window-close-icon"}, true, false);
392		if(!!close)
393			close.innerHTML = "<i class='fa fa-times'></i>";
394
395		strPictSrc = this.product.pict.SRC;
396		strPictWidth = this.product.pict.WIDTH;
397		strPictHeight = this.product.pict.HEIGHT;
398		
399		strContent = "<div class='cont'><div class='item_image_cont'><div class='item_image_full'><img src='" + strPictSrc + "' width='" + strPictWidth + "' height='" + strPictHeight + "' alt='"+ this.product.name +"' /></div></div><div class='item_title'>" + this.product.name + "</div></div>";
400
401		buttons = [			
402			new BasketButton({				
403				text: BX.message("BIGDATA_POPUP_WINDOW_BTN_CLOSE"),
404				name: "close",
405				className: "btn_buy ppp close",
406				events: {
407					click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
408				}
409			}),
410			new BasketButton({				
411				text: BX.message("BIGDATA_POPUP_WINDOW_BTN_ORDER"),
412				name: "order",
413				className: "btn_buy popdef order",
414				events: {
415					click: BX.delegate(this.BasketRedirect, this)
416				}
417			})
418		];
419		
420		this.obPopupWin.setContent(strContent);
421		this.obPopupWin.setButtons(buttons);
422		this.obPopupWin.show();	
423	};
424
425	window.JCCatalogBigdataProducts.prototype.BasketRedirect = function() {
426		location.href = BX.message("BIGDATA_SITE_DIR") + "personal/cart/";
427	};
428
429	window.JCCatalogBigdataProducts.prototype.RememberRecommendation = function(obj, productId) {
430		var rcmContainer = BX.findParent(obj, {className: "bigdata_recommended_products_items"});
431		var rcmId = BX.findChild(rcmContainer, {attr: {name: "bigdata_recommendation_id"}}, true).value;
432
433		this.RememberProductRecommendation(rcmId, productId);
434	};
435
436	window.JCCatalogBigdataProducts.prototype.RememberProductRecommendation = function(recommendationId, productId) {
437		//save to RCM_PRODUCT_LOG
438		var plCookieName = BX.cookie_prefix+"_RCM_PRODUCT_LOG";
439		var plCookie = getCookie(plCookieName);
440		var itemFound = false;
441
442		var cItems = [],
443			cItem;
444
445		if(plCookie) {
446			cItems = plCookie.split(".");
447		}
448
449		var i = cItems.length;
450
451		while(i--) {
452			cItem = cItems[i].split("-");
453
454			if(cItem[0] == productId) {
455				//it's already in recommendations, update the date
456				cItem = cItems[i].split("-");
457
458				//update rcmId and date
459				cItem[1] = rcmId;
460				cItem[2] = BX.current_server_time;
461
462				cItems[i] = cItem.join("-");
463				itemFound = true;
464			} else {
465				if((BX.current_server_time - cItem[2]) > 3600*24*30) {
466					cItems.splice(i, 1);
467				}
468			}
469		}
470
471		if(!itemFound) {
472			//add recommendation
473			cItems.push([productId, rcmId, BX.current_server_time].join("-"));
474		}
475
476		//serialize
477		var plNewCookie = cItems.join(".");
478
479		var cookieDate = new Date(new Date().getTime() + 1000*3600*24*365*10);
480		document.cookie=plCookieName+"="+plNewCookie+"; path=/; expires="+cookieDate.toUTCString()+"; domain="+BX.cookie_domain;
481	};
482})(window);
483
484function getCookie(name) {
485	var matches = document.cookie.match(new RegExp(
486		"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + "=([^;]*)"
487	));
488	return matches ? decodeURIComponent(matches[1]) : undefined;
489}
490
491function bx_rcm_recommendation_event_attaching(rcm_items_cont) {
492	return null;
493}
494
495function bx_rcm_adaptive_recommendation_event_attaching(items, uniqId) {
496	//onclick handler
497	var callback = function(e) {
498		var link = BX(this), j;
499		for(j in items) {
500			if(items[j].productUrl == link.getAttribute("href")) {
501				window.JCCatalogBigdataProducts.prototype.RememberProductRecommendation(
502					items[j].recommendationId, items[j].productId
503				);
504				break;
505			}
506		}
507	};
508
509	//check if a container was defined is the template
510	var itemsContainer = BX(uniqId);
511
512	if(!itemsContainer) {
513		// then get all the links
514		itemsContainer = document.body;
515	}
516
517	var links = BX.findChildren(itemsContainer, {tag:"a"}, true);
518
519	//bind
520	if(links) {
521		var i;
522		for(i in links) {
523			BX.bind(links[i], "click", callback);
524		}
525	}
526}
527
528function bx_rcm_get_from_cloud(injectId, rcmParameters, localAjaxData) {
529	var url = "https://analytics.bitrix.info/crecoms/v1_0/recoms.php";
530	var data = BX.ajax.prepareData(rcmParameters);
531
532	if(data) {
533		url += (url.indexOf("?") !== -1 ? "&" : "?") + data;
534	}
535
536	var onready = function(response) {
537		if(!response.items) {
538			response.items = [];
539		}
540		BX.ajax({
541			url: "/bitrix/components/bitrix/catalog.bigdata.products/ajax.php?"+BX.ajax.prepareData({"AJAX_ITEMS": response.items, "RID": response.id}),
542			method: "POST",
543			data: localAjaxData,
544			dataType: "html",
545			processData: false,
546			start: true,
547			onsuccess: function(html) {
548				var ob = BX.processHTML(html);
549
550				// inject
551				BX(injectId).innerHTML = ob.HTML;
552				BX.ajax.processScripts(ob.SCRIPT);
553			}
554		});
555	};
556
557	BX.ajax({
558		"method": "GET",
559		"dataType": "json",
560		"url": url,
561		"timeout": 3,
562		"onsuccess": onready,
563		"onfailure": onready
564	});
565}

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.