const el = document.querySelectorAll('.faq-list__item'); const anchors = document.querySelectorAll('.faq-anchor'); const hash = window.location.hash; function getCoords(elem) { // кроме IE8- const box = elem.getBoundingClientRect(); return { top: box.top + pageYOffset, left: box.left + pageXOffset }; } function offsetTopChange(elem) { setTimeout(() => { const element = document.getElementById(elem); if (element && element.classList.contains('faq-list__item')) { element.classList.add('is-opened'); const targetItemCoords = getCoords(element); window.scrollTo(0, targetItemCoords.top - 100); } }, 0); }; if (hash) { window.addEventListener('load', () => { offsetTopChange(hash.slice(1)); }); } for(let i = 0; i < el.length; i++) { el[i].onclick = function(e) { if(!e.target.classList.contains('faq-anchor')) { this.classList.toggle('is-opened'); } }; } for(let i =0; i < anchors.length; i++) { anchors[i].onclick = function(e) { e.preventDefault(); const targetItem = anchors[i].getAttribute('href').slice(1); offsetTopChange(targetItem); }; } const urlString = document.URL; const url = new URL(urlString); const mobileApp = url.searchParams.get("mobileApp"); const logoLink = document.querySelectorAll(".header__logo a")[0]; if (mobileApp && logoLink) { logoLink.style.pointerEvents = "none"; } document.querySelectorAll('[data-autoresize]').forEach(function (element) { element.style.boxSizing = 'border-box'; var offset = element.offsetHeight - element.clientHeight; element.addEventListener('input', function (event) { if (event.target.scrollHeight > 170) { return; } event.target.style.height = 'auto'; event.target.style.height = event.target.scrollHeight + offset + 'px'; }); element.removeAttribute('data-autoresize'); });