201202// иначе мы имеем дело с якорной ссылкой вставленной через настройки блока203// поэтому ищем близлежащий блок, прописываем ссылке айдишник и возвращаем элемент ссылки204// (чтобы пройти дальнейшую проверку на айдишник)205var recordBlock = document.querySelector(linkSelector + '+ .r');206if (recordBlock) {207linkEl.id = recordBlock ? recordBlock.id + '_' + selector : '';208return linkEl;209}210211return null;212
}}/** * find active link by connected section, placed in viewport and set to it class .t-active * * @param {HTMLElement[]} navLinks - nav links * @param {HTMLElement[]} sections - connected with navlinks sections by hooks * @param {Object} sectionToNavigationLinkID - object which placed id key and section value * @param {null | string} clickedSectionID - id of clicked hook (section) */function t_menuBase__highlightNavLinks(navLinks, sections, sectionToNavigationLinkID, clickedSectionID) { if (document.documentElement.classList.contains('t-body_scroll-locked')) return null; var scrollPosition = window.pageYOffset; var scrollHeight = Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); var returnValue = clickedSectionID; var lastSection = sections.length ? sections[sections.length - 1] : null; var lastSectionTopPos = lastSection ? parseInt(lastSection.getAttribute('data-offset-top'), 10) || 0 : 0; // if first section is not at the page top (under first blocks) if (sections.length && clickedSectionID === null && lastSectionTopPos > scrollPosition + 300) { navLinks.forEach(function (link) { link.classList.remove('t-active'); }); return null; } for (var i = 0; i < sections.length; i++) { var sectionTopPos = parseInt(sections[i].getAttribute('data-offset-top'), 10); var navLink = sections[i].id ? sectionToNavigationLinkID[sections[i].id] : null; if (scrollPosition + 300 >= sectionTopPos || (i === 0 && scrollPosition >= scrollHeight - window.innerHeight)) { if (clickedSectionID === null && navLink && !navLink.classList.contains('t-active')) { navLinks.forEach(function (link) { link.classList.remove('t-active'); }); if (navLink) navLink.classList.add('t-active'); returnValue = null; } else if (clickedSectionID !== null && sections[i].id && clickedSectionID === sections[i].id) { returnValue = null; } break; } } return returnValue;}/** * set background color for menu from data-attribute * * @param {string} recid - record ID * @param {string} selector - '.t456' etc. */function t_menuBase__setBGcolor(recid, selector) { var menuBlocks = document.querySelectorAll(selector); Array.prototype.forEach.call(menuBlocks, function (menu) { if (window.innerWidth > 960) { if (menu.getAttribute('data-bgcolor-setbyscript') === 'yes') { menu.style.backgroundColor = menu.getAttribute('data-bgcolor-rgba'); } } else { menu.style.backgroundColor = menu.getAttribute('data-bgcolor-hex'); menu.setAttribute('data-bgcolor-setbyscript', 'yes'); // show mobile menu after slideUp animation if (menu.style.transform) menu.style.transform = ''; if (menu.style.opacity) menu.style.opacity = ''; } });}/** * show and hide fixed menu, if user set option 'menu appearing when scrolling through N pixels'. * Only for desktop, except some classes, placed inside exceptionClasses Array. * * @param {string} recid - record ID * @param {string} selector - '.t456' etc. */function t_menuBase__showFixedMenu(recid, selector) { const exceptionClasses = ['.t280', '.t282', '.t450', '.t451', '.t466', '.t453']; const isHasExceptionClass = exceptionClasses.some(function (className) { return className === selector; });