PageSourceSearch

https://felicia.md/local/templates/aspro-lite/components/bitrix/sale.gift.product/main/script.js

js felicia.md collected 2026-10-04 02:55:56 UTC 49,212 bytes, 1,833 lines download raw bytes

1(function (window) {
2	if (!window.JCCatalogSectionOnlyElement) {
3		window.JCCatalogSectionOnlyElement = function (arParams) {
4			if (typeof arParams === "object") {
5				this.params = arParams;
6
7				this.obProduct = null;
8				this.set_quantity = 1;
9
10				this.currentPriceMode = "";
11				this.currentPrices = [];
12				this.currentPriceSelected = 0;
13				this.currentQuantityRanges = [];
14				this.currentQuantityRangeSelected = 0;
15
16				if (this.params.MESS) {
17					this.mess = this.params.MESS;
18				}
19
20				this.init();
21			}
22		};
23		window.JCCatalogSectionOnlyElement.prototype = {
24			init: function () {
25				var i = 0,
26					j = 0,
27					treeItems = null;
28
29				this.obProduct = BX(this.params.ID);
30
31				if (!!this.obProduct) {
32					$(this.obProduct)
33						.find(".counter_wrapp .counter_block input")
34						.data("product", "ob" + this.obProduct.id + "el");
35					this.currentPriceMode = this.params.ITEM_PRICE_MODE;
36					this.currentPrices = this.params.ITEM_PRICES;
37					this.currentQuantityRanges = this.params.ITEM_QUANTITY_RANGES;
38				}
39			},
40
41			setPriceAction: function () {
42				this.set_quantity = this.params.MIN_QUANTITY_BUY;
43				if ($(this.obProduct).find("input[name=quantity]").length)
44					this.set_quantity = $(this.obProduct)
45						.find("input[name=quantity]")
46						.val();
47
48				this.checkPriceRange(this.set_quantity);
49
50				$(this.obProduct).find(".not_matrix").hide();
51				$(this.obProduct)
52					.find(".with_matrix .price_value_block")
53					.html(
54						getCurrentPrice(
55							this.currentPrices[this.currentPriceSelected].PRICE,
56							this.currentPrices[this.currentPriceSelected].CURRENCY,
57							this.currentPrices[this.currentPriceSelected].PRINT_PRICE
58						)
59					);
60
61				if ($(this.obProduct).find(".with_matrix .discount")) {
62					$(this.obProduct)
63						.find(".with_matrix .discount")
64						.html(
65							getCurrentPrice(
66								this.currentPrices[this.currentPriceSelected].BASE_PRICE,
67								this.currentPrices[this.currentPriceSelected].CURRENCY,
68								this.currentPrices[this.currentPriceSelected].PRINT_BASE_PRICE
69							)
70						);
71				}
72
73				if (this.params.SHOW_DISCOUNT_PERCENT_NUMBER == "Y") {
74					if (
75						this.currentPrices[this.currentPriceSelected].PERCENT > 0 &&
76						this.currentPrices[this.currentPriceSelected].PERCENT < 100
77					) {
78						if (
79							!$(this.obProduct).find(
80								".with_matrix .sale_block .sale_wrapper .value"
81							).length
82						)
83							$('<div class="value"></div>').insertBefore(
84								$(this.obProduct).find(
85									".with_matrix .sale_block .sale_wrapper .text"
86								)
87							);
88
89						$(this.obProduct)
90							.find(".with_matrix .sale_block .sale_wrapper .value")
91							.html(
92								"-<span>" +
93									this.currentPrices[this.currentPriceSelected].PERCENT +
94									"</span>%"
95							);
96					} else {
97						if (
98							$(this.obProduct).find(
99								".with_matrix .sale_block .sale_wrapper .value"
100							).length
101						)
102							$(this.obProduct)
103								.find(".with_matrix .sale_block .sale_wrapper .value")
104								.remove();
105					}
106				}
107				$(this.obProduct)
108					.find(".with_matrix .sale_block .text .values_wrapper")
109					.html(
110						getCurrentPrice(
111							this.currentPrices[this.currentPriceSelected].DISCOUNT,
112							this.currentPrices[this.currentPriceSelected].CURRENCY,
113							this.currentPrices[this.currentPriceSelected].PRINT_DISCOUNT
114						)
115					);
116
117				$(this.obProduct).find(".with_matrix").show();
118
119				if (arMaxOptions["THEME"]["SHOW_TOTAL_SUMM"] == "Y") {
120					setPriceItem(
121						$(this.obProduct),
122						this.set_quantity,
123						this.currentPrices[this.currentPriceSelected].PRICE
124					);
125				}
126			},
127
128			checkPriceRange: function (quantity) {
129				if (typeof quantity === "undefined" || this.currentPriceMode != "Q")
130					return;
131
132				var range,
133					found = false;
134
135				for (var i in this.currentQuantityRanges) {
136					if (this.currentQuantityRanges.hasOwnProperty(i)) {
137						range = this.currentQuantityRanges[i];
138
139						if (
140							parseInt(quantity) >= parseInt(range.SORT_FROM) &&
141							(range.SORT_TO == "INF" ||
142								parseInt(quantity) <= parseInt(range.SORT_TO))
143						) {
144							found = true;
145							this.currentQuantityRangeSelected = range.HASH;
146							break;
147						}
148					}
149				}
150
151				if (!found && (range = this.getMinPriceRange())) {
152					this.currentQuantityRangeSelected = range.HASH;
153				}
154
155				for (var k in this.currentPrices) {
156					if (this.currentPrices.hasOwnProperty(k)) {
157						if (
158							this.currentPrices[k].QUANTITY_HASH ==
159							this.currentQuantityRangeSelected
160						) {
161							this.currentPriceSelected = k;
162							break;
163						}
164					}
165				}
166			},
167
168			getMinPriceRange: function () {
169				var range;
170
171				for (var i in this.currentQuantityRanges) {
172					if (this.currentQuantityRanges.hasOwnProperty(i)) {
173						if (
174							!range ||
175							parseInt(this.currentQuantityRanges[i].SORT_FROM) <
176								parseInt(range.SORT_FROM)
177						) {
178							range = this.currentQuantityRanges[i];
179						}
180					}
181				}
182
183				return range;
184			},
185		};
186	}
187
188	if (!!window.JCSaleGiftProduct) {
189		return;
190	}
191
192	var BasketButton = function (params) {
193		BasketButton.superclass.constructor.apply(this, arguments);
194		this.nameNode = BX.create("span", {
195			props: { className: "bx_medium bx_bt_button", id: this.id },
196			text: params.text,
197		});
198		this.buttonNode = BX.create("span", {
199			attrs: { className: params.ownerClass },
200			style: { marginBottom: "0", borderBottom: "0 none transparent" },
201			children: [this.nameNode],
202			events: this.contextEvents,
203		});
204		if (BX.browser.IsIE()) {
205			this.buttonNode.setAttribute("hideFocus", "hidefocus");
206		}
207	};
208	BX.extend(BasketButton, BX.PopupWindowButton);
209
210	window.JCSaleGiftProduct = function (arParams) {
211		this.skuVisualParams = {
212			SELECT: {
213				TAG_BIND: "select",
214				TAG: "option",
215				ACTIVE_CLASS: "active",
216				HIDE_CLASS: "hidden",
217				EVENT: "change",
218			},
219			LI: {
220				TAG_BIND: "li",
221				TAG: "li",
222				ACTIVE_CLASS: "active",
223				HIDE_CLASS: "missing",
224				EVENT: "click",
225			},
226		};
227		this.productType = 0;
228		this.showQuantity = true;
229		this.showAbsent = true;
230		this.secondPict = false;
231		this.showOldPrice = false;
232		this.showPercent = false;
233		this.showSkuProps = false;
234		this.showPercentNumber = false;
235		this.visual = {
236			ID: "",
237			PICT_ID: "",
238			SECOND_PICT_ID: "",
239			QUANTITY_ID: "",
240			QUANTITY_UP_ID: "",
241			QUANTITY_DOWN_ID: "",
242			PRICE_ID: "",
243			DSC_PERC: "",
244			SECOND_DSC_PERC: "",
245			DISPLAY_PROP_DIV: "",
246			BASKET_PROP_DIV: "",
247		};
248		this.product = {
249			checkQuantity: false,
250			maxQuantity: 0,
251			stepQuantity: 1,
252			isDblQuantity: false,
253			canBuy: true,
254			canSubscription: true,
255			name: "",
256			pict: {},
257			id: 0,
258			addUrl: "",
259			buyUrl: "",
260		};
261		this.basketData = {
262			useProps: false,
263			emptyProps: false,
264			quantity: "quantity",
265			props: "prop",
266			basketUrl: "",
267		};
268
269		this.defaultPict = {
270			pict: null,
271			secondPict: null,
272		};
273
274		this.checkQuantity = false;
275		this.maxQuantity = 0;
276		this.stepQuantity = 1;
277		this.isDblQuantity = false;
278		this.canBuy = true;
279		this.canSubscription = true;
280		this.precision = 6;
281		this.precisionFactor = Math.pow(10, this.precision);
282
283		this.currentPriceMode = "";
284		this.currentPrices = [];
285		this.currentPriceSelected = 0;
286		this.currentQuantityRanges = [];
287		this.currentQuantityRangeSelected = 0;
288
289		this.offers = [];
290		this.offerNum = 0;
291		this.treeProps = [];
292		this.obTreeRows = [];
293		this.showCount = [];
294		this.showStart = [];
295		this.selectedValues = {};
296
297		this.obProduct = null;
298		this.obQuantity = null;
299		this.obQuantityUp = null;
300		this.obQuantityDown = null;
301		this.obPict = null;
302		this.obSecondPict = null;
303		this.obPrice = null;
304		this.obTree = null;
305		this.obBuyBtn = null;
306		this.obDscPerc = null;
307		this.obSecondDscPerc = null;
308		this.obSkuProps = null;
309		this.obMeasure = null;
310
311		this.obPopupWin = null;
312		this.basketUrl = "";
313		this.basketParams = {};
314
315		this.treeRowShowSize = 5;
316		this.treeEnableArrow = { display: "", cursor: "pointer", opacity: 1 };
317		this.treeDisableArrow = { display: "", cursor: "default", opacity: 0.2 };
318
319		this.lastElement = false;
320		this.containerHeight = 0;
321
322		this.errorCode = 0;
323
324		if ("object" === typeof arParams) {
325			this.productType = parseInt(arParams.PRODUCT_TYPE, 10);
326			this.showQuantity = arParams.SHOW_QUANTITY;
327			this.showAbsent = arParams.SHOW_ABSENT;
328			this.secondPict = !!arParams.SECOND_PICT;
329			this.showOldPrice = !!arParams.SHOW_OLD_PRICE;
330			this.showPercent = !!arParams.SHOW_DISCOUNT_PERCENT;
331			this.showSkuProps = !!arParams.SHOW_SKU_PROPS;
332			this.showPercentNumber = arParams.SHOW_DISCOUNT_PERCENT_NUMBER == "Y";
333
334			this.visual = arParams.VISUAL;
335			switch (this.productType) {
336				case 1: //product
337				case 2: //set
338					if (!!arParams.PRODUCT && "object" === typeof arParams.PRODUCT) {
339						if (this.showQuantity) {
340							this.product.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY;
341							this.product.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT;
342							if (this.product.checkQuantity) {
343								this.product.maxQuantity = this.product.isDblQuantity
344									? parseFloat(arParams.PRODUCT.MAX_QUANTITY)
345									: parseInt(arParams.PRODUCT.MAX_QUANTITY, 10);
346							}
347							this.product.stepQuantity = this.product.isDblQuantity
348								? parseFloat(arParams.PRODUCT.STEP_QUANTITY)
349								: parseInt(arParams.PRODUCT.STEP_QUANTITY, 10);
350
351							this.checkQuantity = this.product.checkQuantity;
352							this.isDblQuantity = this.product.isDblQuantity;
353							this.maxQuantity = this.product.maxQuantity;
354							this.stepQuantity = this.product.stepQuantity;
355							if (this.isDblQuantity) {
356								this.stepQuantity =
357									Math.round(this.stepQuantity * this.precisionFactor) /
358									this.precisionFactor;
359							}
360						}
361						this.product.canBuy = arParams.PRODUCT.CAN_BUY;
362						this.product.canSubscription = arParams.PRODUCT.SUBSCRIPTION;
363
364						this.canBuy = this.product.canBuy;
365						this.canSubscription = this.product.canSubscription;
366
367						this.product.name = arParams.PRODUCT.NAME;
368						this.product.pict = arParams.PRODUCT.PICT;
369						this.product.id = arParams.PRODUCT.ID;
370						if (!!arParams.PRODUCT.ADD_URL) {
371							this.product.addUrl = arParams.PRODUCT.ADD_URL;
372						}
373						if (!!arParams.PRODUCT.BUY_URL) {
374							this.product.buyUrl = arParams.PRODUCT.BUY_URL;
375						}
376						if (!!arParams.BASKET && "object" === typeof arParams.BASKET) {
377							this.basketData.useProps = !!arParams.BASKET.ADD_PROPS;
378							this.basketData.emptyProps = !!arParams.BASKET.EMPTY_PROPS;
379						}
380					} else {
381						this.errorCode = -1;
382					}
383					break;
384				case 3: //sku
385					if (!!arParams.OFFERS && BX.type.isArray(arParams.OFFERS)) {
386						if (!!arParams.PRODUCT && "object" === typeof arParams.PRODUCT) {
387							this.product.name = arParams.PRODUCT.NAME;
388							this.product.id = arParams.PRODUCT.ID;
389						}
390						this.offers = arParams.OFFERS;
391						this.offerNum = 0;
392						if (!!arParams.OFFER_SELECTED) {
393							this.offerNum = parseInt(arParams.OFFER_SELECTED, 10);
394						}
395						if (isNaN(this.offerNum)) {
396							this.offerNum = 0;
397						}
398						if (!!arParams.TREE_PROPS) {
399							this.treeProps = arParams.TREE_PROPS;
400						}
401						if (!!arParams.DEFAULT_PICTURE) {
402							this.defaultPict.pict = arParams.DEFAULT_PICTURE.PICTURE;
403							this.defaultPict.secondPict =
404								arParams.DEFAULT_PICTURE.PICTURE_SECOND;
405						}
406					} else {
407						this.errorCode = -1;
408					}
409					break;
410				default:
411					this.errorCode = -1;
412			}
413			if (!!arParams.BASKET && "object" === typeof arParams.BASKET) {
414				if (!!arParams.BASKET.QUANTITY) {
415					this.basketData.quantity = arParams.BASKET.QUANTITY;
416				}
417				if (!!arParams.BASKET.PROPS) {
418					this.basketData.props = arParams.BASKET.PROPS;
419				}
420				if (!!arParams.BASKET.BASKET_URL) {
421					this.basketData.basketUrl = arParams.BASKET.BASKET_URL;
422				}
423			}
424			this.lastElement =
425				!!arParams.LAST_ELEMENT && "Y" === arParams.LAST_ELEMENT;
426		}
427		if (0 === this.errorCode) {
428			BX.ready(BX.delegate(this.Init, this));
429		}
430	};
431
432	window.JCSaleGiftProduct.prototype.Init = function () {
433		var i = 0,
434			strPrefix = "",
435			TreeItems = null;
436
437		this.obProduct = BX(this.visual.ID);
438
439		if (!this.obProduct) {
440			this.errorCode = -1;
441		}
442		this.obPict = BX(this.visual.PICT_ID);
443		if (!this.obPict) {
444			this.errorCode = -2;
445		}
446		if (this.secondPict && !!this.visual.SECOND_PICT_ID) {
447			this.obSecondPict = BX(this.visual.SECOND_PICT_ID);
448		}
449		this.storeQuanity = BX(this.visual.STORE_QUANTITY);
450		this.obPrice = BX(this.visual.PRICE_ID);
451		this.obPriceOld = BX(this.visual.PRICE_OLD_ID);
452		if (!this.obPrice) {
453			this.errorCode = -16;
454		}
455		if (this.showQuantity && !!this.visual.QUANTITY_ID) {
456			this.obQuantity = BX(this.visual.QUANTITY_ID);
457			if (!!this.visual.QUANTITY_UP_ID) {
458				this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID);
459			}
460			if (!!this.visual.QUANTITY_DOWN_ID) {
461				this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID);
462			}
463		}
464		if (3 === this.productType) {
465			if (!!this.visual.TREE_ID) {
466				this.obTree = BX(this.visual.TREE_ID);
467				if (!this.obTree) {
468					this.errorCode = -256;
469				}
470				strPrefix = this.visual.TREE_ITEM_ID;
471
472				for (i = 0; i < this.treeProps.length; i++) {
473					this.obTreeRows[i] = {
474						LIST: BX(strPrefix + this.treeProps[i].ID + "_list"),
475						CONT: BX(strPrefix + this.treeProps[i].ID + "_cont"),
476					};
477
478					if (!this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT) {
479						this.errorCode = -512;
480						break;
481					}
482				}
483			}
484			if (!!this.visual.QUANTITY_MEASURE) {
485				this.obMeasure = BX(this.visual.QUANTITY_MEASURE);
486			}
487		}
488		if (!!this.visual.BUY_ID) {
489			this.obBuyBtn = BX(this.visual.BUY_ID);
490		}
491
492		if (this.showPercent) {
493			if (!!this.visual.DSC_PERC) {
494				this.obDscPerc = BX(this.visual.DSC_PERC);
495			}
496			if (this.secondPict && !!this.visual.SECOND_DSC_PERC) {
497				this.obSecondDscPerc = BX(this.visual.SECOND_DSC_PERC);
498			}
499		}
500
501		if (this.showSkuProps) {
502			if (!!this.visual.DISPLAY_PROP_DIV) {
503				this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV);
504			}
505		}
506
507		if (0 === this.errorCode) {
508			if (this.showQuantity) {
509				if (!!this.obQuantityUp) {
510					BX.bind(
511						this.obQuantityUp,
512						"click",
513						BX.delegate(this.QuantityUp, this)
514					);
515				}
516				if (!!this.obQuantityDown) {
517					BX.bind(
518						this.obQuantityDown,
519						"click",
520						BX.delegate(this.QuantityDown, this)
521					);
522				}
523				if (!!this.obQuantity) {
524					BX.bind(
525						this.obQuantity,
526						"change",
527						BX.delegate(this.QuantityChange, this)
528					);
529				}
530			}
531
532			switch (this.productType) {
533				case 1: //product
534					break;
535				case 3: //sku
536					for (var key in this.skuVisualParams) {
537						var TreeItems = BX.findChildren(
538							this.obTree,
539							{ tagName: this.skuVisualParams[key].TAG_BIND },
540							true
541						);
542						if (!!TreeItems && 0 < TreeItems.length) {
543							for (i = 0; i < TreeItems.length; i++) {
544								$(TreeItems[i]).on(
545									this.skuVisualParams[key].EVENT,
546									BX.delegate(this.SelectOfferProp, this)
547								);
548								//BX.bind(TreeItems[i], this.skuVisualParams[key].EVENT, BX.delegate(this.SelectOfferProp, this));
549							}
550						}
551					}
552
553					this.SetCurrent();
554					break;
555			}
556			if (!!this.obBuyBtn) {
557				BX.bind(this.obBuyBtn, "click", BX.delegate(this.Basket, this));
558			}
559		}
560	};
561
562	window.JCSaleGiftProduct.prototype.QuantityUp = function () {
563		var curValue = 0,
564			boolSet = true;
565
566		if (0 === this.errorCode && this.showQuantity && this.canBuy) {
567			curValue = this.isDblQuantity
568				? parseFloat(this.obQuantity.value)
569				: parseInt(this.obQuantity.value, 10);
570			if (!isNaN(curValue)) {
571				curValue += this.stepQuantity;
572				if (this.checkQuantity) {
573					if (curValue > this.maxQuantity) {
574						boolSet = false;
575					}
576				}
577				if (boolSet) {
578					if (this.isDblQuantity) {
579						curValue =
580							Math.round(curValue * this.precisionFactor) /
581							this.precisionFactor;
582					}
583					this.obQuantity.value = curValue;
584				}
585			}
586		}
587	};
588
589	window.JCSaleGiftProduct.prototype.QuantityDown = function () {
590		var curValue = 0,
591			boolSet = true;
592
593		if (0 === this.errorCode && this.showQuantity && this.canBuy) {
594			curValue = this.isDblQuantity
595				? parseFloat(this.obQuantity.value)
596				: parseInt(this.obQuantity.value, 10);
597			if (!isNaN(curValue)) {
598				curValue -= this.stepQuantity;
599				if (curValue < this.stepQuantity) {
600					boolSet = false;
601				}
602				if (boolSet) {
603					if (this.isDblQuantity) {
604						curValue =
605							Math.round(curValue * this.precisionFactor) /
606							this.precisionFactor;
607					}
608					this.obQuantity.value = curValue;
609				}
610			}
611		}
612	};
613
614	window.JCSaleGiftProduct.prototype.QuantityChange = function () {
615		var curValue = 0,
616			boolSet = true;
617
618		if (0 === this.errorCode && this.showQuantity) {
619			if (this.canBuy) {
620				curValue = this.isDblQuantity
621					? parseFloat(this.obQuantity.value)
622					: parseInt(this.obQuantity.value, 10);
623				if (!isNaN(curValue)) {
624					if (this.checkQuantity) {
625						if (curValue > this.maxQuantity) {
626							boolSet = false;
627							curValue = this.maxQuantity;
628						} else if (curValue < this.stepQuantity) {
629							boolSet = false;
630							curValue = this.stepQuantity;
631						}
632					}
633					if (!boolSet) {
634						this.obQuantity.value = curValue;
635					}
636				} else {
637					this.obQuantity.value = this.stepQuantity;
638				}
639			} else {
640				this.obQuantity.value = this.stepQuantity;
641			}
642		}
643	};
644
645	window.JCSaleGiftProduct.prototype.QuantitySet = function (index) {
646		if (0 === this.errorCode) {
647			this.canBuy = this.offers[index].CAN_BUY;
648			this.currentPriceMode = this.offers[index].ITEM_PRICE_MODE;
649			this.currentPrices = this.offers[index].ITEM_PRICES;
650			this.currentPriceSelected = this.offers[index].ITEM_PRICE_SELECTED;
651			this.currentQuantityRanges = this.offers[index].ITEM_QUANTITY_RANGES;
652			this.currentQuantityRangeSelected =
653				this.offers[index].ITEM_QUANTITY_RANGE_SELECTED;
654
655			if (this.canBuy) {
656				if (!!this.obBasketActions) {
657					BX.style(this.obBasketActions, "display", "");
658				}
659				if (!!this.obNotAvail) {
660					BX.style(this.obNotAvail, "display", "none");
661				}
662			} else {
663				if (!!this.obBasketActions) {
664					//BX.style(this.obBasketActions, 'display', 'none');
665					BX.style(this.obBasketActions, "opacity", "0");
666					BX.style(
667						BX.findParent(BX(this.obQuantity), { class: "counter_block" }),
668						"display",
669						"none"
670					);
671				}
672				if (!!this.obNotAvail) {
673					BX.style(this.obNotAvail, "display", "");
674				}
675			}
676			if (this.showQuantity) {
677				this.isDblQuantity = this.offers[index].QUANTITY_FLOAT;
678				this.checkQuantity = this.offers[index].CHECK_QUANTITY;
679				if (this.isDblQuantity) {
680					this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY);
681					this.stepQuantity =
682						Math.round(
683							parseFloat(this.offers[index].STEP_QUANTITY) *
684								this.precisionFactor
685						) / this.precisionFactor;
686				} else {
687					this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10);
688					this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10);
689				}
690				if (!!this.obQuantity) {
691					this.obQuantity.value = this.defaultCount;
692					this.obQuantity.disabled = !this.canBuy;
693				}
694				if (!!this.obMeasure) {
695					if (!!this.offers[index].MEASURE) {
696						BX.adjust(this.obMeasure, { html: this.offers[index].MEASURE });
697					} else {
698						BX.adjust(this.obMeasure, { html: "" });
699					}
700				}
701			}
702			this.currentBasisPrice = this.offers[index].BASIS_PRICE;
703		}
704	};
705
706	/*window.JCSaleGiftProduct.prototype.QuantitySet = function(index)
707{
708	if (0 === this.errorCode)
709	{
710		this.canBuy = this.offers[index].CAN_BUY;
711		if (this.canBuy)
712		{
713			BX.addClass(this.obBuyBtn, 'bx_bt_button');
714			BX.removeClass(this.obBuyBtn, 'bx_bt_button_type_2');
715			this.obBuyBtn.innerHTML = BX.message('CVP_MESS_BTN_BUY');
716		}
717		else
718		{
719			BX.addClass(this.obBuyBtn, 'bx_bt_button_type_2');
720			BX.removeClass(this.obBuyBtn, 'bx_bt_button');
721			this.obBuyBtn.innerHTML = BX.message('CVP_MESS_NOT_AVAILABLE');
722		}
723		if (this.showQuantity)
724		{
725			this.isDblQuantity = this.offers[index].QUANTITY_FLOAT;
726			this.checkQuantity = this.offers[index].CHECK_QUANTITY;
727			if (this.isDblQuantity)
728			{
729				this.maxQuantity = parseFloat(this.offers[index].MAX_QUANTITY);
730				this.stepQuantity = Math.round(parseFloat(this.offers[index].STEP_QUANTITY)*this.precisionFactor)/this.precisionFactor;
731			}
732			else
733			{
734				this.maxQuantity = parseInt(this.offers[index].MAX_QUANTITY, 10);
735				this.stepQuantity = parseInt(this.offers[index].STEP_QUANTITY, 10);
736			}
737
738			this.obQuantity.value = this.stepQuantity;
739			this.obQuantity.disabled = !this.canBuy;
740			if (!!this.obMeasure)
741			{
742				if (!!this.offers[index].MEASURE)
743				{
744					BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE});
745				}
746				else
747				{
748					BX.adjust(this.obMeasure, { html : ''});
749				}
750			}
751		}
752	}
753};*/
754
755	window.JCSaleGiftProduct.prototype.SelectOfferProp = function () {
756		var i = 0,
757			value = "",
758			strTreeValue = "",
759			arTreeItem = [],
760			RowItems = null,
761			target = BX.proxy_context;
762
763		if (!!target && target.hasAttribute("data-treevalue")) {
764			strTreeValue = target.getAttribute("data-treevalue");
765			propModes = target.getAttribute("data-showtype");
766			arTreeItem = strTreeValue.split("_");
767			if (this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1])) {
768				/*RowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false);
769			if (!!RowItems && 0 < RowItems.length)
770			{
771				for (i = 0; i < RowItems.length; i++)
772				{
773					value = RowItems[i].getAttribute('data-onevalue');
774					if (value === arTreeItem[1])
775					{
776						BX.addClass(RowItems[i], 'bx_active');
777					}
778					else
779					{
780						BX.removeClass(RowItems[i], 'bx_active');
781					}
782				}
783			}*/
784
785				RowItems = BX.findChildren(
786					target.parentNode,
787					{ tagName: this.skuVisualParams[propModes.toUpperCase()].TAG },
788					false
789				);
790
791				if (!!RowItems && 0 < RowItems.length) {
792					for (i = 0; i < RowItems.length; i++) {
793						value = RowItems[i].getAttribute("data-onevalue");
794
795						// for SELECTBOXES
796						if (propModes == "TEXT") {
797							if (value === arTreeItem[1]) {
798								RowItems[i].setAttribute("selected", "selected");
799							} else {
800								RowItems[i].removeAttribute("selected");
801							}
802						} else {
803							if (value === arTreeItem[1]) {
804								$(RowItems[i]).addClass(
805									this.skuVisualParams[propModes.toUpperCase()].ACTIVE_CLASS
806								);
807							} else {
808								$(RowItems[i]).removeClass(
809									this.skuVisualParams[propModes.toUpperCase()].ACTIVE_CLASS
810								);
811							}
812						}
813					}
814				}
815			}
816		}
817	};
818
819	window.JCSaleGiftProduct.prototype.SearchOfferPropIndex = function (
820		strPropID,
821		strPropValue
822	) {
823		var strName = "",
824			arShowValues = false,
825			i,
826			j,
827			arCanBuyValues = [],
828			index = -1,
829			arFilter = {},
830			tmpFilter = [];
831
832		for (i = 0; i < this.treeProps.length; i++) {
833			if (this.treeProps[i].ID === strPropID) {
834				index = i;
835				break;
836			}
837		}
838
839		if (-1 < index) {
840			for (i = 0; i < index; i++) {
841				strName = "PROP_" + this.treeProps[i].ID;
842				arFilter[strName] = this.selectedValues[strName];
843			}
844			strName = "PROP_" + this.treeProps[index].ID;
845			arShowValues = this.GetRowValues(arFilter, strName);
846			if (!arShowValues) {
847				return false;
848			}
849			if (!BX.util.in_array(strPropValue, arShowValues)) {
850				return false;
851			}
852			arFilter[strName] = strPropValue;
853			for (i = index + 1; i < this.treeProps.length; i++) {
854				strName = "PROP_" + this.treeProps[i].ID;
855				arShowValues = this.GetRowValues(arFilter, strName);
856				if (!arShowValues) {
857					return false;
858				}
859				if (this.showAbsent) {
860					arCanBuyValues = [];
861					tmpFilter = [];
862					tmpFilter = BX.clone(arFilter, true);
863					for (j = 0; j < arShowValues.length; j++) {
864						tmpFilter[strName] = arShowValues[j];
865						if (this.GetCanBuy(tmpFilter)) {
866							arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
867						}
868					}
869				} else {
870					arCanBuyValues = arShowValues;
871				}
872				if (
873					!!this.selectedValues[strName] &&
874					BX.util.in_array(this.selectedValues[strName], arCanBuyValues)
875				) {
876					arFilter[strName] = this.selectedValues[strName];
877				} else {
878					arFilter[strName] = arCanBuyValues[0];
879				}
880				this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
881			}
882			this.selectedValues = arFilter;
883			this.ChangeInfo();
884		}
885		return true;
886	};
887
888	window.JCSaleGiftProduct.prototype.RowLeft = function () {
889		var i = 0,
890			strTreeValue = "",
891			index = -1,
892			target = BX.proxy_context;
893
894		if (!!target && target.hasAttribute("data-treevalue")) {
895			strTreeValue = target.getAttribute("data-treevalue");
896			for (i = 0; i < this.treeProps.length; i++) {
897				if (this.treeProps[i].ID === strTreeValue) {
898					index = i;
899					break;
900				}
901			}
902			if (-1 < index && this.treeRowShowSize < this.showCount[index]) {
903				if (0 > this.showStart[index]) {
904					this.showStart[index]++;
905					BX.adjust(this.obTreeRows[index].LIST, {
906						style: { marginLeft: this.showStart[index] * 20 + "%" },
907					});
908					BX.adjust(this.obTreeRows[index].RIGHT, {
909						style: this.treeEnableArrow,
910					});
911				}
912
913				if (0 <= this.showStart[index]) {
914					BX.adjust(this.obTreeRows[index].LEFT, {
915						style: this.treeDisableArrow,
916					});
917				}
918			}
919		}
920	};
921
922	window.JCSaleGiftProduct.prototype.RowRight = function () {
923		var i = 0,
924			strTreeValue = "",
925			index = -1,
926			target = BX.proxy_context;
927
928		if (!!target && target.hasAttribute("data-treevalue")) {
929			strTreeValue = target.getAttribute("data-treevalue");
930			for (i = 0; i < this.treeProps.length; i++) {
931				if (this.treeProps[i].ID === strTreeValue) {
932					index = i;
933					break;
934				}
935			}
936			if (-1 < index && this.treeRowShowSize < this.showCount[index]) {
937				if (
938					this.treeRowShowSize - this.showStart[index] <
939					this.showCount[index]
940				) {
941					this.showStart[index]--;
942					BX.adjust(this.obTreeRows[index].LIST, {
943						style: { marginLeft: this.showStart[index] * 20 + "%" },
944					});
945					BX.adjust(this.obTreeRows[index].LEFT, {
946						style: this.treeEnableArrow,
947					});
948				}
949
950				if (
951					this.treeRowShowSize - this.showStart[index] >=
952					this.showCount[index]
953				) {
954					BX.adjust(this.obTreeRows[index].RIGHT, {
955						style: this.treeDisableArrow,
956					});
957				}
958			}
959		}
960	};
961
962	window.JCSaleGiftProduct.prototype.UpdateRow = function (
963		intNumber,
964		activeID,
965		showID,
966		canBuyID
967	) {
968		var i = 0,
969			showI = 0,
970			value = "",
971			countShow = 0,
972			strNewLen = "",
973			obData = {},
974			pictMode = false,
975			extShowMode = false,
976			isCurrent = false,
977			selectIndex = 0,
978			obLeft = this.treeEnableArrow,
979			obRight = this.treeEnableArrow,
980			currentShowStart = 0,
981			RowItems = null;
982
983		if (-1 < intNumber && intNumber < this.obTreeRows.length) {
984			propMode = this.treeProps[intNumber].DISPLAY_TYPE;
985			RowItems = BX.findChildren(
986				this.obTreeRows[intNumber].LIST,
987				{ tagName: this.skuVisualParams[propMode].TAG },
988				false
989			);
990			if (!!RowItems && 0 < RowItems.length) {
991				selectMode = "SELECT" === this.treeProps[intNumber].DISPLAY_TYPE;
992				countShow = showID.length;
993				obData = {
994					style: {},
995					props: {
996						disabled: "",
997						selected: "",
998					},
999				};
1000
1001				for (i = 0; i < RowItems.length; i++) {
1002					value = RowItems[i].getAttribute("data-onevalue");
1003					isCurrent = value === activeID && value != 0;
1004					if (BX.util.in_array(value, canBuyID)) {
1005						obData.props.className = isCurrent
1006							? this.skuVisualParams[propMode].ACTIVE_CLASS
1007							: "";
1008					} else {
1009						obData.props.className = isCurrent
1010							? this.skuVisualParams[propMode].ACTIVE_CLASS +
1011							  " " +
1012							  this.skuVisualParams[propMode].HIDE_CLASS
1013							: this.skuVisualParams[propMode].HIDE_CLASS;
1014					}
1015					// obData.props.className = (isCurrent ? this.skuVisualParams[propMode].ACTIVE_CLASS : '');
1016
1017					if (selectMode) {
1018						obData.props.disabled = "disabled";
1019						obData.props.selected = isCurrent ? "selected" : "";
1020					} else {
1021						obData.style.display = "none";
1022					}
1023
1024					if (BX.util.in_array(value, showID)) {
1025						if (selectMode) {
1026							obData.props.disabled = "";
1027						} else {
1028							obData.style.display = "";
1029						}
1030						if (isCurrent) {
1031							selectIndex = showI;
1032						}
1033						showI++;
1034					}
1035					BX.adjust(RowItems[i], obData);
1036				}
1037
1038				if (selectMode) {
1039					if ($(this.obTreeRows[intNumber].LIST).parent().hasClass("ik_select"))
1040						$(this.obTreeRows[intNumber].LIST).ikSelect("reset");
1041				}
1042
1043				this.showCount[intNumber] = countShow;
1044				this.showStart[intNumber] = currentShowStart;
1045			}
1046		}
1047	};
1048
1049	window.JCSaleGiftProduct.prototype.GetRowValues = function (arFilter, index) {
1050		var i = 0,
1051			j,
1052			arValues = [],
1053			boolSearch = false,
1054			boolOneSearch = true;
1055
1056		if (0 === arFilter.length) {
1057			for (i = 0; i < this.offers.length; i++) {
1058				if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
1059					arValues[arValues.length] = this.offers[i].TREE[index];
1060				}
1061			}
1062			boolSearch = true;
1063		} else {
1064			for (i = 0; i < this.offers.length; i++) {
1065				boolOneSearch = true;
1066				for (j in arFilter) {
1067					if (arFilter[j] !== this.offers[i].TREE[j]) {
1068						boolOneSearch = false;
1069						break;
1070					}
1071				}
1072				if (boolOneSearch) {
1073					if (!BX.util.in_array(this.offers[i].TREE[index], arValues)) {
1074						arValues[arValues.length] = this.offers[i].TREE[index];
1075					}
1076					boolSearch = true;
1077				}
1078			}
1079		}
1080		return boolSearch ? arValues : false;
1081	};
1082
1083	window.JCSaleGiftProduct.prototype.GetCanBuy = function (arFilter) {
1084		var i = 0,
1085			j,
1086			boolSearch = false,
1087			boolOneSearch = true;
1088
1089		for (i = 0; i < this.offers.length; i++) {
1090			boolOneSearch = true;
1091			for (j in arFilter) {
1092				if (arFilter[j] !== this.offers[i].TREE[j]) {
1093					boolOneSearch = false;
1094					break;
1095				}
1096			}
1097			if (boolOneSearch) {
1098				if (this.offers[i].CAN_BUY) {
1099					boolSearch = true;
1100					break;
1101				}
1102			}
1103		}
1104		return boolSearch;
1105	};
1106
1107	window.JCSaleGiftProduct.prototype.SetCurrent = function () {
1108		var i = 0,
1109			j = 0,
1110			arCanBuyValues = [],
1111			strName = "",
1112			arShowValues = false,
1113			arFilter = {},
1114			tmpFilter = [],
1115			current = this.offers[this.offerNum].TREE;
1116
1117		for (i = 0; i < this.treeProps.length; i++) {
1118			strName = "PROP_" + this.treeProps[i].ID;
1119			arShowValues = this.GetRowValues(arFilter, strName);
1120			if (!arShowValues) {
1121				break;
1122			}
1123			if (BX.util.in_array(current[strName], arShowValues)) {
1124				arFilter[strName] = current[strName];
1125			} else {
1126				arFilter[strName] = arShowValues[0];
1127				this.offerNum = 0;
1128			}
1129			if (this.showAbsent) {
1130				arCanBuyValues = [];
1131				tmpFilter = [];
1132				tmpFilter = BX.clone(arFilter, true);
1133				for (j = 0; j < arShowValues.length; j++) {
1134					tmpFilter[strName] = arShowValues[j];
1135					if (this.GetCanBuy(tmpFilter)) {
1136						arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
1137					}
1138				}
1139			} else {
1140				arCanBuyValues = arShowValues;
1141			}
1142			this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
1143		}
1144		this.selectedValues = arFilter;
1145		this.ChangeInfo();
1146	};
1147
1148	window.JCSaleGiftProduct.prototype.ChangeInfo = function () {
1149		var i = 0,
1150			j,
1151			index = -1,
1152			obData = {},
1153			boolOneSearch = true,
1154			strPrice = "";
1155
1156		for (i = 0; i < this.offers.length; i++) {
1157			boolOneSearch = true;
1158			for (j in this.selectedValues) {
1159				if (this.selectedValues[j] !== this.offers[i].TREE[j]) {
1160					boolOneSearch = false;
1161					break;
1162				}
1163			}
1164			if (boolOneSearch) {
1165				index = i;
1166				break;
1167			}
1168		}
1169		if (-1 < index) {
1170			if (!!this.obPict) {
1171				var obData = {
1172					attrs: {},
1173				};
1174
1175				if (!!this.offers[index].PREVIEW_PICTURE) {
1176					obData.attrs.src = this.offers[index].PREVIEW_PICTURE.SRC;
1177				} else {
1178					obData.attrs.src = this.defaultPict.pict.SRC;
1179				}
1180				BX.adjust(BX.findChild(this.obPict, { tag: "img" }), obData);
1181			}
1182
1183			if (this.showSkuProps && !!this.obSkuProps) {
1184				if (0 === this.offers[index].DISPLAY_PROPERTIES.length) {
1185					BX.adjust(this.obSkuProps, { style: { display: "none" }, html: "" });
1186				} else {
1187					BX.adjust(this.obSkuProps, {
1188						style: { display: "" },
1189						html: this.offers[index].DISPLAY_PROPERTIES,
1190					});
1191				}
1192			}
1193
1194			this.setQuantityStore(
1195				this.offers[index].MAX_QUANTITY,
1196				this.offers[index].AVAILIABLE.TEXT
1197			);
1198
1199			this.offerNum = index;
1200			this.QuantitySet(this.offerNum);
1201
1202			/*$(this.obProduct).find('.item-title a').attr('href', this.offers[this.offerNum].URL);
1203		$(this.obProduct).find('.image_wrapper_block > a').attr('href', this.offers[this.offerNum].URL);*/
1204
1205			/*quantity discount start*/
1206			if ($(this.obProduct).find(".quantity_block .values").length) {
1207				$(this.obProduct)
1208					.find(".quantity_block .values .item span")
1209					.text(this.offers[index].MAX_QUANTITY)
1210					.css({ opacity: "1" });
1211			}
1212			/*quantity discount end*/
1213
1214			var obj = this.offers[index],
1215				th = $(this.obProduct),
1216				_th = this;
1217
1218			if (typeof arBasketAspro !== "undefined") {
1219				this.setActualDataBlock(th, obj);
1220			} else {
1221				if (typeof window.frameCacheVars !== "undefined") {
1222					BX.addCustomEvent("onFrameDataReceived", function () {
1223						_th.setActualDataBlock(th, obj);
1224					});
1225				}
1226			}
1227		}
1228	};
1229
1230	/*set blocks start*/
1231	window.JCSaleGiftProduct.prototype.setActualDataBlock = function (th, obj) {
1232		/*like block start*/
1233		this.setLikeBlock(th, ".like_icons .wish_item_button", obj, "DELAY");
1234		this.setLikeBlock(th, ".like_icons .compare_item_button", obj, "COMPARE");
1235		/*like block end*/
1236
1237		/*buy block start*/
1238		this.setBuyBlock(th, obj);
1239		/*buy block end*/
1240	};
1241	/*set blocks end*/
1242
1243	/*set compare/wish*/
1244	window.JCSaleGiftProduct.prototype.setLikeBlock = function (
1245		th,
1246		className,
1247		obj,
1248		type
1249	) {
1250		var block = th;
1251		if (type == "DELAY") {
1252			if (obj.CAN_BUY) {
1253				block.find(className).css("display", "block");
1254			} else {
1255				block.find(className).hide();
1256			}
1257		}
1258		block.find(className).attr("data-item", obj.ID);
1259		block.find(className).find("span").attr("data-item", obj.ID);
1260		if (arBasketAspro[type]) {
1261			block
1262				.find(className)
1263				.find(".to")
1264				.removeClass("added")
1265				.css("display", "block");
1266			block.find(className).find(".in").hide();
1267
1268			if (arBasketAspro[type][obj.ID] !== undefined) {
1269				block.find(className).find(".to").hide();
1270				block.find(className).find(".in").css("display", "block");
1271			}
1272		}
1273	};
1274
1275	/*set buy*/
1276	window.JCSaleGiftProduct.prototype.setBuyBlock = function (th, obj) {
1277		var buyBlock = th.find(".offer_buy_block"),
1278			input_value = obj.CONFIG.MIN_QUANTITY_BUY;
1279
1280		if (buyBlock.find(".counter_wrapp .counter_block").length) {
1281			buyBlock.find(".counter_wrapp .counter_block").attr("data-item", obj.ID);
1282		}
1283		if (this.offers[this.offerNum].offer_set_quantity)
1284			input_value = this.offers[this.offerNum].offer_set_quantity;
1285
1286		if (
1287			obj.CONFIG.OPTIONS.USE_PRODUCT_QUANTITY_DETAIL &&
1288			obj.CONFIG.ACTION == "ADD" &&
1289			obj.CAN_BUY
1290		) {
1291			var max =
1292					obj.CONFIG.MAX_QUANTITY_BUY > 0
1293						? "data-max='" + obj.CONFIG.MAX_QUANTITY_BUY + "'"
1294						: "",
1295				counterHtml =
1296					'<span class="minus">-</span>' +
1297					'<input type="text" class="text" name="' +
1298					obj.PRODUCT_QUANTITY_VARIABLE +
1299					'" value="' +
1300					input_value +
1301					'" />' +
1302					'<span class="plus" ' +
1303					max +
1304					">+</span>";
1305			if (
1306				arBasketAspro["BASKET"] &&
1307				arBasketAspro["BASKET"][obj.ID] !== undefined
1308			) {
1309				if (buyBlock.find(".counter_wrapp .counter_block").length) {
1310					buyBlock.find(".counter_wrapp .counter_block").hide();
1311				} else {
1312					buyBlock
1313						.find(".counter_wrapp")
1314						.prepend(
1315							'<div class="counter_block" data-item="' + obj.ID + '"></div>'
1316						);
1317					buyBlock
1318						.find(".counter_wrapp .counter_block")
1319						.html(counterHtml)
1320						.hide();
1321				}
1322			} else {
1323				if (buyBlock.find(".counter_wrapp .counter_block").length) {
1324					buyBlock
1325						.find(".counter_wrapp .counter_block")
1326						.html(counterHtml)
1327						.show();
1328				} else {
1329					buyBlock
1330						.find(".counter_wrapp")
1331						.prepend(
1332							'<div class="counter_block" data-item="' + obj.ID + '"></div>'
1333						);
1334					buyBlock.find(".counter_wrapp .counter_block").html(counterHtml);
1335				}
1336			}
1337		} else {
1338			if (buyBlock.find(".counter_wrapp .counter_block").length) {
1339				buyBlock.find(".counter_wrapp .counter_block").hide();
1340			}
1341		}
1342
1343		var className =
1344				obj.CONFIG.ACTION == "ORDER" ||
1345				!obj.CAN_BUY ||
1346				!obj.CONFIG.OPTIONS.USE_PRODUCT_QUANTITY_DETAIL ||
1347				(obj.CONFIG.ACTION == "SUBSCRIBE" && obj.CATALOG_SUBSCRIBE == "Y")
1348					? "wide"
1349					: "",
1350			buyBlockBtn = $('<div class="button_block"></div>');
1351
1352		if (buyBlock.find(".counter_wrapp").find(".button_block").length) {
1353			if (
1354				arBasketAspro["BASKET"] &&
1355				arBasketAspro["BASKET"][obj.ID] !== undefined
1356			) {
1357				buyBlock
1358					.find(".counter_wrapp")
1359					.find(".button_block")
1360					.addClass("wide")
1361					.html(obj.HTML);
1362				markProductAddBasket(obj.ID);
1363			} else {
1364				if (className) {
1365					buyBlock
1366						.find(".counter_wrapp")
1367						.find(".button_block")
1368						.addClass("wide")
1369						.html(obj.HTML);
1370					if (
1371						arBasketAspro["SUBSCRIBE"] &&
1372						arBasketAspro["SUBSCRIBE"][obj.ID] !== undefined
1373					) {
1374						markProductSubscribe(obj.ID);
1375					}
1376				} else {
1377					buyBlock
1378						.find(".counter_wrapp")
1379						.find(".button_block")
1380						.removeClass("wide")
1381						.html(obj.HTML);
1382				}
1383			}
1384		} else {
1385			buyBlock
1386				.find(".counter_wrapp")
1387				.append(
1388					'<div class="button_block ' + className + '">' + obj.HTML + "</div>"
1389				);
1390			if (
1391				arBasketAspro["BASKET"] &&
1392				arBasketAspro["BASKET"][obj.ID] !== undefined
1393			)
1394				markProductAddBasket(obj.ID);
1395			if (
1396				arBasketAspro["SUBSCRIBE"] &&
1397				arBasketAspro["SUBSCRIBE"][obj.ID] !== undefined
1398			)
1399				markProductSubscribe(obj.ID);
1400		}
1401
1402		if (obj.CONFIG.ACTION !== "NOTHING") {
1403			if (
1404				obj.CONFIG.ACTION == "ADD" &&
1405				obj.CAN_BUY &&
1406				obj.SHOW_ONE_CLICK_BUY != "N"
1407			) {
1408				var ocb =
1409					'<span class="transparent big_btn type_block button one_click" data-offers="Y" data-item="' +
1410					obj.ID +
1411					'" data-iblockID="' +
1412					obj.IBLOCK_ID +
1413					'" data-quantity="' +
1414					obj.CONFIG.MIN_QUANTITY_BUY +
1415					'" data-props="' +
1416					obj.OFFER_PROPS +
1417					'" onclick="oneClickBuy(' +
1418					obj.ID +
1419					", " +
1420					obj.IBLOCK_ID +
1421					', this)">' +
1422					"<span>" +
1423					obj.ONE_CLICK_BUY +
1424					"</span>" +
1425					"</span>";
1426				if (buyBlock.find(".wrapp_one_click").length) {
1427					buyBlock.find(".wrapp_one_click").html(ocb);
1428				} else {
1429					buyBlock.append('<div class="wrapp_one_click">' + ocb + "</div>");
1430				}
1431			} else {
1432				if (buyBlock.find(".wrapp_one_click").length) {
1433					buyBlock.find(".wrapp_one_click").remove();
1434				}
1435			}
1436		} else {
1437			if (buyBlock.find(".wrapp_one_click").length) {
1438				buyBlock.find(".wrapp_one_click").remove();
1439			}
1440		}
1441
1442		buyBlock.fadeIn();
1443
1444		buyBlock
1445			.find(".counter_wrapp .counter_block input")
1446			.data("product", "ob" + this.obProduct.id);
1447		this.setPriceAction("", "Y");
1448
1449		if (arMaxOptions["THEME"]["CHANGE_TITLE_ITEM"] == "Y") {
1450			$(this.obProduct).find(".item-title a").text(obj.NAME);
1451		}
1452	};
1453
1454	window.JCSaleGiftProduct.prototype.setPriceAction = function (change, sku) {
1455		var check_quantity = "",
1456			product = $(this.obProduct),
1457			is_sku = typeof sku !== "undefined" && sku == "Y";
1458
1459		this.setPrice();
1460
1461		if (arMaxOptions["THEME"]["SHOW_TOTAL_SUMM"] == "Y") {
1462			if (this.offers[this.offerNum].check_quantity) check_quantity = "Y";
1463			else {
1464				var check_quantity =
1465					typeof change !== "undefined" && change == "Y" ? change : "";
1466				if (check_quantity) this.offers[this.offerNum].check_quantity = true;
1467			}
1468			// setPriceItem(product, this.offers[this.offerNum].offer_set_quantity, this.currentPrices[this.currentPriceSelected].PRICE, check_quantity, is_sku);
1469		}
1470	};
1471
1472	window.JCSaleGiftProduct.prototype.setPrice = function (price, measure) {
1473		var strPrice, obData;
1474
1475		if (!!this.obPrice) {
1476			var measure =
1477					this.offers[this.offerNum].MEASURE &&
1478					this.offers[this.offerNum].SHOW_MEASURE == "Y"
1479						? this.offers[this.offerNum].MEASURE
1480						: "",
1481				product = $(this.obProduct),
1482				obPrice = this.offers[this.offerNum].PRICE;
1483
1484			this.offers[this.offerNum].offer_set_quantity =
1485				this.offers[this.offerNum].CONFIG.MIN_QUANTITY_BUY;
1486
1487			if ($(product).find("input[name=quantity]").length)
1488				this.offers[this.offerNum].offer_set_quantity = $(product)
1489					.find("input[name=quantity]")
1490					.val();
1491
1492			strPrice =
1493				'<span class="values_wrapper">' +
1494				getCurrentPrice(obPrice.VALUE, obPrice.CURRENCY, obPrice.PRINT_
1494VALUE) +
1495				"</span>";
1496			BX.adjust($(this.obPrice).closest(".cost").find(".price.discount")[0], {
1497				html: strPrice,
1498			});
1499			newPrice =
1500				'<span class="values_wrapper">' +
1501				getCurrentPrice(
1502					obPrice.DISCOUNT_VALUE,
1503					obPrice.CURRENCY,
1504					obPrice.PRINT_DISCOUNT_VALUE
1505				) +
1506				"</span>";
1507			if (measure) {
1508				newPrice += "/" + measure;
1509			}
1510			BX.adjust(this.obPrice, { html: newPrice });
1511
1512			if (
1513				obPrice.DISCOUNT_VALUE !== obPrice.VALUE &&
1514				this.showOldPrice &&
1515				obPrice.DISCOUNT_VALUE > 0
1516			) {
1517				price_value = BX.Currency.currencyFormat(
1518					obPrice.VALUE * this.offers[this.offerNum].offer_set_quantity,
1519					obPrice.CURRENCY
1520				);
1521				price_value_old = BX.Currency.currencyFormat(
1522					obPrice.VALUE,
1523					obPrice.CURRENCY
1524				);
1525				$(this.obPriceOld)
1526					.find("strike")
1527					.show()
1528					.html(
1529						'<span class="values_wrapper">' +
1530							obPrice.PRINT_VALUE.replace(price_value_old, price_value) +
1531							"</span>"
1532					);
1533				if (this.showPercent && obPrice.DISCOUNT_VALUE) {
1534					$(this.obPriceOld).closest(".cost").find(".sale_block").show();
1535					$(this.obPriceOld)
1536						.closest(".cost")
1537						.find(".value")
1538						.html(obPrice.DISCOUNT_DIFF_PERCENT_RAW);
1539					$(this.obPriceOld)
1540						.closest(".cost")
1541						.find(".text span")
1542						.html(
1543							BX.Currency.currencyFormat(
1544								obPrice.DISCOUNT_DIFF,
1545								obPrice.CURRENCY,
1546								true
1547							)
1548						);
1549				}
1550			} else {
1551				$(this.obPriceOld).find("strike").hide().html("");
1552				if (this.showPercent) {
1553					$(this.obPrice).closest(".cost").find(".sale_block").hide();
1554				}
1555			}
1556
1557			var eventdata = {
1558				product: product,
1559				measure: measure,
1560				config: this.config,
1561				offer: this.offers[this.offerNum],
1562				obPrice: obPrice,
1563			};
1564			BX.onCustomEvent("onAsproSkuSetPrice", [eventdata]);
1565		}
1566	};
1567
1568	/*set store quantity*/
1569	window.JCSaleGiftProduct.prototype.setQuantityStore = function (
1570		quantity,
1571		text
1572	) {
1573		if (parseFloat(quantity) > 0) {
1574			$(this.storeQuanity).find(".icon").removeClass("order").addClass("stock");
1575		} else {
1576			$(this.storeQuanity).find(".icon").removeClass("stock").addClass("order");
1577		}
1578		$(this.storeQuanity).find(".icon + span").html(text);
1579	};
1580
1581	window.JCSaleGiftProduct.prototype.InitBasketUrl = function () {
1582		switch (this.productType) {
1583			case 1: //product
1584			case 2: //set
1585				this.basketUrl = this.product.addUrl;
1586				break;
1587			case 3: //sku
1588				this.basketUrl = this.offers[this.offerNum].ADD_URL;
1589				break;
1590		}
1591		this.basketParams = {
1592			ajax_basket: "Y",
1593		};
1594		if (this.showQuantity) {
1595			this.basketParams[this.basketData.quantity] = this.obQuantity.value;
1596		}
1597	};
1598
1599	window.JCSaleGiftProduct.prototype.FillBasketProps = function () {
1600		if (!this.visual.BASKET_PROP_DIV) {
1601			return;
1602		}
1603		var i = 0,
1604			propCollection = null,
1605			foundValues = false,
1606			obBasketProps = null;
1607
1608		if (this.basketData.useProps && !this.basketData.emptyProps) {
1609			if (!!this.obPopupWin && !!this.obPopupWin.contentContainer) {
1610				obBasketProps = this.obPopupWin.contentContainer;
1611			}
1612		} else {
1613			obBasketProps = BX(this.visual.BASKET_PROP_DIV);
1614		}
1615		if (!obBasketProps) {
1616			return;
1617		}
1618		propCollection = obBasketProps.getElementsByTagName("select");
1619		if (!!propCollection && !!propCollection.length) {
1620			for (i = 0; i < propCollection.length; i++) {
1621				if (!propCollection[i].disabled) {
1622					switch (propCollection[i].type.toLowerCase()) {
1623						case "select-one":
1624							this.basketParams[propCollection[i].name] =
1625								propCollection[i].value;
1626							foundValues = true;
1627							break;
1628						default:
1629							break;
1630					}
1631				}
1632			}
1633		}
1634		propCollection = obBasketProps.getElementsByTagName("input");
1635		if (!!propCollection && !!propCollection.length) {
1636			for (i = 0; i < propCollection.length; i++) {
1637				if (!propCollection[i].disabled) {
1638					switch (propCollection[i].type.toLowerCase()) {
1639						case "hidden":
1640							this.basketParams[propCollection[i].name] =
1641								propCollection[i].value;
1642							foundValues = true;
1643							break;
1644						case "radio":
1645							if (propCollection[i].checked) {
1646								this.basketParams[propCollection[i].name] =
1647									propCollection[i].value;
1648								foundValues = true;
1649							}
1650							break;
1651						default:
1652							break;
1653					}
1654				}
1655			}
1656		}
1657		if (!foundValues) {
1658			this.basketParams[this.basketData.props] = [];
1659			this.basketParams[this.basketData.props][0] = 0;
1660		}
1661	};
1662
1663	window.JCSaleGiftProduct.prototype.SendToBasket = function () {
1664		if (!this.canBuy) {
1665			return;
1666		}
1667		this.InitBasketUrl();
1668		this.FillBasketProps();
1669		BX.ajax.loadJSON(
1670			this.basketUrl,
1671			this.basketParams,
1672			BX.delegate(this.BasketResult, this)
1673		);
1674	};
1675
1676	window.JCSaleGiftProduct.prototype.Basket = function () {
1677		var contentBasketProps = "";
1678		if (!this.canBuy) {
1679			return;
1680		}
1681		switch (this.productType) {
1682			case 1: //product
1683			case 2: //set
1684				if (this.basketData.useProps && !this.basketData.emptyProps) {
1685					this.InitPopupWindow();
1686					this.obPopupWin.setTitleBar({
1687						content: BX.create("div", {
1688							style: { marginRight: "30px", whiteSpace: "nowrap" },
1689							text: BX.message("CVP_TITLE_BASKET_PROPS"),
1690						}),
1691					});
1692					if (BX(this.visual.BASKET_PROP_DIV)) {
1693						contentBasketProps = BX(this.visual.BASKET_PROP_DIV).innerHTML;
1694					}
1695					this.obPopupWin.setContent(contentBasketProps);
1696					this.obPopupWin.setButtons([
1697						new BasketButton({
1698							ownerClass:
1699								this.obProduct.parentNode.parentNode.parentNode.className,
1700							text: BX.message("CVP_BTN_MESSAGE_SEND_PROPS"),
1701							events: {
1702								click: BX.delegate(this.SendToBasket, this),
1703							},
1704						}),
1705					]);
1706					this.obPopupWin.show();
1707				} else {
1708					this.SendToBasket();
1709				}
1710				break;
1711			case 3: //sku
1712				this.SendToBasket();
1713				break;
1714		}
1715	};
1716
1717	window.JCSaleGiftProduct.prototype.BasketResult = function (arResult) {
1718		var strContent = "",
1719			strName = "",
1720			strPict = "",
1721			successful = true,
1722			buttons = [];
1723
1724		if (!!this.obPopupWin) {
1725			this.obPopupWin.close();
1726		}
1727		if ("object" !== typeof arResult) {
1728			return false;
1729		}
1730		successful = "OK" === arResult.STATUS;
1731		if (successful) {
1732			BX.onCustomEvent("OnBasketChange");
1733			strName = this.product.name;
1734			switch (this.productType) {
1735				case 1: //
1736				case 2: //
1737					strPict = this.product.pict.SRC;
1738					break;
1739				case 3:
1740					strPict = !!this.offers[this.offerNum].PREVIEW_PICTURE
1741						? this.offers[this.offerNum].PREVIEW_PICTURE.SRC
1742						: this.defaultPict.pict.SRC;
1743					break;
1744			}
1745			strContent =
1746				'<div style="width: 96%; margin: 10px 2%; text-align: center;"><img src="' +
1747				strPict +
1748				'" height="130" style="max-height:130px"><p>' +
1749				strName +
1750				"</p></div>";
1751			buttons = [
1752				new BasketButton({
1753					ownerClass: this.obProduct.parentNode.parentNode.parentNode.className,
1754					text: BX.message("CVP_BTN_MESSAGE_BASKET_REDIRECT"),
1755					events: {
1756						click: BX.delegate(function () {
1757							location.href = !!this.basketData.basketUrl
1758								? this.basketData.basketUrl
1759								: BX.message("CVP_BASKET_URL");
1760						}, this),
1761					},
1762				}),
1763			];
1764		} else {
1765			strContent = !!arResult.MESSAGE
1766				? arResult.MESSAGE
1767				: BX.message("CVP_BASKET_UNKNOWN_ERROR");
1768			buttons = [
1769				new BasketButton({
1770					ownerClass: this.obProduct.parentNode.parentNode.parentNode.className,
1771					text: BX.message("CVP_BTN_MESSAGE_CLOSE"),
1772					events: {
1773						click: BX.delegate(this.obPopupWin.close, this.obPopupWin),
1774					},
1775				}),
1776			];
1777		}
1778		this.InitPopupWindow();
1779		this.obPopupWin.setTitleBar({
1780			content: BX.create("div", {
1781				style: { marginRight: "30px", whiteSpace: "nowrap" },
1782				text: successful
1783					? BX.message("CVP_TITLE_SUCCESSFUL")
1784					: BX.message("CVP_TITLE_ERROR"),
1785			}),
1786		});
1787		this.obPopupWin.setContent(strContent);
1788		this.obPopupWin.setButtons(buttons);
1789		this.obPopupWin.show();
1790	};
1791
1792	window.JCSaleGiftProduct.prototype.InitPopupWindow = function () {
1793		if (!!this.obPopupWin) {
1794			return;
1795		}
1796		this.obPopupWin = BX.PopupWindowManager.create(
1797			"CatalogSectionBasket_" + this.visual.ID,
1798			null,
1799			{
1800				autoHide: false,
1801				offsetLeft: 0,
1802				offsetTop: 0,
1803				overlay: true,
1804				closeByEsc: true,
1805				titleBar: true,
1806				closeIcon: { top: "10px", right: "10px" },
1807			}
1808		);
1809	};
1810})(window);
1811
1812function bx_sale_gift_product_load(injectId, localAjaxData, additionalData) {
1813	localAjaxData = localAjaxData || {};
1814	additionalData = additionalData || {};
1815
1816	BX.ajax({
1817		url: "/bitrix/components/bitrix/sale.gift.product/ajax.php",
1818		method: "POST",
1819		data: BX.merge(localAjaxData, additionalData),
1820		dataType: "html",
1821		processData: false,
1822		start: true,
1823		onsuccess: function (html) {
1824			var ob = BX.processHTML(html);
1825
1826			// inject
1827			BX(injectId).innerHTML = ob.HTML;
1828			BX.ajax.processScripts(ob.SCRIPT);
1829			initCountdown();
1830			initSwiperSlider();
1831		},
1832	});
1833}

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.