(function() { if (!document.querySelector('.js-head-benefits')) { document.body.dataset.benefitBar = false; } else { var windowInnerWidth = window.innerWidth; bnUpdateHeightElement(); setTimeout(bnUpdateHeightElement, 3000); window.addEventListener('resize', function () { if (windowInnerWidth != window.innerWidth) { windowInnerWidth = window.innerWidth; setTimeout(bnUpdateHeightElement, 10) } }); document.addEventListener("bnUpdateHeightElement", (event) => { setTimeout(bnUpdateHeightElement, 10) }); document.addEventListener("missySlickSliderLoaded", function () { var $jsHeadBenefits = $('.js-head-benefits'); $jsHeadBenefits.on('init', function (event, slick) { document.dispatchEvent(new CustomEvent("bnUpdateHeightElement")); }); $jsHeadBenefits.slickSlider({ mobileOnly: true }) }); } function bnUpdateHeightElement() { var actualHeight = 0, elementsArrayForHeight = [ { querySelector: window.innerWidth >= 1200 ? '.page-header' : '.page-header .header.content' }, { querySelector: '.js-head-benefits' } ] elementsArrayForHeight.forEach((element => { var findElement = document.querySelector(element.querySelector); if (findElement) { actualHeight += parseInt(findElement.offsetHeight) } })); var body = document.querySelector('body'), bodyStyles = window.getComputedStyle(body), bodyPadding = parseInt(bodyStyles.getPropertyValue("padding-top")), navSectionsElement = document.querySelector('.nav-sections'), searchBlock = document.querySelector('.header-tool--search .block-search'), closeMenuButton = document.querySelector('.close-mobile-menu'); if (actualHeight !== bodyPadding) { body.style.paddingTop = actualHeight + "px"; if (navSectionsElement && searchBlock && closeMenuButton) { if (window.innerWidth >= 768 && window.innerWidth <= 1199) { navSectionsElement.style.top = actualHeight + 'px'; navSectionsElement.style.height = 'calc(100% - ' + actualHeight + 'px)'; searchBlock.style.top = actualHeight + 'px'; closeMenuButton.style.top = actualHeight + 'px'; } else { navSectionsElement.style.top = ''; navSectionsElement.style.height = ''; searchBlock.style.top = ''; closeMenuButton.style.top = ''; } } } } })();