Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Main page: the Search button opens the search box
 
Not needed: Citizen handles .citizen-search-trigger itself
Tag: Replaced
 
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
/* Main page: the big "Search" button opens the skin's search box. */
( function () {
if ( !mw.config.get( 'wgIsMainPage' ) ) {
return;
}
mw.hook( 'wikipage.content' ).add( function () {
var trigger = document.getElementById( 'fw-mainpage-search-trigger' );
var input = document.getElementById( 'searchInput' );
if ( !trigger || !input ) {
return;
}
function openSearch() {
if ( mw.config.get( 'skin' ) === 'citizen' ) {
/* Citizen hides the header while scrolling down; bring it back. */
if ( document.body.classList.contains( 'citizen-scroll--down' ) ) {
document.body.classList.remove( 'citizen-scroll--down' );
document.body.classList.add( 'citizen-scroll--up' );
}
/* Citizen's search lives in a collapsed panel and focuses the input when opened. */
var details = document.getElementById( 'citizen-search-details' );
if ( details ) {
details.open = true;
return;
}
}
input.focus();
}
trigger.addEventListener( 'click', openSearch );
trigger.addEventListener( 'keydown', function ( e ) {
if ( e.key === 'Enter' || e.key === ' ' ) {
e.preventDefault();
openSearch();
}
} );
} );
}() );

Latest revision as of 00:45, 24 September 2026

/* Any JavaScript here will be loaded for all users on every page load. */