(() => { const { EventManager, utils, constants } = ShopbySkin; const slideMenuEL = document.querySelector('slide-menu'); const slideMenuClickActionMap = { CLOSE_SLIDE_MENU: () => { EventManager.fire('TOGGLE_HEADER_SLIDE_MENU', { type: 'close' }); }, TOGGLE_SLIDE_MENU_CHILD_CATEGORY: (e) => { const categoryWrapEl = e?.target?.closest('[shopby-category-no]'); if (!categoryWrapEl) return; const parentUl = categoryWrapEl.closest('ul'); if (!parentUl) return; const siblingCategoryWrapEls = parentUl.querySelectorAll(':scope > li > [shopby-category-no]'); const isOpened = categoryWrapEl.classList.contains('is-opened'); // ✅ 같은 depth 안에서만 닫기 siblingCategoryWrapEls.forEach((el) => { el.classList.remove('is-opened'); }); // 토글 처리 if (!isOpened) { categoryWrapEl.classList.add('is-opened'); } // EventManager.fire('TOGGLE_SLIDE_MENU_CHILD_CATEGORY', { // wrapEl: categoryWrapEl, // }); }, SIGN_OUT: () => { slideMenuClickActionMap.CLOSE_SLIDE_MENU(); EventManager.fire('SIGN_OUT'); }, GO_MY_MENU: (e) => { if (!utils.isSignedIn()) { e.preventDefault(); slideMenuClickActionMap.CLOSE_SLIDE_MENU(); const from = e.target.href; const nextUrl = `${location.origin}${constants.PAGE.SIGN_IN}`; utils.moveTo({ url: `${nextUrl}?from=${encodeURIComponent(from)}` }); } else { if (!e.target.href) { return; } slideMenuClickActionMap.CLOSE_SLIDE_MENU(); utils.moveTo({ url: e.target.href }); } }, GO_NEXT: (event) => { event.preventDefault(); const { target } = event; const href = target?.href ?? target.closest('[shopby-action="GO_NEXT"]')?.href; if (!href) { return; } slideMenuClickActionMap.CLOSE_SLIDE_MENU(); utils.moveTo({ url: href }); }, }; const clickEventListener = (e) => { const action = e?.target?.closest('[shopby-action]')?.getAttribute('shopby-action'); slideMenuClickActionMap[action]?.(e); }; slideMenuEL?.addEventListener('click', clickEventListener); EventManager.fire('MYAPP:PROXY_REGISTER', { proxyFnKey: 'slideMenuProxy', applyProxy: (proxyFn) => { slideMenuEL?.removeEventListener('click', clickEventListener); slideMenuEL?.addEventListener('click', proxyFn(clickEventListener)); }, }); EventManager.on('PAGE_LOAD_COMPLETED', (commonData) => { const btnMenu = document.querySelector('#btnMenu'); if (btnMenu) { // 왼쪽 메뉴 열기, 닫기 document.querySelector('#btnMenu').addEventListener('click', function () { document.querySelector('#allMenu').classList.add('active'); document.body.classList.add('menu-open'); }); } function setScreenSize() { let vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); } setScreenSize(); window.addEventListener('resize', setScreenSize); document.querySelector('#menuClose').addEventListener('click', function (e) { document.querySelector('#allMenu').classList.remove('active'); document.querySelectorAll('.slide-menu__nav-category-label-wrap.is-opened').forEach(function (el) { el.classList.remove('is-opened'); }); document.body.classList.remove('menu-open'); }); //베스트/브랜드전용관/점주전용관 비노출 const targetCategories = ['1170271', '1170275', '1170277']; document.querySelectorAll('[data-category]').forEach(el => { if (targetCategories.includes(el.dataset.category)) { el.classList.add('is-hidden'); } }); if ( ShopbySkin.utils.isSignIn() ) { slideMenuEL.querySelector('.slide-menu__login-header-name').innerHTML = commonData.profile.memberName + '님'; } }); })();