PageSourceSearch

https://www.avs-el.ru/local/templates/default/components/bitrix/sa…/basket_top_mobile/script.js?17827419402599

js avs-el.ru collected 2026-10-08 04:28:16 UTC 2,599 bytes, 93 lines download raw bytes

1'use strict';
2
3function BitrixSmallCart(){}
4
5BitrixSmallCart.prototype = {
6
7	activate: function ()
8	{
9		this.cartElement = BX(this.cartId);
10		this.setCartBodyClosure = this.closure('setCartBody');
11		BX.addCustomEvent(window, 'OnBasketChange', this.closure('refreshCart', {}));
12	},
13
14	closure: function (fname, data)
15	{
16		var obj = this;
17		return data
18			? function(){ obj[fname](data); }
19			: function(arg1){ obj[fname](arg1); };
20	},
21
22	refreshCart: function (data)
23	{
24		data.sessid = BX.bitrix_sessid();
25		data.siteId = this.siteId;
26		data.templateName = this.templateName;
27		data.arParams = this.arParams;
28
29		BX.ajax({
30			url: this.ajaxPath,
31			method: 'POST',
32			dataType: 'html',
33			data: data,
34			onsuccess: this.setCartBodyClosure
35		});
36	},
37
38	setCartBody: function (result)
39	{
40		if (!this.cartElement) return;
41
42		// Парсим HTML из ajax
43		var tmp = document.createElement('div');
44		tmp.innerHTML = result.replace(/#CURRENT_URL#/g, this.currentUrl || '');
45
46		var newMenuItem = tmp.querySelector('.menu-item');
47		var curMenuItem = this.cartElement.querySelector('.menu-item');
48
49		// Если вдруг структура не совпала — fallback на полный replace
50		if (!newMenuItem || !curMenuItem)
51		{
52			this.cartElement.innerHTML = tmp.innerHTML;
53			return;
54		}
55
56		// 1) data-count
57		var newCount = newMenuItem.getAttribute('data-count');
58		if (newCount !== null)
59			curMenuItem.setAttribute('data-count', newCount);
60
61		// 2) label
62		var newLabel = newMenuItem.querySelector('.menu-item__label');
63		var curLabel = curMenuItem.querySelector('.menu-item__label');
64		if (newLabel && curLabel)
65			curLabel.innerHTML = newLabel.innerHTML;
66
67		// 3) popup: обновляем ТОЛЬКО внутренности, не трогая сам .menu-item
68		var newPopup = newMenuItem.querySelector('.basket-popup');
69		var curPopup = curMenuItem.querySelector('.basket-popup');
70
71		if (newPopup && curPopup)
72		{
73			// оставляем старый DOM-узел popup (курсору проще), меняем его контент
74			curPopup.innerHTML = newPopup.innerHTML;
75		}
76		else if (newPopup && !curPopup)
77		{
78			// попап появился
79			curMenuItem.appendChild(newPopup);
80		}
81		else if (!newPopup && curPopup)
82		{
83			// попап исчез (корзина стала пустой)
84			curPopup.parentNode.removeChild(curPopup);
85		}
86	},
87
88	removeItemFromCart: function (id)
89	{
90		this.refreshCart({ sbblRemoveItemFromCart: id });
91		BX.onCustomEvent('OnBasketChange');
92	}
93};

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.