PageSourceSearch

https://t-triumph.ru/bitrix/templates/.default/components/bitrix/menu/mobile-menu-tree/script.js

js t-triumph.ru collected 2026-10-10 00:53:09 UTC 6,096 bytes, 262 lines download raw bytes

1(function(window) {
2
3	if (!window.BX || BX.CatalogMenu)
4		return;
5
6	BX.CatalogMenu = {
7		items : {},
8		idCnt : 1,
9		currentItem : null,
10		overItem : null,
11		outItem : null,
12		timeoutOver : null,
13		timeoutOut : null,
14
15		getItem : function(item)
16		{
17			if (!BX.type.isDomNode(item))
18				return null;
19
20			var id = !item.id || !BX.type.isNotEmptyString(item.id) ? (item.id = "menu-item-" + this.idCnt++) : item.id;
21
22			if (!this.items[id])
23				this.items[id] = new CatalogMenuItem(item);
24
25			return this.items[id];
26		},
27
28		itemOver : function(item)
29		{
30			var menuItem = this.getItem(item);
31			if (!menuItem)
32				return;
33
34			if (this.outItem == menuItem)
35			{
36				clearTimeout(menuItem.timeoutOut);
37			}
38
39			this.overItem = menuItem;
40
41			if (menuItem.timeoutOver)
42			{
43				clearTimeout(menuItem.timeoutOver);
44			}
45
46			menuItem.timeoutOver = setTimeout(function() {
47				if (BX.CatalogMenu.overItem == menuItem)
48				{
49					menuItem.itemOver();
50				}
51
52			}, 100);
53		},
54
55		itemOut : function(item)
56		{
57			var menuItem = this.getItem(item);
58			if (!menuItem)
59				return;
60
61			this.outItem = menuItem;
62
63			if (menuItem.timeoutOut)
64			{
65				clearTimeout(menuItem.timeoutOut);
66			}
67
68			menuItem.timeoutOut = setTimeout(function() {
69
70				if (menuItem != BX.CatalogMenu.overItem)
71				{
72					menuItem.itemOut();
73				}
74				if (menuItem == BX.CatalogMenu.outItem)
75				{
76					menuItem.itemOut();
77				}
78
79			}, 100);
80		},
81
82		removeHover : function(curItem)
83		{
84			if (typeof curItem !== "object")
85				return false;
86
87			var items = curItem.parentNode.querySelectorAll('[data-role="bx-menu-item"]');
88			for (var i=0; i<items.length; i++)
89			{
90				if (curItem == items[i])
91					continue;
92
93				if (BX.hasClass(items[i], "bx-hover"))
94					BX.removeClass(items[i], "bx-hover")
95			}
96		}
97	};
98
99	var CatalogMenuItem = function(item)
100	{
101		this.element = item;
102		this.popup = BX.findChild(item, { className: "bx_children_container" }, false, false);
103		this.isLastItem = BX.lastChild(this.element.parentNode) == this.element;
104	};
105
106	CatalogMenuItem.prototype.itemOver = function()
107	{
108		if (!BX.hasClass(this.element, "bx-hover"))
109		{
110			BX.addClass(this.element, "bx-hover");
111
112			var popup = BX.findChild(this.element, {className:"bx-nav-2-lvl-container"}, true, false);
113			if (popup)
114			{
115				var popupRightEdge = popup.getBoundingClientRect().left + popup.offsetWidth;
116				if (popupRightEdge > document.body.clientWidth)
117					popup.style.right = 0;
118			}
119		}
120	};
121
122	CatalogMenuItem.prototype.itemOut = function()
123	{
124		BX.removeClass(this.element, "bx-hover");
125	};
126})(window);
127
128BX.namespace("BX.Main.Menu");
129BX.Main.Menu.CatalogHorizontal = (function()
130{
131	var CatalogHorizontal = function(menuBlockId, itemImgDesc)
132	{
133		this.menuBlockId = menuBlockId || "";
134		this.itemImgDesc = itemImgDesc || "";
135
136		this.resizeMenu();
137		BX.bind(window, "resize", BX.proxy(this.resizeMenu, this));
138	};
139
140	CatalogHorizontal.prototype.clickInMobile = function(element, event)
141	{
142		if (BX.findParent(element, {className: "bx-aside-nav"}, true))
143			return;
144
145		event.preventDefault();
146		element.onclick = '';
147		return false;
148	};
149
150	CatalogHorizontal.prototype.toggleInMobile = function(element)
151	{
152		var parentObj = BX.findParent(element, {className: "bx-nav-parent"});
153		var arrow = element.firstChild;
154		if (BX.hasClass(parentObj, "bx-opened"))
155		{
156			BX.removeClass(parentObj, "bx-opened");
157			BX.removeClass(arrow, "fa-angle-down");
158			BX.addClass(arrow, "fa-angle-left");
159		}
160		else
161		{
162			BX.addClass(parentObj, "bx-opened");
163			BX.addClass(arrow, "fa-angle-down");
164			BX.removeClass(arrow, "fa-angle-left");
165		}
166	};
167
168	CatalogHorizontal.prototype.resizeMenu = function()
169	{
170		var templateWrap = this.templateWrap;
171		var menuMobile = document.body.querySelector("[data-role='bx-menu-mobile']");
172		var menuMobileButton = document.body.querySelector("[data-role='bx-menu-button-mobile']");
173
174		if (document.body.clientWidth <= 767) //mobile
175		{
176			if (!menuMobile)
177			{
178				menuMobile = BX.create("div", {
179					attrs: {
180						className: "bx-aside-nav",
181						"data-role" : "bx-menu-mobile"
182					},
183					children: [ BX.clone(BX("ul_" + this.menuBlockId)) ]
184				});
185				document.body.insertBefore(menuMobile, document.body.firstChild);
186			}
187
188			if (!menuMobileButton)
189			{
190				menuMobileButton = BX.create("div", {
191					attrs: {className: "bx-aside-nav-control bx-closed", "data-role" : "bx-menu-button-mobile"},
192					children: [
193						BX.create("i", {
194							attrs: {className: "fa fa-bars"}
195						})
196					],
197					events: {
198						"click" : function() {
199							if (BX.hasClass(this, "bx-opened"))
200							{
201								BX.removeClass(this, 'bx-opened');
202								BX.removeClass(menuMobile, 'bx-opened');
203								BX.addClass(this, 'bx-closed');
204								document.body.style.overflow = "";
205								BX.removeClass(document.body, 'bx-opened');
206							}
207							else
208							{
209
210								BX.addClass(this, 'bx-opened');
211								BX.addClass(menuMobile, 'bx-opened');
212								BX.removeClass(this, 'bx-closed');
213								document.body.style.overflow = "hidden";
214								BX.addClass(document.body, 'bx-opened');
215							}
216						}
217					}
218				});
219
220				document.body.insertBefore(menuMobileButton, document.body.firstChild);
221			}
222		}
223		else
224		{
225			BX.removeClass(menuMobile, 'bx-opened');
226			BX.removeClass(document.body, 'bx-opened');
227			document.body.style.overflow = "";
228
229			if (menuMobileButton)
230				BX.removeClass(menuMobileButton, 'bx-opened');
231		}
232	};
233
234	CatalogHorizontal.prototype.changeSectionPicure = function(element, itemId)
235	{
236		var curLi = BX.findParent(element, {className: "bx-nav-1-lvl"});
237		if (!curLi)
238			return;
239
240		var imgDescObj = curLi.querySelector("[data-role='desc-img-block']");
241		if (!imgDescObj)
242			return;
243
244		var imgObj = BX.findChild(imgDescObj, {tagName: "img"}, true, false);
245		if (imgObj)
246			imgObj.src = this.itemImgDesc[itemId]["PICTURE"];
247
248		var linkObj = BX.findChild(imgDescObj, {tagName: "a"}, true, false);
249		if (linkObj)
250			linkObj.href = element.href;
251
252		var descObj = BX.findChild(imgDescObj, {tagName: "p"}, true, false);
253		if (descObj)
254			descObj.innerHTML = this.itemImgDesc[itemId]["DESC"];
255
256	};
257
258	return CatalogHorizontal;
259})();
260
261
262

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.