mediawiki-skins-Citizen/resources/skins.citizen.scripts/skins.citizen.scripts.js

36 lines
716 B
JavaScript
Raw Normal View History

/*
2020-08-12 16:37:43 +00:00
* Citizen - Core JS
* https://starcitizen.tools
*/
var searchToggle = document.getElementById( 'search-toggle' ),
searchInput = document.getElementById( 'searchInput' );
2020-06-17 03:16:45 +00:00
/**
* Focus in search box when search toggle checkbox is checked.
*
2020-06-17 03:16:45 +00:00
* @constructor
*/
function searchInputFocus() {
if ( searchToggle.checked !== false ) {
searchInput.focus();
}
}
2020-06-17 03:16:45 +00:00
/**
* Check search toggle checkbox when search box is in focus.
*
2020-06-17 03:16:45 +00:00
* @constructor
*/
function searchToggleCheck() {
if ( searchToggle.checked === false ) {
searchToggle.checked = true;
}
}
2020-08-12 16:37:43 +00:00
function main() {
searchToggle.addEventListener( 'click', searchInputFocus );
searchInput.addEventListener( 'focus', searchToggleCheck );
}
main();