Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-menusub-1.0.js

Код файла
Версия от 18.08.2026, 07:00:17 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
2001		var wrapper = column.closest('.t-menusub__innermenu-wrapper');2002		var calculatedMaxHeight;2003		if (wrapper) {2004			var overflow = rect.bottom - winHeight + bottomPadding;2005			var currentTop = parseFloat(wrapper.style.top) || 0;2006			var newTop = currentTop - overflow;2007 2008			// Не поднимать выше 02009			if (newTop < 0) {2010				// Если не можем поднять достаточно — добавляем скролл2011				wrapper.style.top = '0px';2012
История файла и сравнение версий
  • 18.08.2026, 07:00:17 · 56c3b845
var wrapperRect = wrapper.getBoundingClientRect();
2013 calculatedMaxHeight = winHeight - wrapperRect.top - bottomPadding;
2014 if (calculatedMaxHeight > 0) {
2015 column.style.maxHeight = calculatedMaxHeight + 'px';
2016 column.style.overflowY = 'auto';
2017 }
2018 } else {
2019 wrapper.style.top = newTop + 'px';
2020 }
2021 } else {
2022 // Для content (2-й уровень) — только скролл
2023 calculatedMaxHeight = winHeight - rect.top - bottomPadding;
2024 if (calculatedMaxHeight > MENU_MIN_SCROLL_HEIGHT) {
2025 column.style.maxHeight = calculatedMaxHeight + 'px';
2026 column.style.overflowY = 'auto';
2027 }
2028 }
2029 }
2030}
2031
2032/**
2033 * Проверка, находится ли элемент внутри "зоны меню"
2034 * @param {HTMLElement} element - проверяемый элемент
2035 * @param {Object} ctx - контекст
2036 * @returns {boolean} - true если элемент внутри зоны меню
2037 */
2038function t_menusub__isInsideMenuZone(element, ctx) {
2039 if (!element) return false;
2040
2041 return (
2042 ctx.content.contains(element) ||
2043 (ctx.innerMenu && ctx.innerMenu.contains(element)) ||
2044 Array.prototype.slice.call(ctx.innermenuWrappers).some(function (w) {
2045 return w.contains(element);
2046 }) ||
2047 (ctx.menuWrapper && ctx.menuWrapper.contains(element)) ||
2048 (element.nodeName === 'HTML' && ctx.innermenuWrappers.length > 0)
2049 );
2050}
2051
2052// shouldIgnoreMouseout и shouldIgnoreInnermenuLeave удалены - используем isInsideMenuZone напрямую
2053
2054/**
2055 * Универсальные обработчики событий для обоих режимов (десктоп/мобайл)
2056 * @param {Object} ctx - контекст с необходимыми переменными
2057 */
2058function t_menusub__initUniversalHandlers(ctx) {
2059 var showTimer = null;
2060 var hideTimer = null;
2061 var mouseEnterEvent = new Event('submenu:mouseenter');
2062
2063 ctx.content.addEventListener('mouseover', function (e) {
2064 if (!t_menusub__isDesktopMode) return;
2065
2066 var link = e.target.closest(MENU_SELECTORS.LINK);
2067 if (!link) return;
2068
2069 var linkParentList = link.closest(MENU_SELECTORS.LIST);
2070 var contentList = ctx.content.querySelector(MENU_SELECTORS.CONTENT_LIST);
2071 if (linkParentList !== contentList) return;
2072
2073 var hook = link.getAttribute('data-menu-submenu-hook');
2074
2075 clearTimeout(showTimer);
2076 clearTimeout(hideTimer);
2077 ctx.rootSubmenu.dispatchEvent(mouseEnterEvent);
2078
2079 var parentLi = link.closest(MENU_SELECTORS.LIST_ITEM);
2080 t_menusub__clearHoverlinks(ctx.rootSubmenu, parentLi);
2081 if (parentLi) parentLi.classList.add(MENU_CLASSES.HOVERLINK);
2082
2083 if (!hook) {
2084 hideTimer = setTimeout(function () {
2085 t_menusub__hideChildMenu(ctx);
2086 }, 0);
2087 return;
2088 }
2089
2090 showTimer = setTimeout(function () {
2091 t_menusub__showInnermenuOnHover(ctx, link, parentLi);
2092 }, 0);
2093 });
2094
2095 ctx.content.addEventListener('mouseout', function (e) {
2096 if (!t_menusub__isDesktopMode) return;
2097
2098 var toElement = e.relatedTarget;
2099 clearTimeout(showTimer);
2100
Предыдущие 100 строкСледующие 100 строк