PageSourceSearch

https://zubr-vrn.ru/local/templates/.default/components/altop/search.title/top/script.js

js zubr-vrn.ru collected 2026-10-04 23:17:11 UTC 12,706 bytes, 423 lines download raw bytes

1(function (window) {
2
3	if(!!window.JCCatalogSearchProducts) {
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.JCCatalogSearchProducts = 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		};
48
49		this.obPopupBtn = null;
50		this.obPropsBtn = null;
51		this.obBtnBuy = null;
52
53		this.obPopupWin = null;
54		this.basketParams = {};
55			
56		this.errorCode = 0;
57		
58		if("object" === typeof arParams) {			
59			this.visual = arParams.VISUAL;
60
61			if(!!arParams.PRODUCT && "object" === typeof(arParams.PRODUCT)) {
62				this.product.id = arParams.PRODUCT.ID;
63				this.product.name = arParams.PRODUCT.NAME;
64				this.product.pict = arParams.PRODUCT.PICT;
65
66				this.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY;
67				this.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT;
68				if(this.checkQuantity)
69					this.maxQuantity = (this.isDblQuantity ? parseFloat(arParams.PRODUCT.MAX_QUANTITY) : parseInt(arParams.PRODUCT.MAX_QUANTITY, 10));
70				this.stepQuantity = (this.isDblQuantity ? parseFloat(arParams.PRODUCT.STEP_QUANTITY) : parseInt(arParams.PRODUCT.STEP_QUANTITY, 10));
71				if(this.isDblQuantity)
72					this.stepQuantity = Math.round(this.stepQuantity * this.precisionFactor) / this.precisionFactor;
73
74				if(!!arParams.OFFER)
75					this.offer.id = arParams.OFFER.ID;
76			} else {
77				this.errorCode = -1;
78			}
79		}
80		if(0 === this.errorCode) {
81			BX.ready(BX.delegate(this.Init,this));
82		}
83	};
84
85	window.JCCatalogSearchProducts.prototype.Init = function() {
86		this.obQuantityUp = BX("quantity_plus_" + this.visual.ID);
87		if(!!this.obQuantityUp)
88			BX.bind(this.obQuantityUp, "click", BX.delegate(this.QuantityUp, this));
89				
90		this.obQuantityDown = BX("quantity_minus_" + this.visual.ID);
91		if(!!this.obQuantityDown)
92			BX.bind(this.obQuantityDown, "click", BX.delegate(this.QuantityDown, this));
93
94		this.obQuantity = BX("quantity_" + this.visual.ID);
95		if(!!this.obQuantity)
96			BX.bind(this.obQuantity, "change", BX.delegate(this.QuantityChange, this));
97
98		if(!!this.visual.POPUP_BTN_ID) {
99			this.obPopupBtn = BX(this.visual.POPUP_BTN_ID);
100			BX.bind(this.obPopupBtn, "click", BX.delegate(this.OpenFormPopup, this));
101		}
102		
103		if(!!this.visual.PROPS_BTN_ID) {
104			this.obPropsBtn = BX(this.visual.PROPS_BTN_ID);
105			BX.bind(this.obPropsBtn, "click", BX.delegate(this.OpenPropsPopup, this));
106		}
107		
108		if(!!this.visual.BTN_BUY_ID) {
109			this.obBtnBuy = BX(this.visual.BTN_BUY_ID);
110			BX.bind(this.obBtnBuy, "click", BX.delegate(this.Add2Basket, this));
111		}
112	};
113
114	window.JCCatalogSearchProducts.prototype.QuantityUp = function() {
115		var curValue = 0,
116			boolSet = true;
117		
118		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
119		if(!isNaN(curValue)) {
120			curValue += this.stepQuantity;
121			if(this.checkQuantity) {
122				if(curValue > this.maxQuantity) {
123					boolSet = false;
124				}
125			}
126			if(boolSet) {
127				if(this.isDblQuantity) {
128					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
129				}
130				this.obQuantity.value = curValue;
131			}
132		}
133	};
134
135	window.JCCatalogSearchProducts.prototype.QuantityDown = function() {
136		var curValue = 0,
137			boolSet = true;
138		
139		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
140		if(!isNaN(curValue)) {
141			curValue -= this.stepQuantity;
142			if(curValue < this.stepQuantity) {
143				boolSet = false;
144			}
145			if(boolSet) {
146				if(this.isDblQuantity) {
147					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
148				}
149				this.obQuantity.value = curValue;
150			}
151		}
152	};
153
154	window.JCCatalogSearchProducts.prototype.QuantityChange = function() {
155		var curValue = 0,
156			intCount,
157			count;
158		
159		curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
160		if(!isNaN(curValue)) {
161			if(this.checkQuantity) {
162				if(curValue > this.maxQuantity) {
163					curValue = this.maxQuantity;
164				}
165			}
166			if(curValue < this.stepQuantity) {
167				curValue = this.stepQuantity;
168			} else {
169				count = Math.round((curValue * this.precisionFactor) / this.stepQuantity) / this.precisionFactor;
170				intCount = parseInt(count, 10);
171				if(isNaN(intCount)) {
172					intCount = 1;
173					count = 1.1;
174				}
175				if(count > intCount) {
176					curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity);
177					curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
178				}
179			}
180			this.obQuantity.value = curValue;
181		} else {
182			this.obQuantity.value = this.stepQuantity;
183		}
184	};
185
186	window.JCCatalogSearchProducts.prototype.OpenPropsPopup = function() {
187		var visualId = this.visual.ID,
188			elementId = this.product.id,
189			offerId = this.offer.id;
190		BX.PropsSet =
191		{			
192			popup: null
193		};
194		BX.PropsSet.popup = BX.PopupWindowManager.create(visualId, null, {
195			autoHide: BX.message("SEARCH_OFFERS_VIEW") == "LIST" ? false : true,
196			offsetLeft: 0,
197			offsetTop: 0,
198			overlay: {
199				opacity: 100
200			},
201			draggable: false,
202			closeByEsc: false,
203			className: "pop-up more_options" + (offerId > 0 && BX.message("SEARCH_OFFERS_VIEW") == "LIST" ? " offers-list" : ""),
204			closeIcon: { right : "-10px", top : "-10px"},
205			titleBar: {content: BX.create("span", {html: BX.message("SEARCH_POPUP_WINDOW_MORE_OPTIONS")})},
206			content: "<div class='popup-window-wait'><i class='fa fa-spinner fa-pulse'></i></div>",
207			events: {
208				onAfterPopupShow: function()
209				{
210					if(!BX(visualId + "_info")) {
211						BX.ajax.post(
212							BX.message("SEARCH_COMPONENT_TEMPLATE") + "/popup.php",
213							{
214								sessid: BX.bitrix_sessid(),
215								action: "props",
216								arParams: BX.message("SEARCH_COMPONENT_PARAMS"),
217								ELEMENT_ID: elementId,
218								STR_MAIN_ID: visualId
219							},
220							BX.delegate(function(result)
221							{
222								this.setContent(result);
223								var windowSize =  BX.GetWindowInnerSize(),
224								windowScroll = BX.GetWindowScrollPos(),
225								popupHeight = BX(visualId).offsetHeight;
226								BX(visualId).style.top = windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop + "px";
227							},
228							this)
229						);
230					} else {
231						if(offerId > 0) {
232							var parentQntInput = BX("quantity_" + visualId),
233								qntInput = BX("quantity_" + visualId + "_" + offerId);
234							if(!!parentQntInput && !!qntInput)
235								qntInput.value = parentQntInput.value;
236						}
237						var parentQntSelectInput = BX("quantity_" + visualId),
238							qntSelectInput = BX("quantity_select_" + visualId);
239						if(!!parentQntSelectInput && !!qntSelectInput)
240							qntSelectInput.value = parentQntSelectInput.value;
241					}
242				}
243			}
244		});
245
246		var close = BX.findChild(BX(visualId), {className: "popup-window-close-icon"}, true, false);
247		if(!!close)
248			close.innerHTML = "<i class='fa fa-times'></i>";
249
250		BX.PropsSet.popup.show();
251	};
252	
253	window.JCCatalogSearchProducts.prototype.OpenFormPopup = function() {
254		var target = BX.proxy_context,
255			form = BX.findParent(target, {tagName: "form"}),
256			action = BX.findChild(form, {tagName: "input", attribute: {name: "ACTION"}}, true, false).value,
257			visualId = action + "_" + this.visual.ID,
258			elementId = this.product.id,
259			elementName = BX.findChild(form, {tagName: "input", attribute: {name: "NAME"}}, true, false).value;		
260		BX.PopupForm =
261		{						
262			arParams: {}
263		};
264		BX.PopupForm.popup = BX.PopupWindowManager.create(visualId, null, {
265			autoHide: true,
266			offsetLeft: 0,
267			offsetTop: 0,			
268			overlay: {
269				opacity: 100
270			},
271			draggable: false,
272			closeByEsc: false,
273			className: "pop-up forms full",
274			closeIcon: { right : "-10px", top : "-10px"},
275			titleBar: true,
276			content: "<div class='popup-window-wait'><i class='fa fa-spinner fa-pulse'></i></div>",			
277			events: {
278				onAfterPopupShow: function()
279				{
280					if(!BX(visualId + "_form")) {
281						BX.ajax.post(
282							BX.message("SEARCH_COMPONENT_TEMPLATE") + "/popup.php",
283							{							
284								sessid: BX.bitrix_sessid(),
285								action: action,
286								arParams: {
287									ELEMENT_ID: elementId,
288									ELEMENT_AREA_ID: visualId,
289									ELEMENT_NAME: elementName
290								}
291							},
292							BX.delegate(function(result)
293							{
294								this.setContent(result);
295								var windowSize =  BX.GetWindowInnerSize(),
296								windowScroll = BX.GetWindowScrollPos(),
297								popupHeight = BX(visualId).offsetHeight;
298								BX(visualId).style.top = windowSize.innerHeight/2 - popupHeight/2 + windowScroll.scrollTop + "px";
299							},
300							this)
301						);
302					}
303				}
304			}			
305		});
306		
307		var close = BX.findChild(BX(visualId), {className: "popup-window-close-icon"}, true, false);
308		if(!!close)
309			close.innerHTML = "<i class='fa fa-times'></i>";
310
311		BX.PopupForm.popup.show();		
312	};
313	
314	window.JCCatalogSearchProducts.prototype.Add2Basket = function() {
315		var target = BX.proxy_context,
316			form = BX.findParent(target, {"tag" : "form"}),
317			formInputs = BX.findChildren(form, {"tag" : "input"}, true);
318		
319		if(!!formInputs && 0 < formInputs.length) {
320			for(i = 0; i < formInputs.length; i++) {
321				this.basketParams[formInputs[i].getAttribute("name")] = formInputs[i].value;
322			}
323		}
324		
325		BX.ajax.post(
326			form.getAttribute("action"),			
327			this.basketParams,			
328			BX.delegate(function(result) {
329				if(location.pathname != BX.message("SEARCH_SITE_DIR") + "personal/cart/") {
330					BX.ajax.post(
331						BX.message("SEARCH_SITE_DIR") + "ajax/basket_line.php",
332						"",
333						BX.delegate(function(data) {
334							refreshCartLine(data);
335						}, this)
336					);
337					BX.ajax.post(
338						BX.message("SEARCH_SITE_DIR") + "ajax/delay_line.php",
339						"",
340						BX.delegate(function(data) {
341							var delayLine = BX.findChild(document.body, {className: "delay_line"}, true, false);
342							if(!!delayLine)
343								delayLine.innerHTML = data;						
344						}, this)
345					);
346				}
347				BX.adjust(target, {
348					props: {disabled: true},
349					html: "<i class='fa fa-check'></i><span>" + BX.message("SEARCH_ADDITEMINCART_ADDED") + "</span>"
350				});
351				if(location.pathname != BX.message("SEARCH_SITE_DIR") + "personal/cart/") {
352					this.BasketResult();				
353				} else {
354					this.BasketRedirect();
355				}
356			}, this)			
357		);		
358	};
359
360	window.JCCatalogSearchProducts.prototype.BasketResult = function() {
361		var close,
362			strContent,
363			strPictSrc,
364			strPictWidth,
365			strPictHeight,
366			buttons = [];
367
368		if(!!this.obPopupWin) {
369			this.obPopupWin.close();
370		}
371		
372		this.obPopupWin = BX.PopupWindowManager.create("addItemInCart", null, {
373			autoHide: true,
374			offsetLeft: 0,
375			offsetTop: 0,
376			overlay: {
377				opacity: 100
378			},
379			draggable: false,
380			closeByEsc: false,
381			className: "pop-up modal",
382			closeIcon: {top: "-10px", right: "-10px"},
383			titleBar: {content: BX.create("span", {html: BX.message("SEARCH_POPUP_WINDOW_TITLE")})}			
384		});
385		
386		close = BX.findChild(BX("addItemInCart"), {className: "popup-window-close-icon"}, true, false);
387		if(!!close)
388			close.innerHTML = "<i class='fa fa-times'></i>";
389
390		strPictSrc = this.product.pict.SRC;
391		strPictWidth = this.product.pict.WIDTH;
392		strPictHeight = this.product.pict.HEIGHT;
393		
394		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>";
395
396		buttons = [			
397			new BasketButton({				
398				text: BX.message("SEARCH_POPUP_WINDOW_BTN_CLOSE"),
399				name: "close",
400				className: "btn_buy ppp close",
401				events: {
402					click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
403				}
404			}),
405			new BasketButton({				
406				text: BX.message("SEARCH_POPUP_WINDOW_BTN_ORDER"),
407				name: "order",
408				className: "btn_buy popdef order",
409				events: {
410					click: BX.delegate(this.BasketRedirect, this)
411				}
412			})
413		];
414		
415		this.obPopupWin.setContent(strContent);
416		this.obPopupWin.setButtons(buttons);
417		this.obPopupWin.show();	
418	};
419
420	window.JCCatalogSearchProducts.prototype.BasketRedirect = function() {
421		location.href = BX.message("SEARCH_SITE_DIR") + "personal/cart/";
422	};
423})(window);

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.