다른 명령
편집 요약 없음 |
편집 요약 없음 |
||
| 6번째 줄: | 6번째 줄: | ||
* Improves UX by immediately opening the virtual keyboard | * Improves UX by immediately opening the virtual keyboard | ||
*/ | */ | ||
(function () { | |||
function focusSearch() { | |||
const input = | const input = | ||
document.querySelector('.citizen-search__input') || | document.querySelector('.citizen-search__input') || | ||
| 15번째 줄: | 15번째 줄: | ||
if (input) { | if (input) { | ||
input.focus({ preventScroll: true }); | input.focus({ preventScroll: true }); | ||
input.click(); | input.click(); | ||
} | } | ||
} | } | ||
requestAnimationFrame(() => requestAnimationFrame( | // 검색 버튼/아이콘(스킨마다 다름)에서 이벤트로 잡기 | ||
}); | document.addEventListener('click', function (e) { | ||
// Citizen/모바일에서 검색 토글 버튼 후보들 | |||
const isSearchButton = | |||
e.target.closest('.citizen-search__button, .mw-ui-icon-search, .search-toggle, a[title="Search"], button[title="Search"]'); | |||
if (!isSearchButton) return; | |||
// 버튼 누른 "직후" 입력창이 생기므로 프레임 2번 정도만 양보 | |||
requestAnimationFrame(() => requestAnimationFrame(focusSearch)); | |||
}, true); | |||
})(); | |||
2026년 1월 17일 (토) 18:33 판
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
/**
* Autofocus search input on mobile
* Triggered when MobileFrontend search UI opens
* Improves UX by immediately opening the virtual keyboard
*/
(function () {
function focusSearch() {
const input =
document.querySelector('.citizen-search__input') ||
document.querySelector('#searchInput') ||
document.querySelector('input[type="search"]');
if (input) {
input.focus({ preventScroll: true });
input.click();
}
}
// 검색 버튼/아이콘(스킨마다 다름)에서 이벤트로 잡기
document.addEventListener('click', function (e) {
// Citizen/모바일에서 검색 토글 버튼 후보들
const isSearchButton =
e.target.closest('.citizen-search__button, .mw-ui-icon-search, .search-toggle, a[title="Search"], button[title="Search"]');
if (!isSearchButton) return;
// 버튼 누른 "직후" 입력창이 생기므로 프레임 2번 정도만 양보
requestAnimationFrame(() => requestAnimationFrame(focusSearch));
}, true);
})();