1101pathname +1102'/"], ' +1103'.t-menusub a[href="/' +1104pathname +1105'/"]';11061107// Добавляем поиск по якорю (hash), если он есть1108if (hash && hash !== '') {1109selector += ', .t-menusub a[href="' + hash + '"]';1110}11111112var shouldBeActiveElements = document.querySelectorAll(selector);
Array.prototype.forEach.call(shouldBeActiveElements, function (element) { // Не добавлять t-active к ссылкам с подменю (они служат для раскрытия ветки) var hookAttr = element.getAttribute('data-menu-submenu-hook'); if (hookAttr && hookAttr !== '') return; t_menusub__addActiveClassWithParents(element); });}/** * special script for ME401 after showing submenu * * @param {HTMLElement} hookLink */function t_menusub__showME401Submenu(hookLink) { var wrapME401 = hookLink.closest('.t280'); var wrapME401Wrapper = wrapME401 ? wrapME401.querySelector('.t280__menu__wrapper') : null; if (!wrapME401Wrapper) return; var isMobileHeight = t_menusub__isMobileME401(wrapME401); var isStaticME401 = wrapME401Wrapper.getAttribute('data-submenu-static'); if (wrapME401Wrapper.classList.contains('t280__menu_static')) { wrapME401Wrapper.setAttribute('data-submenu-static', 'n'); } if (isStaticME401 === 'n' && isMobileHeight && !wrapME401Wrapper.classList.contains('t280__menu_static')) { var wrapME401Menu = wrapME401.querySelector('.t280__menu'); var wrapME401Bottom = wrapME401.querySelector('.t280__bottom'); if (wrapME401Menu) wrapME401Menu.style.transition = 'none'; if (wrapME401Bottom) wrapME401Bottom.style.transition = 'none'; if (wrapME401Wrapper) wrapME401Wrapper.classList.add('t280__menu_static'); }}/** * special script for ME401 after hidding submenu * * @param {HTMLElement} submenu */function t_menusub__hideME401Submenu(submenu) { var wrapME401 = submenu.closest('.t280'); if (!wrapME401) return; var isMobileHeight = t_menusub__isMobileME401(wrapME401); var wrapME401Wrapper = wrapME401.querySelector('.t280__menu__wrapper'); var isStaticME401 = wrapME401Wrapper ? wrapME401Wrapper.getAttribute('data-submenu-static') : ''; var wrapME401ShowMenus = wrapME401.querySelectorAll('.t280__menu .t-menusub__menu_show'); if ( isStaticME401 === 'n' && window.t_menusub__isMobile && isMobileHeight && !wrapME401ShowMenus.length && wrapME401Wrapper.classList.contains('t280__menu_static') ) { wrapME401Wrapper.classList.remove('t280__menu_static'); }}/** * check if submenu in ME401 is mobile * * @param {HTMLElement} wrapME401 - ME401 block * @returns {boolean} true | false */function t_menusub__isMobileME401(wrapME401) { var wrapME401Menu = wrapME401.querySelector('.t280__menu'); var wrapME401Bottom = wrapME401.querySelector('.t280__bottom'); var wrapME401Container = wrapME401.querySelector('.t280__container'); var menuHeight = wrapME401Menu ? wrapME401Menu.offsetHeight : 0; var menuBottomHeight = wrapME401Bottom ? wrapME401Bottom.offsetHeight : 0; var menuHeaderHeight = wrapME401Container ? wrapME401Container.offsetHeight : 0; var wrapperHeight = window.innerHeight - menuBottomHeight - menuHeaderHeight - 40; return menuHeight > wrapperHeight;}/** * mark active link by scroll. This operation contains with few functions: * 1. t_menusub__checkAnchorLinks() find all links, which can be active, and send it to t_menusub__catchScroll() * 2. in t_menusub__catchScroll() by scroll check current viewport position and connected with link section, * and if this section placed inside viewport, for link append active class * 3. to get connected section with link, use function t_menusub__getSectionByHref() * 4. to highlight link use function t_menusub__highlightNavLinks() * 5. if window width/height will be changed, need update sections position, that doing t_menusub__updateSectionsOffsets() * * * @param {string} recid - record id */function t_menusub__checkAnchorLinks(recid) { var rec = document.getElementById('rec' + recid);