Главная Магазин Услуги Проекты Калькулятор Контакты Корзина
Написать в WhatsApp +7 (707) 705-99-77 Войти

Каталог товаров

Камеры видеонаблюдения, регистраторы, кабель и сетевое оборудование в наличии на складе

Сбросить
стр. 1/3
const btns = document.querySelectorAll('.view-btn'); if (!btns.length) return; // Восстановить из localStorage let saved = 'grid'; try { saved = localStorage.getItem('shop_view') || 'grid'; } catch(e){} if (saved !== 'grid' && saved !== 'list') saved = 'grid'; function setView(v) { grid.setAttribute('data-view', v); btns.forEach(b => b.classList.toggle('active', b.dataset.view === v)); try { localStorage.setItem('shop_view', v); } catch(e){} } setView(saved); btns.forEach(b => b.addEventListener('click', function(){ setView(this.dataset.view); })); })(); // Sidebar drawer (mobile/tablet — открывается по кнопке "Все категории") function openSidebar(){ document.getElementById('shopSidebar')?.classList.add('show'); document.getElementById('sidebarOverlay')?.classList.add('show'); document.body.classList.add('sidebar-open'); } function closeSidebar(){ document.getElementById('shopSidebar')?.classList.remove('show'); document.getElementById('sidebarOverlay')?.classList.remove('show'); document.body.classList.remove('sidebar-open'); } // ESC закрывает drawer document.addEventListener('keydown', function(e){ if (e.key === 'Escape') closeSidebar(); }); // Плавное появление карточек товаров при попадании в viewport (function(){ const cards = document.querySelectorAll('.product-card'); if (!cards.length) return; // Если IntersectionObserver не поддерживается — просто показываем все if (!('IntersectionObserver' in window)) { cards.forEach(c => c.classList.add('in-view')); return; } const io = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('in-view'); io.unobserve(entry.target); } }); }, { rootMargin: '50px 0px', threshold: 0.05 }); cards.forEach(c => io.observe(c)); // Для уже загруженных картинок (из кэша) сразу проставляем .loaded document.querySelectorAll('.lazy-img').forEach(img => { if (img.complete && img.naturalHeight !== 0) img.classList.add('loaded'); }); })(); function addToCart(pid, btn) { const orig = btn.innerHTML; btn.disabled = true; btn.innerHTML = '' + 'Добавлено' + ''; const fd = new FormData(); fd.set('cart_action', 'add'); fd.set('product_id', pid); fd.set('qty', 1); fetch('/cart.php', { method: 'POST', body: fd }) .then(r => r.json()) .then(d => { document.querySelectorAll('.cart-badge').forEach(el => { el.textContent = d.count; el.style.display = d.count > 0 ? 'flex' : 'none'; }); setTimeout(() => { btn.disabled = false; btn.innerHTML = orig; }, 1200); }); } // Close filter dropdowns on outside click document.addEventListener("click", function(e) { if (!e.target.closest(".hz-filter-group")) { document.querySelectorAll(".hz-filter-dropdown.show").forEach(function(d) { d.classList.remove("show"); }); } }); function applyPropFilter(name, value) { const url = new URL(window.location); if (value) { url.searchParams.set('prop[' + name + ']', value); } else { url.searchParams.delete('prop[' + name + ']'); } url.searchParams.delete('page'); window.location = url.toString(); }