/* ══════════════════════════════════════════════════════ Выезжающий слайдер «Что нового в классе» ══════════════════════════════════════════════════════ */ (function () { var slider = document.getElementById('newsSlider'); var toggle = document.getElementById('newsToggle'); var closeBtn = document.getElementById('newsClose'); var backdrop = document.getElementById('newsBackdrop'); if (!slider || !toggle) return; function open() { slider.classList.add('open'); toggle.setAttribute('aria-expanded', 'true'); document.body.style.overflow = 'hidden'; } function close() { slider.classList.remove('open'); toggle.setAttribute('aria-expanded', 'false'); document.body.style.overflow = ''; } function togglePanel() { if (slider.classList.contains('open')) close(); else open(); } toggle.addEventListener('click', togglePanel); if (closeBtn) closeBtn.addEventListener('click', close); if (backdrop) backdrop.addEventListener('click', close); document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && slider.classList.contains('open')) close(); }); // Счётчик новостей var countEl = document.getElementById('newsCount'); if (countEl) { var items = slider.querySelectorAll('.news-item'); countEl.textContent = items.length; } // Скрываем, если не на главной var isHome = /(^|\/)index\.html$/.test(window.location.pathname) || window.location.pathname === '/' || window.location.pathname.endsWith('/'); var isInSubfolder = /\/(tests|[0-9]+|basy|sosedi|backlog)\//.test(window.location.pathname); if (!isHome || isInSubfolder) { slider.style.display = 'none'; return; } })();