(() => { const { EventManager, utils } = ShopbySkin; const { isMobileDevice } = utils; // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.initialize({ apiOption: { platform: 'MOBILE_WEB', }, }).then(() => { EventManager.fire('QUERY_PAGE_SCRIPTS', ShopbyExternalScript?.scripts); }); EventManager.on('PAGE_LOAD_COMPLETED', ({ profile }) => { // 외부스크립트 등록 기능. 삭제금지 ShopbyExternalScript?.setGlobalObjectSb({ getPlatform: () => (isMobileDevice ? 'MOBILE_WEB' : 'PC'), profile, }); }); const searchParams = new URLSearchParams(location.search); const trackingKey = searchParams.get('trackingKey'); const channelType = searchParams.get('channelType'); const { setTrackingKey, setChannelType } = ShopbySkin.utils; setTrackingKey(trackingKey); setChannelType(channelType); /* 헤더 고정 */ const header = document.querySelector('header'); window.addEventListener('scroll', function (e) { if (window.pageYOffset > 0) { header.classList.add('fixed'); } else { header.classList.remove('fixed'); } }); // 헤더 높이값 고정 const headW = document.querySelector('shopby-header-v2'); var headerHeight = headW.offsetHeight; if (!headW || !headW.nextElementSibling) return; const nextEl = headW.nextElementSibling; const isProductDetail = nextEl.id === 'productDetailWrap'; const isMain = nextEl.tagName === 'MAIN'; const isMainProductList = isMain && nextEl.classList.contains('product-list'); nextEl.style.paddingTop = isProductDetail || (isMain && !isMainProductList) ? headerHeight + 'px' : headerHeight + 51 + 'px'; /* 상단 검색 버튼 trigger */ const containerEl = document.querySelector('header'); const topSearchTrigger = async () => { const defaultSearchBtn = document.querySelector('.nav-bottom__search'); const headerSearchBtn = document.querySelector('.header-search-btn'); if (defaultSearchBtn) { defaultSearchBtn.click(); } }; const clickEventListener = ({ target }) => { const action = target.getAttribute('shopby-action'); if (action === 'SEARCH') { topSearchTrigger(); } }; containerEl.addEventListener('click', clickEventListener); })();