mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-28 16:21:11 +00:00
43 lines
960 B
JavaScript
43 lines
960 B
JavaScript
var searchToggle = document.getElementById( 'search-checkbox' ),
|
|
searchInput = document.getElementById( 'searchInput' ),
|
|
pageReady = require( ( 'mediawiki.page.ready' ) );
|
|
|
|
/**
|
|
* Focus in search box when search toggle checkbox is checked.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function searchInputFocus() {
|
|
if ( searchToggle.checked !== false ) {
|
|
searchInput.focus();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check search toggle checkbox when search box is in focus.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function searchToggleCheck() {
|
|
if ( searchToggle.checked === false ) {
|
|
searchToggle.checked = true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return {void}
|
|
*/
|
|
function init() {
|
|
searchToggle.addEventListener( 'click', searchInputFocus );
|
|
searchInput.addEventListener( 'focus', searchToggleCheck );
|
|
pageReady.loadSearchModule(
|
|
// Decide between new Citizen implementation or core
|
|
mw.config.get( 'wgCitizenEnableSearch' ) ?
|
|
'skins.citizen.scripts.search' : 'mediawiki.searchSuggest'
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
init: init
|
|
};
|