PageSourceSearch

https://kuzbassizo.ru/js/menu.js

js kuzbassizo.ru collected 2026-10-02 20:02:36 UTC 2,719 bytes, 88 lines download raw bytes

1class MenuHandler{
2
3	menuButton;
4	menu;
5
6	//
7	//	Конструктор
8	//	params = {
9	//		menuButtonSelector	- селектор кнопки переключени бутерброда
10	//		menuSelector		- селектор контейнера меню
11	//	}
12	constructor(params){
13		this.menuButton = document.querySelector(params.menuButtonSelector);
14		this.menu = document.querySelector(params.menuSelector);
15		this.#menuInit();
16		this.#menuButtonInit();
17	}
18
19	//
20	//	Инициализация элементов меню
21	//
22	#menuInit(){
23		const that = this;
24		const delay = 300;
25		const items = this.menu.querySelectorAll(".items li A");
26		$(items).on({
27			// Для режима Смартфона
28			click: function(){
29				if(that.menuModePC()) return;
30				const currentItem = this;
31				items.forEach(item => {
32					if(item == currentItem){
33						$(item.parentNode.querySelector(".submenu")).slideToggle(delay);
34					} else {
35						$(item.parentNode.querySelectorAll(".submenu")).slideUp(delay);
36					}
37				});
38			}
39		});		
40	}
41
42	//
43	//	Инициализация кнопки бутерброда
44	//
45	#menuButtonInit(){
46		const that = this;
47		//	Скрыть/показать меню "бутерброда" в режиме смартфона
48		this.menuButton.onclick = function(){
49
50			// Если кнопка скрыта, значит режим ПК - выходим
51			if(that.menuModePC()) return;
52
53			// состояние кнопки
54			that.menuButton.classList.toggle('close')
55
56			// состояние меню
57			that.menu.classList.toggle('active')
58
59			// фикс ширины скролла, чтобы не было "скачков"
60			that.#modalFixScroll( that.menuButton.classList.contains('close') )
61
62			// фикс скролла у боди
63			document.body.classList.toggle('freeze')
64		}
65	}
66
67	//
68	//	Режим меню ПК или нет...
69	//
70	menuModePC(){
71		// Если кнопка скрыта, значит режим ПК
72		// console.log(this.menuButton);
73		return this.menuButton.offsetParent === null;
74		// return this.menuButton.style.display=="none";
75	}
76
77	//
78	//	Учитываем ширину скролла при открытии/закрытии модального окна
79	//
80	#modalFixScroll(isOpen){
81		const html = document.documentElement;
82		//ширина скроллбара равна разнице ширины окна и ширины док
82умента (селектора html)
83		const scrollWidth = window.innerWidth - html.clientWidth;
84		//при открытии и наличие разницы окна задаем оступ, иначе сбрасываем
85		html.style.marginRight = (isOpen && scrollWidth) ? scrollWidth + "px" : "";
86	}
87
88}

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.