(() => { 'use strict'; const view=new URL(location.href).searchParams.get('view'); const template=document.getElementById(view==='brand'?'brand-page-template':view==='details'?'guide-page-template':''); if(template){const main=document.querySelector('main');main.replaceChildren(template.content.cloneNode(true));main.classList.add('editorial-page');document.body.classList.add('is-editorial');document.title=(view==='brand'?'브랜드 스토리':'소재와 기능')+' | BISLEY KOREA';document.querySelectorAll('.nav a').forEach(a=>{if(new URL(a.href,location.href).searchParams.get('view')===view)a.setAttribute('aria-current','page');});} const nav = document.querySelector('.nav'); const menu = document.querySelector('.menu-button'); function closeMenu() { nav.classList.remove('open'); menu.setAttribute('aria-expanded','false'); menu.setAttribute('aria-label','메뉴 열기'); } menu.addEventListener('click', () => { const open = menu.getAttribute('aria-expanded') !== 'true'; nav.classList.toggle('open',open); menu.setAttribute('aria-expanded',String(open)); menu.setAttribute('aria-label',open?'메뉴 닫기':'메뉴 열기'); }); nav.querySelectorAll('a').forEach(a => a.addEventListener('click', closeMenu)); document.addEventListener('keydown', e => { if(e.key==='Escape')closeMenu(); }); const filters = [...document.querySelectorAll('[data-filter]')]; const products = [...document.querySelectorAll('.product')]; function applyFilter(category) { filters.forEach(b => { const active = b.dataset.filter===category; b.classList.toggle('active',active); b.setAttribute('aria-pressed',String(active)); }); let count=0; products.forEach(p => { const visible = category==='all'||p.dataset.category===category; p.hidden=!visible; if(visible)count++; }); document.querySelector('.product-count').textContent = count+' ITEMS'; } filters.forEach(b=>b.addEventListener('click',()=>applyFilter(b.dataset.filter))); document.querySelectorAll('[data-select]').forEach(a=>a.addEventListener('click',()=>applyFilter(a.dataset.select))); const gallery=document.querySelector('.campaign-hero'); if(gallery){ const looks=[...gallery.querySelectorAll('.campaign-frame')]; const controls=gallery.querySelector('.campaign-controls'); const buttons=[...controls.querySelectorAll('[data-look]')]; const status=gallery.querySelector('.campaign-status'); let current=0; function showLook(index){ current=(index+looks.length)%looks.length; looks.forEach((look,i)=>{look.hidden=i!==current;}); buttons.forEach((button,i)=>button.setAttribute('aria-pressed',String(i===current))); status.textContent=looks[current].getAttribute('aria-label'); } controls.hidden=false; buttons.forEach((button,i)=>button.addEventListener('click',()=>showLook(i))); controls.addEventListener('keydown',event=>{ if(event.ctrlKey||event.metaKey||event.altKey)return; if(!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return; event.preventDefault(); showLook(event.key==='Home'?0:event.key==='End'?looks.length-1:current+(event.key==='ArrowRight'?1:-1)); buttons[current].focus(); }); let touchStart=null; gallery.addEventListener('touchstart',event=>{const t=event.changedTouches[0];touchStart={x:t.clientX,y:t.clientY};},{passive:true}); gallery.addEventListener('touchend',event=>{if(!touchStart)return;const t=event.changedTouches[0],dx=t.clientX-touchStart.x,dy=t.clientY-touchStart.y;if(Math.abs(dx)>60&&Math.abs(dx)>Math.abs(dy)*1.5)showLook(current+(dx<0?1:-1));touchStart=null;},{passive:true}); } })(); /* Main category photography from the shared catalogue */ (()=>{const D=window.BisleyCatalogue;if(!D)return;document.querySelectorAll('.shop-by-type .type-grid>a').forEach(a=>{const p=D.products.find(p=>p.category===new URL(a.href,location.href).searchParams.get('cate_code')),img=a.querySelector('.type-image img');if(!p||!img)return;img.src=D.base+p.image;img.style.setProperty('--type-photo-scale',p.scale);img.style.setProperty('--type-photo-mobile-scale',p.mobileScale);});})();