mediawiki-skins-Citizen/resources/skins.citizen.scripts/skins.citizen.scripts.js
2020-06-16 23:03:28 -04:00

26 lines
613 B
JavaScript

/*
* Citizen - Search JS
* https://starcitizen.tools
*
* Focus on search input when checkbox is toggled
* Open the search box when the input is in focus
*/
var searchToggle = document.getElementById( 'search-toggle' ),
searchInput = document.getElementById( 'searchInput' );
function searchInputFocus() {
if ( searchToggle.checked !== false ) {
searchInput.focus();
}
}
function searchToggleCheck() {
if ( searchToggle.checked === false ) {
searchToggle.checked = true;
}
}
searchToggle.addEventListener( 'click', searchInputFocus );
searchInput.addEventListener( 'focus', searchToggleCheck );