the-glorious-startpage/js/show-search-box.js

43 lines
872 B
JavaScript
Raw Normal View History

2020-06-04 03:54:39 +02:00
var searchBox = document.getElementById('searchBox');
2020-06-04 04:06:27 +02:00
var centeredBoxOverlay = document.getElementById('centeredBoxOverlay');
2020-06-04 03:54:39 +02:00
let searchBoxVisility = false;
const showSearchBox = () => {
searchBox.classList.add('showSearchBox');
// Focus
searchBox.focus();
searchBoxVisility = !searchBoxVisility;
}
const hideSearchBox = () => {
searchBox.classList.remove('showSearchBox');
searchBoxVisility = !searchBoxVisility;
}
const toggleSearchBox = () => {
// If profile anim is still running,
// Return to avoid spam
if (profileAnimRunning) return;
// Rotate profile
rotateProfile();
if (searchBoxVisility) {
// Hide search box
hideSearchBox();
} else {
// Show search box
showSearchBox();
}
2020-06-04 04:06:27 +02:00
// Show overlay
centeredBoxOverlay.classList.toggle('showOverlay');
2020-06-04 03:54:39 +02:00
console.log('toggle searchbox');
}