PageSourceSearch

https://techno-sozh.ru/local/templates/vm/components/vm/catalog/ca…/.default/script_sku.js?178730317061944

js techno-sozh.ru collected 2026-10-09 22:43:05 UTC 61,944 bytes, 2,124 lines download raw bytes

1
2(function (window) {
3	'use strict';
4
5	if (window.JCCatalogElement)
6		return;
7
8	// var BasketButton = function (params) {
9	// 	BasketButton.superclass.constructor.apply(this, arguments);
10	// 	this.buttonNode = BX.create('SPAN', {
11	// 		props: { className: 'btn btn-default btn-buy btn-sm', id: this.id },
12	// 		style: typeof params.style === 'object' ? params.style : {},
13	// 		text: params.text,
14	// 		events: this.contextEvents
15	// 	});
16
17	// 	if (BX.browser.IsIE()) {
18	// 		this.buttonNode.setAttribute('hideFocus', 'hidefocus');
19	// 	}
20	// };
21	// BX.extend(BasketButton, BX.PopupWindowButton);
22
23
24	window.JCCatalogElement = function (arParams) {
25		this.productType = 0;
26		this.config = {
27			useCatalog: true,
28			showQuantity: true,
29			showPrice: true,
30			showAbsent: true,
31			showOldPrice: false,
32			showPercent: false,
33			showSkuProps: false,
34			showOfferGroup: false,
35			// useCompare: false,
36			// useStickers: false,
37			// useSubscribe: false,
38			// usePopup: false,
39			// useMagnifier: false,
40			usePriceRanges: false,
41			basketAction: ['BUY'],
42			showClosePopup: false,
43			templateTheme: '',
44			// showSlider: false,
45			// sliderInterval: 5000,
46			useEnhancedEcommerce: false,
47			dataLayerName: 'dataLayer',
48			brandProperty: false,
49			alt: '',
50			title: '',
51			magnifierZoomPercent: 200
52		};
53
54		this.checkQuantity = false;
55		this.maxQuantity = 0;
56		this.minQuantity = 0;
57		this.stepQuantity = 1;
58		this.isDblQuantity = false;
59		this.canBuy = true;
60		this.isGift = false;
61		// this.canSubscription = true;
62		this.currentIsSet = false;
63		this.updateViewedCount = false;
64
65		this.currentPriceMode = '';
66		this.currentPrices = [];
67		this.currentPriceSelected = 0;
68		this.currentQuantityRanges = [];
69		this.currentQuantityRangeSelected = 0;
70
71		this.precision = 6;
72		this.precisionFactor = Math.pow(10, this.precision);
73
74		this.visual = {};
75		this.basketMode = '';
76		this.product = {
77			checkQuantity: false,
78			maxQuantity: 0,
79			stepQuantity: 1,
80			startQuantity: 1,
81			isDblQuantity: false,
82			canBuy: true,
83			// canSubscription: true,
84			name: '',
85			pict: {},
86			id: 0,
87			addUrl: '',
88			buyUrl: '',
89			slider: {},
90			sliderCount: 0,
91			useSlider: false,
92			sliderPict: []
93		};
94		this.mess = {};
95
96		this.basketData = {
97			useProps: false,
98			emptyProps: false,
99			quantity: 'quantity',
100			props: 'prop',
101			basketUrl: '',
102			sku_props: '',
103			sku_props_var: 'basket_props',
104			add_url: '',
105			buy_url: ''
106		};
107
108		this.defaultPict = {
109			preview: null,
110			detail: null
111		};
112
113		this.offers = [];
114		this.offerNum = 0;
115		this.treeProps = [];
116		this.selectedValues = {};
117
118		this.mouseTimer = null;
119		this.isTouchDevice = BX.hasClass(document.documentElement, 'bx-touch');
120		this.touch = null;
121		this.slider = {
122			interval: null,
123			progress: null,
124			paused: null,
125			controls: []
126		};
127
128		this.quantityDelay = null;
129		this.quantityTimer = null;
130
131		this.obProduct = null;
132		this.obQuantity = null;
133		this.obQuantityUp = null;
134		this.obQuantityDown = null;
135		this.obPrice = {
136			price: null,
137			full: null,
138			discount: null,
139			percent: null,
140			total: null
141		};
142		this.obTree = null;
143		this.obPriceRanges = null;
144		this.obBuyBtn = null;
145		this.obAddToBasketBtn = null;
146		this.obBasketActions = null;
147		this.obNotAvail = null;
148		this.obSubscribe = null;
149		this.obSkuProps = null;
150		this.obDescription = null;
151		this.obMainSkuProps = null;
152		// this.obBigSlider = null;
153		this.obMeasure = null;
154		this.obQuantityLimit = {
155			all: null,
156			value: null
157		};
158		this.obCompare = null;
159		// this.obTabsPanel = null;
160
161		this.node = {};
162		// top panel small card
163		// this.smallCardNodes = {};
164
165		this.magnify = {
166			enabled: false,
167			obBigImg: null,
168			// obBigSlider: null,
169			height: 0,
170			width: 0,
171			timer: 0
172		};
173		this.currentImg = {
174			id: 0,
175			src: '',
176			width: 0,
177			height: 0
178		};
179		this.viewedCounter = {
180			path: '/bitrix/components/bitrix/catalog.element/ajax.php',
181			params: {
182				AJAX: 'Y',
183				SITE_ID: '',
184				PRODUCT_ID: 0,
185				PARENT_ID: 0
186			}
187		};
188
189		// this.obPopupWin = null;
190		this.basketUrl = '';
191		this.basketParams = {};
192
193		this.errorCode = 0;
194
195		if (typeof arParams === 'object') {
196			this.params = arParams;
197			this.initConfig();
198
199			if (this.params.MESS) {
200				this.mess = this.params.MESS;
201			}
202
203
204			switch (this.productType) {
205				case 0: // no catalog
206				case 1: // product
207				case 2: // set
208					this.initProductData();
209					break;
210				case 3: // sku
211					this.initOffersData();
212					break;
213				default:
214					this.errorCode = -1;
215			}
216
217			this.initBasketData();
218			// this.initCompareData();
219		}
220
221
222
223		if (this.errorCode === 0) {
224			BX.ready(BX.delegate(this.init, this));
225
226		}
227
228		this.params = {};
229
230		// BX.addCustomEvent('onSaleProductIsGift', BX.delegate(this.onSaleProductIsGift, this));
231		// BX.addCustomEvent('onSaleProductIsNotGift', BX.delegate(this.onSaleProductIsNotGift, this));
232	};
233
234	window.JCCatalogElement.prototype = {
235
236		getEntity: function (parent, entity, additionalFilter) {
237			if (!parent || !entity)
238				return null;
239
240			additionalFilter = additionalFilter || '';
241
242			return parent.querySelector(additionalFilter + '[data-entity="' + entity + '"]');
243		},
244
245		getEntities: function (parent, entity, additionalFilter) {
246			if (!parent || !entity)
247				return { length: 0 };
248
249			additionalFilter = additionalFilter || '';
250
251			return parent.querySelectorAll(additionalFilter + '[data-entity="' + entity + '"]');
252		},
253
254		setOffer: function (offerNum) {
255			this.offerNum = parseInt(offerNum);
256			this.setCurrent();
257		},
258
259		init: function () {
260
261			var i = 0,
262				j = 0,
263				treeItems = null;
264
265			this.obProduct = BX(this.visual.ID);
266			if (!this.obProduct) {
267				this.errorCode = -1;
268			}
269
270			if (this.config.showPrice) {
271				this.obPrice.price = BX(this.visual.PRICE_ID);
272				if (!this.obPrice.price && this.config.useCatalog) {
273					this.errorCode = -16;
274				}
275				else {
276					this.obPrice.total = BX(this.visual.PRICE_TOTAL);
277
278					if (this.config.showOldPrice) {
279						this.obPrice.full = BX(this.visual.OLD_PRICE_ID);
280						// this.obPrice.discount = BX(this.visual.DISCOUNT_PRICE_ID);
281
282						if (!this.obPrice.full
283							// || !this.obPrice.discount
284						) {
285							this.config.showOldPrice = false;
286						}
287					}
288
289					if (this.config.showPercent) {
290						this.obPrice.percent = BX(this.visual.DISCOUNT_PERCENT_ID);
291						if (!this.obPrice.percent) {
292							this.config.showPercent = false;
293						}
294					}
295				}
296
297				this.obBasketActions = BX(this.visual.BASKET_ACTIONS_ID);
298				if (this.obBasketActions) {
299					if (BX.util.in_array('BUY', this.config.basketAction)) {
300						this.obBuyBtn = BX(this.visual.BUY_LINK);
301					}
302
303					if (BX.util.in_array('ADD', this.config.basketAction)) {
304						this.obAddToBasketBtn = BX(this.visual.ADD_BASKET_LINK);
305					}
306				}
307				this.obNotAvail = BX(this.visual.NOT_AVAILABLE_MESS);
308			}
309
310			if (this.config.showQuantity) {
311				this.obQuantity = BX(this.visual.QUANTITY_ID);
312				this.node.quantity = this.getEntity(this.obProduct, 'quantity-block');
313				if (this.visual.QUANTITY_UP_ID) {
314					this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID);
315				}
316
317				if (this.visual.QUANTITY_DOWN_ID) {
318					this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID);
319				}
320			}
321
322			if (this.productType === 3) {
323				if (this.visual.TREE_ID) {
324					this.obTree = BX(this.visual.TREE_ID);
325					if (!this.obTree) {
326						this.errorCode = -256;
327					}
328				}
329
330				if (this.visual.QUANTITY_MEASURE) {
331					this.obMeasure = BX(this.visual.QUANTITY_MEASURE);
332				}
333
334				if (this.visual.QUANTITY_LIMIT && this.config.showMaxQuantity !== 'N') {
335					this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT);
336					if (this.obQuantityLimit.all) {
337						this.obQuantityLimit.value = this.getEntity(this.obQuantityLimit.all, 'quantity-limit-value');
338						if (!this.obQuantityLimit.value) {
339							this.obQuantityLimit.all = null;
340						}
341					}
342				}
343
344				if (this.config.usePriceRanges) {
345					this.obPriceRanges = this.getEntity(this.obProduct, 'price-ranges-block');
346				}
347			}
348
349			if (this.config.showSkuProps) {
350				this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV);
351				this.obMainSkuProps = BX(this.visual.DISPLAY_MAIN_PROP_DIV);
352			}
353
354			if (this.config.showSkuDescription === 'Y') {
355				this.obDescription = BX(this.visual.DESCRIPTION_ID);
356			}
357
358
359			// if (this.config.useCompare) {
360			// 	this.obCompare = BX(this.visual.COMPARE_LINK);
361			// }
362
363			// if (this.config.useSubscribe) {
364			// 	this.obSubscribe = BX(this.visual.SUBSCRIBE_LINK);
365			// }
366
367			// this.obTabs = BX(this.visual.TABS_ID);
368			// this.obTabContainers = BX(this.visual.TAB_CONTAINERS_ID);
369			// this.obTabsPanel = BX(this.visual.TABS_PANEL_ID);
370
371			// this.smallCardNodes.panel = BX(this.visual.SMALL_CARD_PANEL_ID);
372			// if (this.smallCardNodes.panel) {
373			// 	this.smallCardNodes.picture = this.getEntity(this.smallCardNodes.panel, 'panel-picture');
374			// 	this.smallCardNodes.title = this.getEntity(this.smallCardNodes.panel, 'panel-title');
375			// 	this.smallCardNodes.price = this.getEntity(this.smallCardNodes.panel, 'panel-price');
376			// 	this.smallCardNodes.sku = this.getEntity(this.smallCardNodes.panel, 'panel-sku-container');
377			// 	this.smallCardNodes.oldPrice = this.getEntity(this.smallCardNodes.panel, 'panel-old-price');
378			// 	this.smallCardNodes.buyButton = this.getEntity(this.smallCardNodes.panel, 'panel-buy-button');
379			// 	this.smallCardNodes.addButton = this.getEntity(this.smallCardNodes.panel, 'panel-add-button');
380			// 	this.smallCardNodes.notAvailableButton = this.getEntity(this.smallCardNodes.panel, 'panel-not-available-button');
381			// 	this.smallCardNodes.aligner = this.getEntity(this.obProduct, 'main-button-container');
382			// }
383
384			// this.initPopup();
385			// this.initTabs();
386
387			// if (this.smallCardNodes.panel) {
388			// 	this.smallCardNodes.picture && BX.bind(this.smallCardNodes.picture.parentNode, 'click', BX.proxy(this.scrollToProduct, this));
389			// 	this.smallCardNodes.title && BX.bind(this.smallCardNodes.title, 'click', BX.proxy(this.scrollToProduct, this));
390			// 	this.smallCardNodes.sku && BX.bind(this.smallCardNodes.sku, 'click', BX.proxy(this.scrollToProduct, this));
391			// }
392
393			// if (this.obTabsPanel || this.smallCardNodes.panel) {
394			// 	this.checkTopPanels();
395			// 	BX.bind(window, 'scroll', BX.proxy(this.checkTopPanels, this));
396			// }
397			if (this.errorCode === 0) {
398				// product slider events
399
400				if (this.config.showQuantity) {
401					var startEventName = this.isTouchDevice ? 'touchstart' : 'mousedown';
402					var endEventName = this.isTouchDevice ? 'touchend' : 'mouseup';
403
404					if (this.obQuantityUp) {
405						BX.bind(this.obQuantityUp, startEventName, BX.proxy(this.startQuantityInterval, this));
406						BX.bind(this.obQuantityUp, endEventName, BX.proxy(this.clearQuantityInterval, this));
407						BX.bind(this.obQuantityUp, 'mouseout', BX.proxy(this.clearQuantityInterval, this));
408						BX.bind(this.obQuantityUp, 'click', BX.delegate(this.quantityUp, this));
409					}
410
411					if (this.obQuantityDown) {
412						BX.bind(this.obQuantityDown, startEventName, BX.proxy(this.startQuantityInterval, this));
413						BX.bind(this.obQuantityDown, endEventName, BX.proxy(this.clearQuantityInterval, this));
414						BX.bind(this.obQuantityDown, 'mouseout', BX.proxy(this.clearQuantityInterval, this));
415						BX.bind(this.obQuantityDown, 'click', BX.delegate(this.quantityDown, this));
416					}
417
418					if (this.obQuantity) {
419						BX.bind(this.obQuantity, 'change', BX.delegate(this.quantityChange, this));
420					}
421				}
422
423				switch (this.productType) {
424					case 0: // no catalog
425					case 1: // product
426					case 2: // set
427						this.checkQuantityControls();
428						// this.setAnalyticsDataLayer('showDetail');
429						break;
430					case 3: // sku
431						treeItems = this.obTree.querySelectorAll('li');
432						for (i = 0; i < treeItems.length; i++) {
433							BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this));
434						}
435
436						// for (i = 0; i < this.offers.length; i++) {
437						// 	this.offers[i].SLIDER_COUNT = parseInt(this.offers[i].SLIDER_COUNT, 10) || 0;
438
439						// 	if (this.offers[i].SLIDER_COUNT === 0) {
440						// 		this.slider.controls[i] = {
441						// 			ID: '',
442						// 			COUNT: this.offers[i].SLIDER_COUNT,
443						// 			ITEMS: []
444						// 		};
445						// 	}
446						// 	else {
447						// 		for (j = 0; j < this.offers[i].SLIDER.length; j++) {
448						// 			this.offers[i].SLIDER[j].WIDTH = parseInt(this.offers[i].SLIDER[j].WIDTH, 10);
449						// 			this.offers[i].SLIDER[j].HEIGHT = parseInt(this.offers[i].SLIDER[j].HEIGHT, 10);
450						// 		}
451
452						// 		this.slider.controls[i] = {
453						// 			ID: this.visual.SLIDER_CONT_OF_ID + this.offers[i].ID,
454						// 			OFFER_ID: this.offers[i].ID,
455						// 			CONT: BX(this.visual.SLIDER_CONT_OF_ID + this.offers[i].ID),
456						// 			COUNT: this.offers[i].SLIDER_COUNT
457						// 		};
458
459						// 		this.slider.controls[i].ITEMS = this.getEntities(this.slider.controls[i].CONT, 'slider-control');
460						// 		for (j = 0; j < this.slider.controls[i].ITEMS.length; j++) {
461						// 			BX.bind(this.slider.controls[i].ITEMS[j], 'mouseenter', BX.delegate(this.onSliderControlHover, this));
462						// 			BX.bind(this.slider.controls[i].ITEMS[j], 'mouseleave', BX.delegate(this.onSliderControlLeave, this));
463						// 			BX.bind(this.slider.controls[i].ITEMS[j], 'click', BX.delegate(this.selectSliderImg, this));
464						// 		}
465						// 	}
466						// }
467
468						this.setCurrent();
469						break;
470				}
471
472				this.obBuyBtn && BX.bind(this.obBuyBtn, 'click', BX.proxy(this.buyBasket, this));
473				// this.smallCardNodes.buyButton && BX.bind(this.smallCardNodes.buyButton, 'click', BX.proxy(this.buyBasket, this));
474
475				this.obAddToBasketBtn && BX.bind(this.obAddToBasketBtn, 'click', BX.proxy(this.add2Basket, this));
476				// this.smallCardNodes.addButton && BX.bind(this.smallCardNodes.addButton, 'click', BX.proxy(this.add2Basket, this));
477
478				// if (this.obCompare) {
479				// 	BX.bind(this.obCompare, 'click', BX.proxy(this.compare, this));
480				// 	BX.addCustomEvent('onCatalogDeleteCompare', BX.proxy(this.checkDeletedCompare, this));
481				// }
482
483				this.checkDetailText();
484			}
485		},
486
487		initConfig: function () {
488
489			if (this.params.PRODUCT_TYPE) {
490				// this.productType = parseInt(this.params.PRODUCT_TYPE, 10);
491				this.productType = 1;
492			}
493
494			if (this.params.CONFIG.USE_CATALOG !== 'undefined' && BX.type.isBoolean(this.params.CONFIG.USE_CATALOG)) {
495				this.config.useCatalog = this.params.CONFIG.USE_CATALOG;
496			}
497
498			this.config.showQuantity = this.params.CONFIG.SHOW_QUANTITY;
499			this.config.showPrice = this.params.CONFIG.SHOW_PRICE;
500			this.config.showPercent = this.params.CONFIG.SHOW_DISCOUNT_PERCENT;
501			this.config.showOldPrice = this.params.CONFIG.SHOW_OLD_PRICE;
502			this.config.showSkuProps = this.params.CONFIG.SHOW_SKU_PROPS;
503			this.config.showOfferGroup = this.params.CONFIG.OFFER_GROUP;
504			// this.config.useCompare = this.params.CONFIG.DISPLAY_COMPARE;
505			// this.config.useStickers = this.params.CONFIG.USE_STICKERS;
506			// this.config.useSubscribe = this.params.CONFIG.USE_SUBSCRIBE;
507			this.config.showMaxQuantity = this.params.CONFIG.SHOW_MAX_QUANTITY;
508			this.config.relativeQuantityFactor = parseInt(this.params.CONFIG.RELATIVE_QUANTITY_FACTOR);
509			this.config.usePriceRanges = this.params.CONFIG.USE_PRICE_COUNT;
510			this.config.showSkuDescription = this.params.CONFIG.SHOW_SKU_DESCRIPTION;
511			this.config.displayPreviewTextMode = this.params.CONFIG.DISPLAY_PREVIEW_TEXT_MODE;
512
513			// if (this.params.CONFIG.MAIN_PICTURE_MODE) {
514			// 	// this.config.usePopup = BX.util.in_array('POPUP', this.params.CONFIG.MAIN_PICTURE_MODE);
515			// 	// this.config.useMagnifier = BX.util.in_array('MAGNIFIER', this.params.CONFIG.MAIN_PICTURE_MODE);
516			// }
517
518			if (this.params.CONFIG.ADD_TO_BASKET_ACTION) {
519				this.config.basketAction = this.params.CONFIG.ADD_TO_BASKET_ACTION;
520			}
521
522			this.config.showClosePopup = this.params.CONFIG.SHOW_CLOSE_POPUP;
523			this.config.templateTheme = this.params.CONFIG.TEMPLATE_THEME || '';
524			// this.config.showSlider = this.params.CONFIG.SHOW_SLIDER === 'Y';
525
526			// if (this.config.showSlider && !this.isTouchDevice) {
527			// 	this.config.sliderInterval = parseInt(this.params.CONFIG.SLIDER_INTERVAL) || 5000;
528			// }
529			// else {
530			// 	this.config.sliderInterval = false;
531			// }
532
533			this.config.useEnhancedEcommerce = this.params.CONFIG.USE_ENHANCED_ECOMMERCE === 'Y';
534			this.config.dataLayerName = this.params.CONFIG.DATA_LAYER_NAME;
535			this.config.brandProperty = this.params.CONFIG.BRAND_PROPERTY;
536
537			this.config.alt = this.params.CONFIG.ALT || '';
538			this.config.title = this.params.CONFIG.TITLE || '';
539
540			this.config.magnifierZoomPercent = parseInt(this.params.CONFIG.MAGNIFIER_ZOOM_PERCENT) || 200;
541
542			if (!this.params.VISUAL || typeof this.params.VISUAL !== 'object' || !this.params.VISUAL.ID) {
543				this.errorCode = -1;
544				return;
545			}
546
547			this.visual = this.params.VISUAL;
548		},
549
550		initProductData: function () {
551			var j = 0;
552
553			if (this.params.PRODUCT && typeof this.params.PRODUCT === 'object') {
554				if (this.config.showPrice) {
555					this.currentPriceMode = this.params.PRODUCT.ITEM_PRICE_MODE;
556					this.currentPrices = this.params.PRODUCT.ITEM_PRICES;
557					this.currentPriceSelected = this.params.PRODUCT.ITEM_PRICE_SELECTED;
558					this.currentQuantityRanges = this.params.PRODUCT.ITEM_QUANTITY_RANGES;
559					this.currentQuantityRangeSelected = this.params.PRODUCT.ITEM_QUANTITY_RANGE_SELECTED;
560				}
561
562				if (this.config.showQuantity) {
563					this.product.checkQuantity = this.params.PRODUCT.CHECK_QUANTITY;
564					this.product.isDblQuantity = this.params.PRODUCT.QUANTITY_FLOAT;
565
566					if (this.product.checkQuantity) {
567						this.product.maxQuantity = this.product.isDblQuantity
568							? parseFloat(this.params.PRODUCT.MAX_QUANTITY)
569							: parseInt(this.params.PRODUCT.MAX_QUANTITY, 10);
570					}
571
572					this.product.stepQuantity = this.product.isDblQuantity
573						? parseFloat(this.params.PRODUCT.STEP_QUANTITY)
574						: parseInt(this.params.PRODUCT.STEP_QUANTITY, 10);
575					this.checkQuantity = this.product.checkQuantity;
576					this.isDblQuantity = this.product.isDblQuantity;
577					this.stepQuantity = this.product.stepQuantity;
578					this.maxQuantity = this.product.maxQuantity;
579					this.minQuantity = this.currentPriceMode === 'Q' ? parseFloat(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity;
580
581					if (this.isDblQuantity) {
582						this.stepQuantity = Math.round(this.stepQuantity * this.precisionFactor) / this.precisionFactor;
583					}
584				}
585
586				this.product.canBuy = this.params.PRODUCT.CAN_BUY;
587				// this.canSubscription = this.product.canSubscription = this.params.PRODUCT.SUBSCRIPTION;
588
589				this.product.name = this.params.PRODUCT.NAME;
590				this.product.pict = this.params.PRODUCT.PICT;
591				this.product.id = this.params.PRODUCT.ID;
592				this.product.category = this.params.PRODUCT.CATEGORY;
593
594
595				if (this.params.PRODUCT.ADD_URL) {
596					this.product.addUrl = this.params.PRODUCT.ADD_URL;
597				}
598
599				if (this.params.PRODUCT.BUY_URL) {
600					this.product.buyUrl = this.params.PRODUCT.BUY_URL;
601				}
602
603
604				this.currentIsSet = true;
605			}
606			else {
607				this.errorCode = -1;
608			}
609		},
610
611		initOffersData: function () {
612			if (this.params.OFFERS && BX.type.isArray(this.params.OFFERS)) {
613				this.offers = this.params.OFFERS;
614				this.offerNum = 0;
615
616				if (this.params.OFFER_SELECTED) {
617					this.offerNum = parseInt(this.params.OFFER_SELECTED, 10) || 0;
618				}
619
620				if (this.params.TREE_PROPS) {
621					this.treeProps = this.params.TREE_PROPS;
622				}
623
624				if (this.params.DEFAULT_PICTURE) {
625					this.defaultPict.preview = this.params.DEFAULT_PICTURE.PREVIEW_PICTURE;
626					this.defaultPict.detail = this.params.DEFAULT_PICTURE.DETAIL_PICTURE;
627				}
628
629				if (this.params.PRODUCT && typeof this.params.PRODUCT === 'object') {
630					this.product.id = parseInt(this.params.PRODUCT.ID, 10);
631					this.product.name = this.params.PRODUCT.NAME;
632					this.product.category = this.params.PRODUCT.CATEGORY;
633					this.product.detailText = this.params.PRODUCT.DETAIL_TEXT;
634					this.product.detailTextType = this.params.PRODUCT.DETAIL_TEXT_TYPE;
635					this.product.previewText = this.params.PRODUCT.PREVIEW_TEXT;
636					this.product.previewTextType = this.params.PRODUCT.PREVIEW_TEXT_TYPE;
637				}
638			}
639			else {
640				this.errorCode = -1;
641			}
642		},
643
644		initBasketData: function () {
645
646			if (this.params.BASKET && typeof this.params.BASKET === 'object') {
647				if (this.productType === 1 || this.productType === 2) {
648					this.basketData.useProps = this.params.BASKET.ADD_PROPS;
649					this.basketData.emptyProps = this.params.BASKET.EMPTY_PROPS;
650				}
651
652				if (this.params.BASKET.QUANTITY) {
653					this.basketData.quantity = this.params.BASKET.QUANTITY;
654				}
655
656				if (this.params.BASKET.PROPS) {
657					this.basketData.props = this.params.BASKET.PROPS;
658				}
659
660				if (this.params.BASKET.BASKET_URL) {
661					this.basketData.basketUrl = this.params.BASKET.BASKET_URL;
662				}
663
664				if (this.productType === 3) {
665					if (this.params.BASKET.SKU_PROPS) {
666						this.basketData.sku_props = this.params.BASKET.SKU_PROPS;
667					}
668				}
669
670				if (this.params.BASKET.ADD_URL_TEMPLATE) {
671					this.basketData.add_url = this.params.BASKET.ADD_URL_TEMPLATE;
672				}
673
674				if (this.params.BASKET.BUY_URL_TEMPLATE) {
675					this.basketData.buy_url = this.params.BASKET.BUY_URL_TEMPLATE;
676				}
677
678				if (this.basketData.add_url === '' && this.basketData.buy_url === '') {
679					this.errorCode = -1024;
680				}
681			}
682		},
683		checkDetailText: function () {
684
685			var box = document.querySelector('[data-entity="detail-text"]');
686
687			if (BX.height(box) > 200) {
688				var linkMore = BX.create('a', {
689					attrs: { className: 'cElement__dTextMore' },
690					text: BX.message('DETAIL_TEXT_MORE_SHOW')
691				});
692
693				BX.addClass(box, '__hidden');
694				BX.insertAfter(linkMore, box);
695
696				BX.bind(linkMore, 'click', BX.proxy(this.checkDetailTextLink, this));
697			}
698		},
699		checkDetailTextLink: function (e) {
700			BX.PreventDefault(e);
701			var a = e.target,
702				box = BX.findPreviousSibling(a, { tagName: 'div' });
703
704			if (BX.hasClass(a, 'selected')) {
705				BX.addClass(box, '__hidden');
706				BX.removeClass(a, 'selected');
707				BX.adjust(a, { text: BX.message('DETAIL_TEXT_MORE_SHOW') });
708
709			}
710			else {
711				BX.addClass(a, 'selected');
712				BX.removeClass(box, '__hidden');
713				BX.adjust(a, { text: BX.message('DETAIL_TEXT_MORE_HIDE') });
714			}
715		},
716
717		startQuantityInterval: function () {
718			var target = BX.proxy_context;
719			var func = target.id === this.visual.QUANTITY_DOWN_ID
720				? BX.proxy(this.quantityDown, this)
721				: BX.proxy(this.quantityUp, this);
722
723			this.quantityDelay = setTimeout(
724				BX.delegate(function () {
725					this.quantityTimer = setInterval(func, 150);
726				}, this),
727				300
728			);
729		},
730
731		clearQuantityInterval: function () {
732			clearTimeout(this.quantityDelay);
733			clearInterval(this.quantityTimer);
734		},
735
736		quantityUp: function () {
737			var curValue = 0,
738				boolSet = true;
739
740			if (this.errorCode === 0 && this.config.showQuantity && this.canBuy && !this.isGift) {
741				curValue = this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10);
742				if (!isNaN(curValue)) {
743					curValue += this.stepQuantity;
744
745					curValue = this.checkQuantityRange(curValue, 'up');
746
747					if (this.checkQuantity && curValue > this.maxQuantity) {
748						boolSet = false;
749					}
750
751					if (boolSet) {
752						if (this.isDblQuantity) {
753							curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
754						}
755
756						this.obQuantity.value = curValue;
757
758						this.setPrice();
759					}
760				}
761			}
762		},
763
764		quantityDown: function () {
765			var curValue = 0,
766				boolSet = true;
767
768			if (this.errorCode === 0 && this.config.showQuantity && this.canBuy && !this.isGift) {
769				curValue = (this.isDblQuantity ? parseFloat(this.obQuantity.value) : parseInt(this.obQuantity.value, 10));
770				if (!isNaN(curValue)) {
771					curValue -= this.stepQuantity;
772
773					curValue = this.checkQuantityRange(curValue, 'down');
774
775					if (curValue < this.minQuantity) {
776						boolSet = false;
777					}
778
779					if (boolSet) {
780						if (this.isDblQuantity) {
781							curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
782						}
783
784						this.obQuantity.value = curValue;
785
786						this.setPrice();
787					}
788				}
789			}
790		},
791
792		quantityChange: function () {
793			var curValue = 0,
794				intCount;
795
796			if (this.errorCode === 0 && this.config.showQuantity) {
797				if (this.canBuy) {
798					curValue = this.isDblQuantity ? parseFloat(this.obQuantity.value) : Math.round(this.obQuantity.value);
799					if (!isNaN(curValue)) {
800						curValue = this.checkQuantityRange(curValue);
801
802						if (this.checkQuantity) {
803							if (curValue > this.maxQuantity) {
804								curValue = this.maxQuantity;
805							}
806						}
807
808						this.checkPriceRange(curValue);
809
810						intCount = Math.floor(
811							Math.round(curValue * this.precisionFactor / this.stepQuantity) / this.precisionFactor
812						) || 1;
813						curValue = (intCount <= 1 ? this.stepQuantity : intCount * this.stepQuantity);
814						curValue = Math.round(curValue * this.precisionFactor) / this.precisionFactor;
815
816						if (curValue < this.minQuantity) {
817							curValue = this.minQuantity;
818						}
819
820						this.obQuantity.value = curValue;
821					}
822					else {
823						this.obQuantity.value = this.minQuantity;
824					}
825				}
826				else {
827					this.obQuantity.value = this.minQuantity;
828				}
829
830				this.setPrice();
831			}
832		},
833
834		quantitySet: function (index) {
835			var strLimit, resetQuantity;
836
837			var newOffer = this.offers[index],
838				oldOffer = this.offers[this.offerNum];
839
840			if (this.errorCode === 0) {
841				this.canBuy = newOffer.CAN_BUY;
842
843				this.currentPriceMode = newOffer.ITEM_PRICE_MODE;
844				this.currentPrices = newOffer.ITEM_PRICES;
845				this.currentPriceSelected = newOffer.ITEM_PRICE_SELECTED;
846				this.currentQuantityRanges = newOffer.ITEM_QUANTITY_RANGES;
847				this.currentQuantityRangeSelected = newOffer.ITEM_QUANTITY_RANGE_SELECTED;
848
849				if (this.canBuy) {
850					this.node.quantity && BX.style(this.node.quantity, 'display', '');
851
852					this.obBasketActions && BX.style(this.obBasketActions, 'display', '');
853					// this.smallCardNodes.buyButton && BX.style(this.smallCardNodes.buyButton, 'display', '');
854					// this.smallCardNodes.addButton && BX.style(this.smallCardNodes.addButton, 'display', '');
855
856					this.obNotAvail && BX.style(this.obNotAvail, 'display', 'none');
857					// this.smallCardNodes.notAvailableButton && BX.style(this.smallCardNodes.notAvailableButton, 'display', 'none');
858
859					this.obSubscribe && BX.style(this.obSubscribe, 'display', 'none');
860				}
861				else {
862					this.node.quantity && BX.style(this.node.quantity, 'display', 'none');
863
864					this.obBasketActions && BX.style(this.obBasketActions, 'display', 'none');
865					// this.smallCardNodes.buyButton && BX.style(this.smallCardNodes.buyButton, 'display', 'none');
866					// this.smallCardNodes.addButton && BX.style(this.smallCardNodes.addButton, 'display', 'none');
867
868					this.obNotAvail && BX.style(this.obNotAvail, 'display', '');
869					// this.smallCardNodes.notAvailableButton && BX.style(this.smallCardNodes.notAvailableButton, 'display', '');
870
871					if (this.obSubscribe) {
872						if (newOffer.CATALOG_SUBSCRIBE === 'Y') {
873							BX.style(this.obSubscribe, 'display', '');
874							this.obSubscribe.setAttribute('data-item', newOffer.ID);
875							BX(this.visual.SUBSCRIBE_LINK + '_hidden').click();
876						}
877						else {
878							BX.style(this.obSubscribe, 'display', 'none');
879						}
880					}
881				}
882
883				this.isDblQuantity = newOffer.QUANTITY_FLOAT;
884				this.checkQuantity = newOffer.CHECK_QUANTITY;
885
886				if (this.isDblQuantity) {
887					this.stepQuantity = Math.round(parseFloat(newOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor;
888					this.maxQuantity = parseFloat(newOffer.MAX_QUANTITY);
889					this.minQuantity = this.currentPriceMode === 'Q' ? parseFloat(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity;
890				}
891				else {
892					this.stepQuantity = parseInt(newOffer.STEP_QUANTITY, 10);
893					this.maxQuantity = parseInt(newOffer.MAX_QUANTITY, 10);
894					this.minQuantity = this.currentPriceMode === 'Q' ? parseInt(this.currentPrices[this.currentPriceSelected].MIN_QUANTITY) : this.stepQuantity;
895				}
896
897				if (this.config.showQuantity) {
898					var isDifferentMinQuantity = oldOffer.ITEM_PRICES.length
899						&& oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED]
900						&& oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED].MIN_QUANTITY != this.minQuantity;
901
902					if (this.isDblQuantity) {
903						resetQuantity = Math.round(parseFloat(oldOffer.STEP_QUANTITY) * this.precisionFactor) / this.precisionFactor !== this.stepQuantity
904							|| isDifferentMinQuantity
905							|| oldOffer.MEASURE !== newOffer.MEASURE
906							|| (
907								this.checkQuantity
908								&& parseFloat(oldOffer.MAX_QUANTITY) > this.maxQuantity
909								&& parseFloat(this.obQuantity.value) > this.maxQuantity
910							);
911					}
912					else {
913						resetQuantity = parseInt(oldOffer.STEP_QUANTITY, 10) !== this.stepQuantity
914							|| isDifferentMinQuantity
915							|| oldOffer.MEASURE !== newOffer.MEASURE
916							|| (
917								this.checkQuantity
918								&& parseInt(oldOffer.MAX_QUANTITY, 10) > this.maxQuantity
919								&& parseInt(this.obQuantity.value, 10) > this.maxQuantity
920							);
921					}
922
923					this.obQuantity.disabled = !this.canBuy;
924
925					if (resetQuantity) {
926						this.obQuantity.value = this.minQuantity;
927					}
928
929					if (this.obMeasure) {
930						if (newOffer.MEASURE) {
931							BX.adjust(this.obMeasure, { html: newOffer.MEASURE });
932						}
933						else {
934							BX.adjust(this.obMeasure, { html: '' });
935						}
936					}
937				}
938
939				if (this.obQuantityLimit.all) {
940					if (!this.checkQuantity || this.maxQuantity == 0) {
941						BX.adjust(this.obQuantityLimit.value, { html: '' });
942						BX.adjust(this.obQuantityLimit.all, { style: { display: 'none' } });
943					}
944					else {
945						if (this.config.showMaxQuantity === 'M') {
946							strLimit = (this.maxQuantity / this.stepQuantity >= this.config.relativeQuantityFactor)
947								? BX.message('RELATIVE_QUANTITY_MANY')
948								: BX.message('RELATIVE_QUANTITY_FEW');
949						}
950						else {
951							strLimit = this.maxQuantity;
952
953							if (newOffer.MEASURE) {
954								strLimit += (' ' + newOffer.MEASURE);
955							}
956						}
957
958						BX.adjust(this.obQuantityLimit.value, { html: strLimit });
959						BX.adjust(this.obQuantityLimit.all, { style: { display: '' } });
960					}
961				}
962
963				if (this.config.usePriceRanges && this.obPriceRanges) {
964					if (
965						this.currentPriceMode === 'Q'
966						&& newOffer.PRICE_RANGES_HTML
967					) {
968						var rangesBody = this.getEntity(this.obPriceRanges, 'price-ranges-body'),
969							rangesRatioHeader = this.getEntity(this.obPriceRanges, 'price-ranges-ratio-header');
970
971						if (rangesBody) {
972							rangesBody.innerHTML = newOffer.PRICE_RANGES_HTML;
973						}
974
975						if (rangesRatioHeader) {
976							rangesRatioHeader.innerHTML = newOffer.PRICE_RANGES_RATIO_HTML;
977						}
978
979						this.obPriceRanges.style.display = '';
980					}
981					else {
982						this.obPriceRanges.style.display = 'none';
983					}
984
985				}
986			}
987		},
988
989		selectOfferProp: function () {
990			var i = 0,
991				strTreeValue = '',
992				arTreeItem = [],
993				rowItems = null,
994				target = BX.proxy_context,
995				smallCardItem;
996
997			if (target && target.hasAttribute('data-treevalue')) {
998				if (BX.hasClass(target, 'selected'))
999					return;
1000
1001				if (typeof document.activeElement === 'object') {
1002					document.activeElement.blur();
1003				}
1004
1005				strTreeValue = target.getAttribute('data-treevalue');
1006				arTreeItem = strTreeValue.split('_');
1007				this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
1008				rowItems = BX.findChildren(target.parentNode, { tagName: 'li' }, false);
1009
1010				if (rowItems && rowItems.length) {
1011					for (i = 0; i < rowItems.length; i++) {
1012						BX.removeClass(rowItems[i], 'selected');
1013					}
1014				}
1015
1016				BX.addClass(target, 'selected');
1017
1018				// if (this.smallCardNodes.panel) {
1019				// 	smallCardItem = this.smallCardNodes.panel.querySelector('[data-treevalue="' + strTreeValue + '"]');
1020				// 	if (smallCardItem) {
1021				// 		rowItems = this.smallCardNodes.panel.querySelectorAll('[data-sku-line="' + smallCardItem.getAttribute('data-sku-line') + '"]');
1022				// 		for (i = 0; i < rowItems.length; i++) {
1023				// 			rowItems[i].style.display = 'none';
1024				// 		}
1025
1026				// 		smallCardItem.style.display = '';
1027				// 	}
1028				// }
1029			}
1030		},
1031
1032		searchOfferPropIndex: function (strPropID, strPropValue) {
1033			var strName = '',
1034				arShowValues = false,
1035				arCanBuyValues = [],
1036				allValues = [],
1037				index = -1,
1038				i, j,
1039				arFilter = {},
1040				tmpFilter = [];
1041
1042			for (i = 0; i < this.treeProps.length; i++) {
1043				if (this.treeProps[i].ID === strPropID) {
1044					index = i;
1045					break;
1046				}
1047			}
1048
1049			if (index > -1) {
1050				for (i = 0; i < index; i++) {
1051					strName = 'PROP_' + this.treeProps[i].ID;
1052					arFilter[strName] = this.selectedValues[strName];
1053				}
1054
1055				strName = 'PROP_' + this.treeProps[index].ID;
1056				arFilter[strName] = strPropValue;
1057
1058				for (i = index + 1; i < this.treeProps.length; i++) {
1059					strName = 'PROP_' + this.treeProps[i].ID;
1060					arShowValues = this.getRowValues(arFilter, strName);
1061
1062					if (!arShowValues)
1063						break;
1064
1065					allValues = [];
1066
1067					if (this.config.showAbsent) {
1068						arCanBuyValues = [];
1069						tmpFilter = [];
1070						tmpFilter = BX.clone(arFilter, true);
1071
1072						for (j = 0; j < arShowValues.length; j++) {
1073							tmpFilter[strName] = arShowValues[j];
1074							allValues[allValues.length] = arShowValues[j];
1075							if (this.getCanBuy(tmpFilter))
1076								arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
1077						}
1078					}
1079					else {
1080						arCanBuyValues = arShowValues;
1081					}
1082
1083					if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues)) {
1084						arFilter[strName] = this.selectedValues[strName];
1085					}
1086					else {
1087						if (this.config.showAbsent) {
1088							arFilter[strName] = (arCanBuyValues.length ? arCanBuyValues[0] : allValues[0]);
1089						}
1090						else {
1091							arFilter[strName] = arCanBuyValues[0];
1092						}
1093					}
1094
1095					this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
1096				}
1097
1098				this.selectedValues = arFilter;
1099				this.changeInfo();
1100			}
1101		},
1102
1103		updateRow: function (intNumber, activeId, showId, canBuyId) {
1104			var i = 0,
1105				value = '',
1106				isCurrent = false,
1107				rowItems = null;
1108
1109			var lineContainer = this.getEntities(this.obTree, 'sku-line-block');
1110
1111			if (intNumber > -1 && intNumber < lineContainer.length) {
1112				rowItems = lineContainer[intNumber].querySelectorAll('li');
1113				for (i = 0; i < rowItems.length; i++) {
1114					value = rowItems[i].getAttribute('data-onevalue');
1115					isCurrent = value === activeId;
1116
1117					if (isCurrent) {
1118						BX.addClass(rowItems[i], 'selected');
1119					}
1120					else {
1121						BX.removeClass(rowItems[i], 'selected');
1122					}
1123
1124					if (BX.util.in_array(value, canBuyId)) {
1125						BX.removeClass(rowItems[i], 'notallowed');
1126					}
1127					else {
1128						BX.addClass(rowItems[i], 'notallowed');
1129					}
1130
1131					rowItems[i].style.display = BX.util.in_array(value, showId) ? '' : 'none';
1132
1133					if (isCurrent) {
1134						lineContainer[intNumber].style.display = (value == 0 && canBuyId.length == 1) ? 'none' : '';
1135					}
1136				}
1137
1138				// if (this.smallCardNodes.panel) {
1139				// 	rowItems = this.smallCardNodes.panel.querySelectorAll('[data-sku-line="' + intNumber + '"]');
1140				// 	for (i = 0; i < rowItems.length; i++) {
1141				// 		value = rowItems[i].getAttribute('data-onevalue');
1142				// 		isCurrent = value === activeId;
1143
1144				// 		if (isCurrent) {
1145				// 			rowItems[i].style.display = '';
1146				// 		}
1147				// 		else {
1148				// 			rowItems[i].style.display = 'none';
1149				// 		}
1150
1151				// 		if (BX.util.in_array(value, canBuyId)) {
1152				// 			BX.removeClass(rowItems[i], 'notallowed');
1153				// 		}
1154				// 		else {
1155				// 			BX.addClass(rowItems[i], 'notallowed');
1156				// 		}
1157
1158				// 		if (isCurrent) {
1159				// 			rowItems[i].style.display = (value == 0 && canBuyId.length == 1) ? 'none' : '';
1160				// 		}
1161				// 	}
1162				// }
1163			}
1164		},
1165
1166		getRowValues: function (arFilter, index) {
1167			var arValues = [],
1168				i = 0,
1169				j = 0,
1170				boolSearch = false,
1171				boolOneSearch = true;
1172
1173			if (arFilter.length === 0) {
1174				for (i = 0; i < this.offers.length; i++) {
1175					if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
1176						arValues[arValues.length] = this.offers[i].TREE[index];
1177					}
1178				}
1179				boolSearch = true;
1180			}
1181			else {
1182				for (i = 0; i < this.offers.length; i++) {
1183					boolOneSearch = true;
1184
1185					for (j in arFilter) {
1186						if (arFilter[j] !== this.offers[i].TREE[j]) {
1187							boolOneSearch = false;
1188							break;
1189						}
1190					}
1191
1192					if (boolOneSearch) {
1193						if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
1194							arValues[arValues.length] = this.offers[i].TREE[index];
1195						}
1196
1197						boolSearch = true;
1198					}
1199				}
1200			}
1201
1202			return (boolSearch ? arValues : false);
1203		},
1204
1205		getCanBuy: function (arFilter) {
1206			var i,
1207				j = 0,
1208				boolOneSearch = true,
1209				boolSearch = false;
1210
1211			for (i = 0; i < this.offers.length; i++) {
1212				boolOneSearch = true;
1213
1214				for (j in arFilter) {
1215					if (arFilter[j] !== this.offers[i].TREE[j]) {
1216						boolOneSearch = false;
1217						break;
1218					}
1219				}
1220
1221				if (boolOneSearch) {
1222					if (this.offers[i].CAN_BUY) {
1223						boolSearch = true;
1224						break;
1225					}
1226				}
1227			}
1228
1229			return boolSearch;
1230		},
1231
1232		setCurrent: function () {
1233			var i,
1234				j = 0,
1235				strName = '',
1236				arShowValues = false,
1237				arCanBuyValues = [],
1238				arFilter = {},
1239				tmpFilter = [],
1240				current = this.offers[this.offerNum].TREE;
1241
1242			for (i = 0; i < this.treeProps.length; i++) {
1243				strName = 'PROP_' + this.treeProps[i].ID;
1244				arShowValues = this.getRowValues(arFilter, strName);
1245
1246				if (!arShowValues)
1247					break;
1248
1249				if (BX.util.in_array(current[strName], arShowValues)) {
1250					arFilter[strName] = current[strName];
1251				}
1252				else {
1253					arFilter[strName] = arShowValues[0];
1254					this.offerNum = 0;
1255				}
1256
1257				if (this.config.showAbsent) {
1258					arCanBuyValues = [];
1259					tmpFilter = [];
1260					tmpFilter = BX.clone(arFilter, true);
1261
1262					for (j = 0; j < arShowValues.length; j++) {
1263						tmpFilter[strName] = arShowValues[j];
1264
1265						if (this.getCanBuy(tmpFilter)) {
1266							arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
1267						}
1268					}
1269				}
1270				else {
1271					arCanBuyValues = arShowValues;
1272				}
1273
1274				this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
1275			}
1276
1277			this.selectedValues = arFilter;
1278
1279			this.changeInfo();
1280		},
1281
1282		changeInfo: function () {
1283			var index = -1,
1284				j = 0,
1285				boolOneSearch = true,
1286				eventData = {
1287					currentId: (this.offerNum > -1 ? this.offers[this.offerNum].ID : 0),
1288					newId: 0
1289				};
1290
1291			var i, offerGroupNode;
1292
1293			for (i = 0; i < this.offers.length; i++) {
1294				boolOneSearch = true;
1295
1296				for (j in this.selectedValues) {
1297					if (this.selectedValues[j] !== this.offers[i].TREE[j]) {
1298						boolOneSearch = false;
1299						break;
1300					}
1301				}
1302
1303				if (boolOneSearch) {
1304					index = i;
1305					break;
1306				}
1307			}
1308
1309			if (index > -1) {
1310				if (index != this.offerNum) {
1311					this.isGift = false;
1312				}
1313
1314				// this.drawImages(this.offers[index].SLIDER);
1315				// this.checkSliderControls(this.offers[index].SLIDER_COUNT);
1316
1317				for (i = 0; i < this.offers.length; i++) {
1318					if (this.config.showOfferGroup && this.offers[i].OFFER_GROUP) {
1319						if (offerGroupNode = BX(this.visual.OFFER_GROUP + this.offers[i].ID)) {
1320							offerGroupNode.style.display = (i == index ? '' : 'none');
1321						}
1322					}
1323
1324					// if (this.slider.controls[i].ID) {
1325					// 	if (i === index) {
1326					// 		this.product.slider = this.slider.controls[i];
1327					// 		this.slider.controls[i].CONT && BX.show(this.slider.controls[i].CONT);
1328					// 	}
1329					// 	else {
1330					// 		this.slider.controls[i].CONT && BX.hide(this.slider.controls[i].CONT);
1331					// 	}
1332					// }
1333					// else if (i === index) {
1334					// 	this.product.slider = {};
1335					// }
1336				}
1337
1338				// if (this.offers[index].SLIDER_COUNT > 0) {
1339				// 	// this.setMainPict(this.offers[index].ID, this.offers[index].SLIDER[0].ID, true);
1340				// }
1341				// else {
1342				// 	this.setMainPictFromItem(index);
1343				// }
1344
1345				// if (this.offers[index].SLIDER_COUNT > 1) {
1346				// 	this.initSlider();
1347				// }
1348				// else {
1349				// 	this.stopSlider();
1350				// }
1351
1352				// if (this.obDescription && this.config.showSkuDescription === 'Y') {
1353				// 	this.changeSkuDescription(index);
1354				// }
1355				if (this.config.showSkuProps) {
1356					if (this.obSkuProps) {
1357						if (!this.offers[index].DISPLAY_PROPERTIES) {
1358							BX.adjust(this.obSkuProps, { style: { display: 'none' }, html: '' });
1359						}
1360						else {
1361							BX.adjust(this.obSkuProps, { style: { display: '' }, html: this.offers[index].DISPLAY_PROPERTIES });
1362						}
1363					}
1364
1365					if (this.obMainSkuProps) {
1366						if (!this.offers[index].DISPLAY_PROPERTIES_MAIN_BLOCK) {
1367							BX.adjust(this.obMainSkuProps, { style: { display: 'none' }, html: '' });
1368						}
1369						else {
1370							BX.adjust(this.obMainSkuProps, { style: { display: '' }, html: this.offers[index].DISPLAY_PROPERTIES_MAIN_BLOCK });
1371						}
1372					}
1373				}
1374
1375				this.quantitySet(index);
1376				this.setPrice();
1377				this.itemPrices(index);
1378				this.picItemChange(index);
1379
1380				// this.setCompared(this.offers[index].COMPARED);
1381				this.offerNum = index;
1382				// this.fixFontCheck();
1383				// this.setAnalyticsDataLayer('showDetail');
1384				this.incViewedCounter();
1385
1386
1387				eventData.newId = this.offers[this.offerNum].ID;
1388				// only for compatible catalog.store.amount custom templates
1389				BX.onCustomEvent('onCatalogStoreProductChange', [this.offers[this.offerNum].ID]);
1390				// new event
1391				BX.onCustomEvent('onCatalogElementChangeOffer', [eventData]);
1392				eventData = null;
1393			}
1394		},
1395		picItemChange: function (index) {
1396			var box, img;
1397			box = BX(this.visual.BIG_IMG_CONT_ID);
1398			img = BX.findChild(box, { tag: img }, true);
1399
1400			BX.adjust(img, { attrs: { src: this.offers[index].DETAIL_PICTURE.SRC } });
1401		},
1402		itemPrices: function (index) {
1403			var boxItemPrice;
1404
1405			boxItemPrice = document.querySelector('[data-entity="item-prices"]');
1406
1407			BX.cleanNode(boxItemPrice);
1408			for (let i = 0; i < this.offers[index].ITEM_PRICES.length; i++) {
1409				const ob_price = this.offers[index].ITEM_PRICES[i];
1410				var ob_priceBox = BX.create('DIV', {
1411					attrs: {
1412						className: 'itemPrice',
1413						id: 'item-price-' + ob_price.ID,
1414					},
1415					html: 'От: ' + (ob_price.QUANTITY_FROM != '' ? ob_price.QUANTITY_FROM : 1) + this.offers[index].MEASURE + ' - ' + ob_price.PRINT_PRICE + (ob_price.RATIO_PRICE < ob_price.RATIO_BASE_PRICE ? '<span>' + ob_price.RATIO_BASE_PRICE + '</span>' : ''),
1416				});
1417				BX.append(ob_priceBox, boxItemPrice);
1418			}
1419		},
1420		checkQuantityRange: function (quantity, direction) {
1421			if (typeof quantity === 'undefined' || this.currentPriceMode !== 'Q') {
1422				return quantity;
1423			}
1424
1425			quantity = parseFloat(quantity);
1426
1427			var nearestQuantity = quantity;
1428			var range, diffFrom, absDiffFrom, diffTo, absDiffTo, shortestDiff;
1429
1430			for (var i in this.currentQuantityRanges) {
1431				if (this.currentQuantityRanges.hasOwnProperty(i)) {
1432					range = this.currentQuantityRanges[i];
1433
1434					if (
1435						parseFloat(quantity) >= parseFloat(range.SORT_FROM)
1436						&& (
1437							range.SORT_TO === 'INF'
1438							|| parseFloat(quantity) <= parseFloat(range.SORT_TO)
1439						)
1440					) {
1441						nearestQuantity = quantity;
1442						break;
1443					}
1444					else {
1445						diffFrom = parseFloat(range.SORT_FROM) - quantity;
1446						absDiffFrom = Math.abs(diffFrom);
1447						diffTo = parseFloat(range.SORT_TO) - quantity;
1448						absDiffTo = Math.abs(diffTo);
1449
1450						if (shortestDiff === undefined || shortestDiff > absDiffFrom) {
1451							if (
1452								direction === undefined
1453								|| (direction === 'up' && diffFrom > 0)
1454								|| (direction === 'down' && diffFrom < 0)
1455							) {
1456								shortestDiff = absDiffFrom;
1457								nearestQuantity = parseFloat(range.SORT_FROM);
1458							}
1459						}
1460
1461						if (shortestDiff === undefined || shortestDiff > absDiffTo) {
1462							if (
1463								direction === undefined
1464								|| (direction === 'up' && diffFrom > 0)
1465								|| (direction === 'down' && diffFrom < 0)
1466							) {
1467								shortestDiff = absDiffTo;
1468								nearestQuantity = parseFloat(range.SORT_TO);
1469							}
1470						}
1471					}
1472				}
1473			}
1474
1475			return nearestQuantity;
1476		},
1477
1478		checkPriceRange: function (quantity) {
1479			if (typeof quantity === 'undefined' || this.currentPriceMode !== 'Q') {
1480				return;
1481			}
1482
1483			var range, found = false;
1484
1485			for (var i in this.currentQuantityRanges) {
1486				if (this.currentQuantityRanges.hasOwnProperty(i)) {
1487					range = this.currentQuantityRanges[i];
1488
1489					if (
1490						parseFloat(quantity) >= parseFloat(range.SORT_FROM)
1491						&& (
1492							range.SORT_TO === 'INF'
1493							|| parseFloat(quantity) <= parseFloat(range.SORT_TO)
1494						)
1495					) {
1496						found = true;
1497						this.currentQuantityRangeSelected = range.HASH;
1498						break;
1499					}
1500				}
1501			}
1502
1503			if (!found && (range = this.getMinPriceRange())) {
1504				this.currentQuantityRangeSelected = range.HASH;
1505			}
1506
1507			for (var k in this.currentPrices) {
1508				if (this.currentPrices.hasOwnProperty(k)) {
1509					if (this.currentPrices[k].QUANTITY_HASH == this.currentQuantityRangeSelected) {
1510						this.currentPriceSelected = k;
1511						break;
1512					}
1513				}
1514			}
1515		},
1516
1517		getMinPriceRange: function () {
1518			var range;
1519
1520			for (var i in this.currentQuantityRanges) {
1521				if (this.currentQuantityRanges.hasOwnProperty(i)) {
1522					if (
1523						!range
1524						|| parseInt(this.currentQuantityRanges[i].SORT_FROM) < parseInt(range.SORT_FROM)
1525					) {
1526						range = this.currentQuantityRanges[i];
1527					}
1528				}
1529			}
1530
1531			return range;
1532		},
1533
1534		checkQuantityControls: function () {
1535			if (!this.obQuantity)
1536				return;
1537
1538			var reachedTopLimit = this.checkQuantity && parseFloat(this.obQuantity.value) + this.stepQuantity > this.maxQuantity,
1539				reachedBottomLimit = parseFloat(this.obQuantity.value) - this.stepQuantity < this.minQuantity;
1540
1541			if (reachedTopLimit) {
1542				BX.addClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled');
1543			}
1544			else if (BX.hasClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled')) {
1545				BX.removeClass(this.obQuantityUp, 'product-item-amount-field-btn-disabled');
1546			}
1547
1548			if (reachedBottomLimit) {
1549				BX.addClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled');
1550			}
1551			else if (BX.hasClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled')) {
1552				BX.removeClass(this.obQuantityDown, 'product-item-amount-field-btn-disabled');
1553			}
1554
1555			if (reachedTopLimit && reachedBottomLimit) {
1556				this.obQuantity.setAttribute('disabled', 'disabled');
1557			}
1558			else {
1559				this.obQuantity.removeAttribute('disabled');
1560			}
1561		},
1562
1563		setPrice: function () {
1564			var
1565				// economyInfo = '', 
1566				price;
1567
1568			BX.adjust(this.obAddToBasketBtn, { text: BX.message('CT_BCE_CATALOG_ADD') });
1569
1570			if (this.obQuantity) {
1571				this.checkPriceRange(this.obQuantity.value);
1572			}
1573
1574			this.checkQuantityControls();
1575
1576			price = this.currentPrices[this.currentPriceSelected];
1577
1578			if (this.isGift) {
1579				price.PRICE = 0;
1580				price.DISCOUNT = price.BASE_PRICE;
1581				price.PERCENT = 100;
1582			}
1583
1584			if (this.obPrice.price) {
1585				if (price) {
1586					BX.adjust(this.obPrice.price, { html: BX.Currency.currencyFormat(price.RATIO_PRICE, price.CURRENCY, true) });
1587					// this.smallCardNodes.price && BX.adjust(this.smallCardNodes.price, {
1588					// 	html: BX.Currency.currencyFormat(price.RATIO_PRICE, price.CURRENCY, true)
1589					// });
1590				}
1591				else {
1592					BX.adjust(this.obPrice.price, { html: '' });
1593					// this.smallCardNodes.price && BX.adjust(this.smallCardNodes.price, { html: '' });
1594				}
1595
1596				if (price && price.RATIO_PRICE !== price.RATIO_BASE_PRICE) {
1597					if (this.config.showOldPrice) {
1598						this.obPrice.full && BX.adjust(this.obPrice.full, {
1599							style: { display: '' },
1600							html: BX.Currency.currencyFormat(price.RATIO_BASE_PRICE, price.CURRENCY, true)
1601						});
1602						// this.smallCardNodes.oldPrice && BX.adjust(this.smallCardNodes.oldPrice, {
1603						// 	style: { display: '' },
1604						// 	html: BX.Currency.currencyFormat(price.RATIO_BASE_PRICE, price.CURRENCY, true)
1605						// });
1606
1607						// if (this.obPrice.discount) {
1608						// 	economyInfo = BX.message('ECONOMY_INFO_MESSAGE');
1609						// 	economyInfo = economyInfo.replace('#ECONOMY#', BX.Currency.currencyFormat(price.RATIO_DISCOUNT, price.CURRENCY, true));
1610						// 	BX.adjust(this.obPrice.discount, { style: { display: '' }, html: economyInfo });
1611						// }
1612					}
1613
1614					if (this.config.showPercent) {
1615						this.obPrice.percent && BX.adjust(this.obPrice.percent, {
1616							style: { display: '' },
1617							html: -price.PERCENT + '%'
1618						});
1619					}
1620				}
1621				else {
1622					if (this.config.showOldPrice) {
1623						this.obPrice.full && BX.adjust(this.obPrice.full, { style: { display: 'none' }, html: '' });
1624						// this.smallCardNodes.oldPrice && BX.adjust(this.smallCardNodes.oldPrice, { style: { display: 'none' }, html: '' });
1625						// this.obPrice.discount && BX.adjust(this.obPrice.discount, { style: { display: 'none' }, html: '' });
1626					}
1627
1628					if (this.config.showPercent) {
1629						this.obPrice.percent && BX.adjust(this.obPrice.percent, { style: { display: 'none' }, html: '' });
1630					}
1631				}
1632				if (this.obPrice.total) {
1633					if (price && this.obQuantity && this.obQuantity.value != this.stepQuantity) {
1634						BX.adjust(this.obPrice.total, {
1635							html: BX.message('PRICE_TOTAL_PREFIX') + ' <strong>'
1636								+ BX.Currency.currencyFormat(price.PRICE * this.obQuantity.value, price.CURRENCY, true)
1637								+ '</strong>',
1638							style: { display: '' }
1639						});
1640					}
1641					else {
1642						BX.adjust(this.obPrice.total, {
1643							html: '',
1644							style: { display: 'none' }
1645						});
1646					}
1647				}
1648			}
1649		},
1650
1651		// compare: function (event) {
1652		// 	var checkbox = this.obCompare.querySelector('[data-entity="compare-checkbox"]'),
1653		// 		target = BX.getEventTarget(event),
1654		// 		checked = true;
1655
1656		// 	if (checkbox) {
1657		// 		checked = target === checkbox ? checkbox.checked : !checkbox.checked;
1658		// 	}
1659
1660		// 	var url = checked ? this.compareData.compareUrl : this.compareData.compareDeleteUrl,
1661		// 		compareLink;
1662
1663		// 	if (url) {
1664		// 		if (target !== checkbox) {
1665		// 			BX.PreventDefault(event);
1666		// 			this.setCompared(checked);
1667		// 		}
1668
1669		// 		switch (this.productType) {
1670		// 			case 0: // no catalog
1671		// 			case 1: // product
1672		// 			case 2: // set
1673		// 				compareLink = url.replace('#ID#', this.product.id.toString());
1674		// 				break;
1675		// 			case 3: // sku
1676		// 				compareLink = url.replace('#ID#', this.offers[this.offerNum].ID);
1677		// 				break;
1678		// 		}
1679
1680		// 		BX.ajax({
1681		// 			method: 'POST',
1682		// 			dataType: checked ? 'json' : 'html',
1683		// 			url: compareLink + (compareLink.indexOf('?') !== -1 ? '&' : '?') + 'ajax_action=Y',
1684		// 			onsuccess: checked
1685		// 				? BX.proxy(this.compareResult, this)
1686		// 				: BX.proxy(this.compareDeleteResult, this)
1687		// 		});
1688		// 	}
1689		// },
1690
1691		// compareResult: function (result) {
1692		// 	var popupContent, popupButtons;
1693
1694		// 	if (this.obPopupWin) {
1695		// 		this.obPopupWin.close();
1696		// 	}
1697
1698		// 	if (!BX.type.isPlainObject(result))
1699		// 		return;
1700
1701		// 	this.initPopupWindow();
1702
1703		// 	if (this.offers.length > 0) {
1704		// 		this.offers[this.offerNum].COMPARED = result.STATUS === 'OK';
1705		// 	}
1706
1707		// 	if (result.STATUS === 'OK') {
1708		// 		BX.onCustomEvent('OnCompareChange');
1709
1710		// 		popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>'
1711		// 			+ BX.message('COMPARE_MESSAGE_OK')
1712		// 			+ '</p></div>';
1713
1714		// 		if (this.config.showClosePopup) {
1715		// 			popupButtons = [
1716		// 				new BasketButton({
1717		// 					text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
1718		// 					events: {
1719		// 						click: BX.delegate(this.compareRedirect, this)
1720		// 					},
1721		// 					style: { marginRight: '10px' }
1722		// 				}),
1723		// 				new BasketButton({
1724		// 					text: BX.message('BTN_MESSAGE_CLOSE_POPUP'),
1725		// 					events: {
1726		// 						click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
1727		// 					}
1728		// 				})
1729		// 			];
1730		// 		}
1731		// 		else {
1732		// 			popupButtons = [
1733		// 				new BasketButton({
1734		// 					text: BX.message('BTN_MESSAGE_COMPARE_REDIRECT'),
1735		// 					events: {
1736		// 						click: BX.delegate(this.compareRedirect, this)
1737		// 					}
1738		// 				})
1739		// 			];
1740		// 		}
1741		// 	}
1742		// 	else {
1743		// 		popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>'
1744		// 			+ (result.MESSAGE ? result.MESSAGE : BX.message('COMPARE_UNKNOWN_ERROR'))
1745		// 			+ '</p></div>';
1746		// 		popupButtons = [
1747		// 			new BasketButton({
1748		// 				text: BX.message('BTN_MESSAGE_CLOSE'),
1749		// 				events: {
1750		// 					click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
1751		// 				}
1752		// 			})
1753		// 		];
1754		// 	}
1755
1756		// 	this.obPopupWin.setTitleBar(BX.message('COMPARE_TITLE'));
1757		// 	this.obPopupWin.setContent(popupContent);
1758		// 	this.obPopupWin.setButtons(popupButtons);
1759		// 	this.obPopupWin.show();
1760		// },
1761
1762		// compareDeleteResult: function () {
1763		// 	BX.onCustomEvent('OnCompareChange');
1764
1765		// 	if (this.offers && this.offers.length) {
1766		// 		this.offers[this.offerNum].COMPARED = false;
1767		// 	}
1768		// },
1769
1770		// setCompared: function (state) {
1771		// 	if (!this.obCompare)
1772		// 		return;
1773
1774		// 	var checkbox = this.getEntity(this.obCompare, 'compare-checkbox');
1775		// 	if (checkbox) {
1776		// 		checkbox.checked = state;
1777		// 	}
1778		// },
1779
1780		// setCompareInfo: function (comparedIds) {
1781		// 	if (!BX.type.isArray(comparedIds))
1782		// 		return;
1783
1784		// 	for (var i in this.offers) {
1785		// 		if (this.offers.hasOwnProperty(i)) {
1786		// 			this.offers[i].COMPARED = BX.util.in_array(this.offers[i].ID, comparedIds);
1787		// 		}
1788		// 	}
1789		// },
1790
1791		// compareRedirect: function () {
1792		// 	if (this.compareData.comparePath) {
1793		// 		location.href = this.compareData.comparePath;
1794		// 	}
1795		// 	else {
1796		// 		this.obPopupWin.close();
1797		// 	}
1798		// },
1799
1800		// checkDeletedCompare: function (id) {
1801		// 	switch (this.productType) {
1802		// 		case 0: // no catalog
1803		// 		case 1: // product
1804		// 		case 2: // set
1805		// 			if (this.product.id == id) {
1806		// 				this.setCompared(false);
1807		// 			}
1808
1809		// 			break;
1810		// 		case 3: // sku
1811		// 			var i = this.offers.length;
1812		// 			while (i--) {
1813		// 				if (this.offers[i].ID == id) {
1814		// 					this.offers[i].COMPARED = false;
1815
1816		// 					if (this.offerNum == i) {
1817		// 						this.setCompared(false);
1818		// 					}
1819
1820		// 					break;
1821		// 				}
1822		// 			}
1823		// 	}
1824		// },
1825
1826		initBasketUrl: function () {
1827			this.basketUrl = (this.basketMode === 'ADD' ? this.basketData.add_url : this.basketData.buy_url);
1828			switch (this.productType) {
1829				case 1: // product
1830				case 2: // set
1831					this.basketUrl = this.basketUrl.replace('#ID#', this.product.id.toString());
1832					break;
1833				case 3: // sku
1834					this.basketUrl = this.basketUrl.replace('#ID#', this.offers[this.offerNum].ID);
1835					break;
1836			}
1837
1838			this.basketParams = {
1839				'ajax_basket': 'Y'
1840			};
1841
1842			if (this.config.showQuantity) {
1843				this.basketParams[this.basketData.quantity] = this.obQuantity.value;
1844			}
1845
1846			if (this.basketData.sku_props) {
1847				this.basketParams[this.basketData.sku_props_var] = this.basketData.sku_props;
1848			}
1849		},
1850
1851		fillBasketProps: function () {
1852			if (!this.visual.BASKET_PROP_DIV)
1853				return;
1854
1855			var
1856				i = 0,
1857				propCollection = null,
1858				foundValues = false,
1859				obBasketProps = null;
1860
1861			if (this.basketData.useProps && !this.basketData.emptyProps) {
1862				// if (this.obPopupWin && this.obPopupWin.contentContainer) {
1863				// 	obBasketProps = this.obPopupWin.contentContainer;
1864				// }
1865			}
1866			else {
1867				obBasketProps = BX(this.visual.BASKET_PROP_DIV);
1868			}
1869
1870			if (obBasketProps) {
1871				propCollection = obBasketProps.getElementsByTagName('select');
1872				if (propCollection && propCollection.length) {
1873					for (i = 0; i < propCollection.length; i++) {
1874						if (!propCollection[i].disabled) {
1875							switch (propCollection[i].type.toLowerCase()) {
1876								case 'select-one':
1877									this.basketParams[propCollection[i].name] = propCollection[i].value;
1878									foundValues = true;
1879									break;
1880								default:
1881									break;
1882							}
1883						}
1884					}
1885				}
1886
1887				propCollection = obBasketProps.getElementsByTagName('input');
1888				if (propCollection && propCollection.length) {
1889					for (i = 0; i < propCollection.length; i++) {
1890						if (!propCollection[i].disabled) {
1891							switch (propCollection[i].type.toLowerCase()) {
1892								case 'hidden':
1893									this.basketParams[propCollection[i].name] = propCollection[i].value;
1894									foundValues = true;
1895									break;
1896								case 'radio':
1897									if (propCollection[i].checked) {
1898										this.basketParams[propCollection[i].name] = propCollection[i].value;
1899										foundValues = true;
1900									}
1901									break;
1902								default:
1903									break;
1904							}
1905						}
1906					}
1907				}
1908			}
1909
1910			if (!foundValues) {
1911				this.basketParams[this.basketData.props] = [];
1912				this.basketParams[this.basketData.props][0] = 0;
1913			}
1914		},
1915
1916		sendToBasket: function () {
1917			if (!this.canBuy)
1918				return;
1919
1920			this.initBasketUrl();
1921			this.fillBasketProps();
1922			BX.ajax({
1923				method: 'POST',
1924				dataType: 'json',
1925				url: this.basketUrl,
1926				data: this.basketParams,
1927				onsuccess: BX.proxy(this.basketResult, this)
1928			});
1929		},
1930
1931		add2Basket: function () {
1932			this.basketMode = 'ADD';
1933			this.basket();
1934		},
1935
1936		buyBasket: function () {
1937			this.basketMode = 'BUY';
1938			this.basket();
1939		},
1940
1941		basket: function () {
1942			var contentBasketProps = '';
1943
1944			if (!this.canBuy)
1945				return;
1946
1947			switch (this.productType) {
1948				case 1: // product
1949				case 2: // set
1950					if (this.basketData.useProps && !this.basketData.emptyProps) {
1951						// this.initPopupWindow();
1952						// this.obPopupWin.setTitleBar(BX.message('TITLE_BASKET_PROPS'));
1953
1954						if (BX(this.visual.BASKET_PROP_DIV)) {
1955							contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML;
1956						}
1957
1958						// this.obPopupWin.setContent(contentBasketProps);
1959						// this.obPopupWin.setButtons([
1960						// 	new BasketButton({
1961						// 		text: BX.message('BTN_SEND_PROPS'),
1962						// 		events: {
1963						// 			click: BX.delegate(this.sendToBasket, this)
1964						// 		}
1965						// 	})
1966						// ]);
1967						// this.obPopupWin.show();
1968					}
1969					else {
1970						this.sendToBasket();
1971					}
1972					break;
1973				case 3: // sku
1974					this.sendToBasket();
1975					break;
1976			}
1977		},
1978
1979		basketResult: function (arResult) {
1980			var popupContent, popupButtons, productPict;
1981
1982			// if (this.obPopupWin) {
1983			// 	this.obPopupWin.close();
1984			// }
1985
1986			if (!BX.type.isPlainObject(arResult))
1987				return;
1988
1989			if (arResult.STATUS === 'OK') {
1990				BX.adjust(this.obAddToBasketBtn, { text: BX.message('CT_BCE_CATALOG_ADDED') });
1991				// this.setAnalyticsDataLayer('addToCart');
1992			}
1993
1994			if (arResult.STATUS === 'OK' && this.basketMode === 'BUY') {
1995				this.basketRedirect();
1996			}
1997			else {
1998				// this.initPopupWindow();
1999
2000				if (arResult.STATUS === 'OK') {
2001					BX.onCustomEvent('OnBasketChange');
2002					switch (this.productType) {
2003						case 1: // product
2004						case 2: // set
2005							productPict = this.product.pict.SRC;
2006							break;
2007						case 3: // sku
2008							productPict = this.offers[this.offerNum].PREVIEW_PICTURE
2009								? this.offers[this.offerNum].PREVIEW_PICTURE.SRC
2010								: this.defaultPict.pict.SRC;
2011							break;
2012					}
2013
2014					// popupContent = '<div style="width: 100%; margin: 0; text-align: center;">'
2015					// 	+ '<img src="' + productPict + '" height="130" style="max-height:130px"><p>'
2016					// 	+ this.product.name + '</p></div>';
2017
2018					// if (this.config.showClosePopup) {
2019					// 	popupButtons = [
2020					// 		new BasketButton({
2021					// 			text: BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2022					// 			events: {
2023					// 				click: BX.delegate(this.basketRedirect, this)
2024					// 			},
2025					// 			style: { marginRight: '10px' }
2026					// 		}),
2027					// 		new BasketButton({
2028					// 			text: BX.message('BTN_MESSAGE_CLOSE_POPUP'),
2029					// 			events: {
2030					// 				click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2031					// 			}
2032					// 		})
2033					// 	];
2034					// }
2035					// else {
2036					// 	popupButtons = [
2037					// 		new BasketButton({
2038					// 			text: BX.message('BTN_MESSAGE_BASKET_REDIRECT'),
2039					// 			events: {
2040					// 				click: BX.delegate(this.basketRedirect, this)
2041					// 			}
2042					// 		})
2043					// 	];
2044					// }
2045				}
2046				else {
2047					// popupContent = '<div style="width: 100%; margin: 0; text-align: center;"><p>'
2048					// 	+ (arResult.MESSAGE ? arResult.MESSAGE : BX.message('BASKET_UNKNOWN_ERROR'))
2049					// 	+ '</p></div>';
2050					// popupButtons = [
2051					// 	new BasketButton({
2052					// 		text: BX.message('BTN_MESSAGE_CLOSE'),
2053					// 		events: {
2054					// 			click: BX.delegate(this.obPopupWin.close, this.obPopupWin)
2055					// 		}
2056					// 	})
2057					// ];
2058				}
2059
2060				// this.obPopupWin.setTitleBar(arResult.STATUS === 'OK' ? BX.message('TITLE_SUCCESSFUL') : BX.message('TITLE_ERROR'));
2061				// this.obPopupWin.setContent(popupContent);
2062				// this.obPopupWin.setButtons(popupButtons);
2063				// this.obPopupWin.show();
2064			}
2065		},
2066
2067		basketRedirect: function () {
2068			location.href = (this.basketData.basketUrl ? this.basketData.basketUrl : BX.message('BASKET_URL'));
2069		},
2070
2071
2072
2073		incViewedCounter: function () {
2074			if (this.currentIsSet && !this.updateViewedCount) {
2075				switch (this.productType) {
2076					case 1:
2077					case 2:
2078						this.viewedCounter.params.PRODUCT_ID = this.product.id;
2079						this.viewedCounter.params.PARENT_ID = this.product.id;
2080						break;
2081					case 3:
2082						this.viewedCounter.params.PARENT_ID = this.product.id;
2083						this.viewedCounter.params.PRODUCT_ID = this.offers[this.offerNum].ID;
2084						break;
2085					default:
2086						return;
2087				}
2088
2089				this.viewedCounter.params.SITE_ID = BX.message('SITE_ID');
2090				this.updateViewedCount = true;
2091				BX.ajax.post(
2092					this.viewedCounter.path,
2093					this.viewedCounter.params,
2094					BX.delegate(function () {
2095						this.updateViewedCount = false;
2096					}, this)
2097				);
2098			}
2099		},
2100
2101		allowViewedCount: function (update) {
2102			this.currentIsSet = true;
2103
2104			if (update) {
2105				this.incViewedCounter();
2106			}
2107		},
2108
2109		// fixFontCheck: function () {
2110		// 	if (BX.type.isDomNode(this.obPrice.price)) {
2111		// 		BX.FixFontSize && BX.FixFontSize.init({
2112		// 			objList: [{
2113		// 				node: this.obPrice.price,
2114		// 				maxFontSize: 28,
2115		// 				smallestValue: false,
2116		// 				scaleBy: this.obPrice.price.parentNode
2117		// 			}],
2118		// 			onAdaptiveResize: true
2119		// 		});
2120
2121		// 	}
2122		// }
2123	}
2124})(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.