2020-06-09 04:30:24 +00:00
|
|
|
/*
|
|
|
|
* 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' );
|
|
|
|
|
2020-06-17 03:16:45 +00:00
|
|
|
/**
|
|
|
|
* Focus in search box when search toggle checkbox is checked.
|
2020-07-05 21:07:36 +00:00
|
|
|
*
|
2020-06-17 03:16:45 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2020-06-09 04:30:24 +00:00
|
|
|
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-07-05 21:07:36 +00:00
|
|
|
*
|
2020-06-17 03:16:45 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2020-06-09 04:30:24 +00:00
|
|
|
function searchToggleCheck() {
|
|
|
|
if ( searchToggle.checked === false ) {
|
|
|
|
searchToggle.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
searchToggle.addEventListener( 'click', searchInputFocus );
|
|
|
|
searchInput.addEventListener( 'focus', searchToggleCheck );
|