PageSourceSearch

https://www.tgsmit.ru/bitrix/templates/aspro_max/components/bitrix/sale.gift.main.products/main/script.js

js tgsmit.ru collected 2026-10-03 23:57:27 UTC 4,955 bytes, 180 lines download raw bytes

1BX.namespace("BX.Sale");
2BX.Sale.GiftMainProductsClass = (function ()
3{
4	var GiftMainProductsClass = function (parameters)
5	{
6		this.ajaxUrl = '/bitrix/components/bitrix/sale.gift.main.products/ajax.php';
7		this.contextAjaxData = parameters.contextAjaxData || {};
8		this.mainProductState = parameters.mainProductState || null;
9		this.injectId = parameters.injectId || null;
10		this.isGift = !!parameters.isGift;
11		this.productId = parameters.productId;
12		this.offerId = parameters.offerId;
13		this.offers = parameters.offers || [];
14
15		this.setEvents();
16
17		//detect #as_gift
18		if(document.location.hash.match(/as_gift/g))
19		{
20			if(this.isGift)
21			{
22				this.enableGift();
23			}
24			else
25			{
26				this.raiseNonGiftEvent();
27			}
28		}
29		BX.bindDelegate(BX(this.injectId), "click", {tagName: 'a'}, BX.proxy(this.clickNavLink, this));
30	};
31
32	GiftMainProductsClass.prototype.clickNavLink = function(e)
33	{
34		if(this.onPageNavigationByLink(BX.proxy_context))
35		{
36			return BX.PreventDefault(e);
37		}
38	};
39
40	GiftMainProductsClass.prototype.setEvents = function()
41	{
42
43		BX.addCustomEvent('onCatalogStoreProductChange', BX.proxy(this.onCatalogStoreProductChange, this));
44		BX.addCustomEvent('onAddToBasketMainProduct', BX.proxy(this.onAddToBasketMainProduct, this));
45	};
46
47	GiftMainProductsClass.prototype.unsubscribeEvents = function()
48	{
49		BX.removeCustomEvent('onCatalogStoreProductChange', BX.proxy(this.onCatalogStoreProductChange, this));
50	};
51
52	GiftMainProductsClass.prototype.onAddToBasketMainProduct = function(productObject)
53	{
54		this.enableGift();
55	};
56
57	GiftMainProductsClass.prototype.onCatalogStoreProductChange = function(offerId)
58	{
59		if(offerId == this.offerId)
60		{
61			return;
62		}
63		if($(this.injectId).length)
64		{
65			BX.ajax({
66				url: this.ajaxUrl,
67				method: 'POST',
68				data: BX.merge(this.contextAjaxData, {offerId: offerId, mainProductState: this.mainProductState, SITE_ID: BX.message('SITE_ID')}),
69				dataType: 'html',
70				processData: false,
71				start: true,
72				onsuccess: BX.delegate(function (html) {
73					this.offerId = offerId;
74					var ob = BX.processHTML(html);
75					if(!ob.HTML)
76					{
77						if(document.location.hash.match(/as_gift/g))
78						{
79							//raise event from previous state. It's trick.
80							if(this.isGift)
81							{
82								this.raiseGiftEvent();
83							}
84							else
85							{
86								this.raiseNonGiftEvent();
87							}
88						}
89
90						return;
91					}
92					this.unsubscribeEvents();
93
94					BX(this.injectId).innerHTML = ob.HTML;
95					BX.ajax.processScripts(ob.SCRIPT);
96				}, this)
97			});
98		}
99	};
100
101	GiftMainProductsClass.prototype.onPageNavigationByLink = function(link)
102	{
103		var isValidNavigationLink = BX.delegate(function(link)
104		{
105			if(!BX.type.isElementNode(link) || !link.href)
106			{
107				return false;
108			}
109			if(link.href.indexOf(this.ajaxUrl) >= 0)
110			{
111				return true;
112			}
113			return link.href.indexOf('PAGEN_') !== -1;
114		}, this);
115
116		if(!isValidNavigationLink(link))
117		{
118			return false;
119		}
120
121		BX.ajax({
122			url: link.href,
123			method: 'POST',
124			data: BX.merge(this.contextAjaxData, {SITE_ID: BX.message('SITE_ID')}),
125			dataType: 'html',
126			processData: false,
127			start: true,
128			onsuccess: BX.delegate(function (html) {
129				var ob = BX.processHTML(html);
130				if(!ob.HTML)
131				{
132					return;
133				}
134				this.unsubscribeEvents();
135
136				BX(this.injectId).innerHTML = ob.HTML;
137				BX.ajax.processScripts(ob.SCRIPT);
138			}, this)
139		});
140
141		return true;
142	};
143
144	GiftMainProductsClass.prototype.enableGift = function()
145	{
146		this.isGift = true;
147		this.raiseGiftEvent();
148	};
149
150	GiftMainProductsClass.prototype.raiseGiftEvent = function()
151	{
152		BX.onCustomEvent('onSaleProductIsGift', [this.productId, this.offerId]);
153	};
154
155	GiftMainProductsClass.prototype.raiseNonGiftEvent = function()
156	{
157		BX.onCustomEvent('onSaleProductIsNotGift', [this.productId, this.offerId]);
158	};
159
160	return GiftMainProductsClass;
161})();
162
163BX.addCustomEvent('onSliderInitialized', function(eventdata) {
164	try{
165		ignoreResize.push(true);
166		if(eventdata){
167			if($(eventdata.slider.currentTarget).closest('.bx_sale_gift_main_products').length)
168			{
169				$('.bx_sale_gift_main_products .catalog_block .catalog_item .item_info .item-title').sliceHeight({item:'.bx_sale_gift_main_products .catalog_item:not(.big)', mobile: true, autoslicecount: false, slice: 999});
170				$('.bx_sale_gift_main_products .catalog_block .catalog_item .item_info .sa_block').sliceHeight({item:'.bx_sale_gift_main_products .catalog_item:not(.big)', mobile: true, autoslicecount: false, slice: 999});
171				$('.bx_sale_gift_main_products .catalog_block .catalog_item .item_info .cost.prices').sliceHeight({item:'.bx_sale_gift_main_products .catalog_item:not(.big)', mobile: true, autoslicecount: false, slice: 999});
172				$('.bx_sale_gift_main_products .catalog_block .catalog_item').sliceHeight({classNull: '.footer_button', item:'.bx_sale_gift_main_products .catalog_item:not(.big)', mobile: true, autoslicecount: false, slice: 999});
173			}
174		}
175	}
176	catch(e){}
177	finally{
178		ignoreResize.pop();
179	}
180});

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.