script>
(function () {
window.PF_GNB_MOBILE_SEARCH_WIDGET_ID =
window.PF_GNB_MOBILE_SEARCH_WIDGET_ID || 'w202405231ccfa5b54a58e';
/** 모바일만 스타일 적용 (데스크톱 동시 DOM 에도 안전) */
function ensureMobilePfStyles() {
if (document.getElementById('pf-gnb-portfolio-search-mobile-style')) return;
var st = document.createElement('style');
st.id = 'pf-gnb-portfolio-search-mobile-style';
st.textContent = [
'/* 기존 검색 슬롯 레이아웃 유지 — 아이콘만 교체·색상 */',
'.pf-portfolio-mobile-search--pf .search_btn .holder{',
'display:inline-flex!important;align-items:center!important;justify-content:center!important;',
'}',
'.pf-portfolio-mobile-search--pf .search_btn a{',
'display:inline-flex!important;align-items:center!important;justify-content:center!important;',
'min-width:0!important;padding:0!important;margin:0!important;',
'color:#333!important;text-decoration:none!important;line-height:0!important;',
'-webkit-tap-highlight-color:transparent;',
'}',
'.pf-portfolio-mobile-search--pf .search_btn .pf-mobile-pf-gnb-svg{',
'display:block!important;width:22px!important;height:22px!important;',
'color:#333!important;stroke:#333!important;',
'}',
'.pf-portfolio-mobile-search--pf .search_btn .search_btn_form{',
'display:none!important;',
'}',
'.pf-portfolio-mobile-search--pf .search_btn form.icon_on{',
'margin:0!important;padding:0!important;',
'}',
].join('');
(document.head || document.documentElement).appendChild(st);
}
/**
* 글로벌 스니펫이 나중에 넣어주는 경우 대비 — id 하나만 유지.
*/
function ensurePfSearchGnbInput() {
if (document.getElementById('pf-search-gnb')) return;
var inp = document.createElement('input');
inp.type = 'text';
inp.id = 'pf-search-gnb';
inp.className = 'pf-gnb-portfolio-search-sync';
inp.setAttribute('tabindex', '-1');
inp.setAttribute('autocomplete', 'off');
inp.setAttribute('aria-hidden', 'true');
inp.style.cssText =
'position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;' +
'overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important;';
document.body.appendChild(inp);
}
function svgMagnifierHtml() {
return (
''
);
}
function installMobilePortfolioSearch() {
var wid = window.PF_GNB_MOBILE_SEARCH_WIDGET_ID;
var widget = wid ? document.getElementById(wid) : null;
if (!widget) return false;
if (widget.getAttribute('data-pf-mobile-pf-installed') === '1') return true;
var anchor = widget.querySelector('.search_btn a[href], .search_btn form a');
if (!anchor) return false;
widget.setAttribute('data-pf-mobile-pf-installed', '1');
widget.classList.add('pf-portfolio-mobile-search--pf');
anchor.removeAttribute('onclick');
anchor.setAttribute('href', 'javascript:;');
anchor.setAttribute('role', 'button');
anchor.setAttribute('aria-label', '프로젝트 검색');
var mag = anchor.querySelector('i.icon-magnifier');
if (mag) {
mag.outerHTML = svgMagnifierHtml();
} else {
anchor.innerHTML = svgMagnifierHtml() + 'site search';
}
function openPfModal(ev) {
if (ev) {
ev.preventDefault();
ev.stopPropagation();
}
ensurePfSearchGnbInput();
if (typeof window.PF_PORTFOLIO_OPEN_SEARCH_MODAL === 'function') {
window.PF_PORTFOLIO_OPEN_SEARCH_MODAL();
}
}
anchor.addEventListener('click', openPfModal, false);
/** 사이트 기본 SITE_SEARCH 가 form 에 걸린 경우 보조 */
var form = widget.querySelector('.search_btn form');
if (form) {
form.addEventListener(
'submit',
function (ev) {
ev.preventDefault();
openPfModal(ev);
},
true
);
}
ensurePfSearchGnbInput();
try {
window.dispatchEvent(
new CustomEvent('pf-gnb-mobile-portfolio-search-installed', { bubbles: true })
);
} catch (e1) {}
return true;
}
function schedule() {
var n = 0;
function tick() {
try {
if (installMobilePortfolioSearch()) return;
if (++n < 80) setTimeout(tick, 125);
} catch (err) {
if (typeof console !== 'undefined' && console.warn) {
console.warn('[pf-gnb-portfolio-search-mobile]', err);
}
}
}
ensureMobilePfStyles();
tick();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', schedule);
} else {
schedule();
}
})();