메뉴 여닫기
환경 설정 메뉴 여닫기
개인 메뉴 여닫기
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

미디어위키:Common.js: 두 판 사이의 차이

novawiki
편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
태그: 수동 되돌리기
31번째 줄: 31번째 줄:
     }, true);
     }, true);
})();
})();
mw.hook('mobileFrontend.search.open').add(function () {
  mw.notify('search.open fired');
});

2026년 1월 17일 (토) 18:36 판

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */

/**
 * 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);
})();