501var opacity = 1;502duration = parseInt(duration, 10);503var speed = duration > 0 ? duration / 10 : 40;504var timer = setInterval(function () {505element.style.opacity = opacity;506opacity -= 0.1;507if (opacity <= 0.1) {508element.style.opacity = '0';509element.style.display = 'none';510if (typeof callback === 'function') {511callback();512}
clearInterval(timer); } }, speed);}function t_menu__fadeIn(element, duration, callback) { if (!element) return false; if ( (getComputedStyle(element).opacity === '1' || getComputedStyle(element).opacity === '') && getComputedStyle(element).display !== 'none' ) return false; var opacity = 0; duration = parseInt(duration, 10); var speed = duration > 0 ? duration / 10 : 40; element.style.opacity = opacity; element.style.display = 'block'; var timer = setInterval(function () { element.style.opacity = opacity; opacity += 0.1; if (opacity >= 1) { element.style.opacity = '1'; if (typeof callback === 'function') { callback(); } clearInterval(timer); } }, speed);}function t_menu__slideElement(menu, menuHeight, direction) { var diff = direction === 'toTop' ? 0 : menuHeight; var diffOpacity = direction === 'toTop' ? 1 : 0; var timerID = setInterval(function () { menu.style.transform = 'translateY(-' + diff + 'px)'; menu.style.opacity = diffOpacity.toString(); diffOpacity = direction === 'toTop' ? diffOpacity - 0.1 : diffOpacity + 0.1; diff = direction === 'toTop' ? diff + menuHeight / 20 : diff - menuHeight / 20; if (direction === 'toTop' && diff >= menuHeight) { menu.style.transform = 'translateY(-' + menuHeight + 'px)'; menu.style.opacity = '0'; clearInterval(timerID); } if (direction === 'toBottom' && diff <= 0) { menu.style.transform = 'translateY(0px)'; menu.style.opacity = '1'; clearInterval(timerID); } }, 10);}/** * a11y * Interact with menu and submenu from keyboard * @param {string} recid - record ID */function t_menu__interactFromKeyboard(recid) { var rec = document.getElementById('rec' + recid); if (!rec) return; var menuItems = rec.querySelectorAll('.t-menu__list > li > a'); var submenuItems = rec.querySelectorAll('.t-menu__list > li li'); var keysCode = { tab: 9, enter: 13, esc: 27, space: 32, }; var menuCurrentIndex = 0; var submenuCurrentIndex; var t_menu__focusOnCurrentMenuItem = function (index) { if (index === menuItems.length) { index = 0; } else if (index < 0) { index = menuItems.length - 1; } menuItems[index].focus(); menuCurrentIndex = index; }; var t_menu__focusOnCurrentSubmenuItem = function (menu, index) { var items = menu.querySelectorAll('a'); if (index == items.length) { index = 0;