2020-06-04 03:54:39 +02:00
|
|
|
var searchBox = document.getElementById('searchBox');
|
2020-06-07 09:18:09 +02:00
|
|
|
const searchBoxContainer = document.getElementById('searchBoxContainer');
|
|
|
|
const centeredBoxOverlay = document.getElementById('centeredBoxOverlay');
|
2020-06-04 03:54:39 +02:00
|
|
|
|
|
|
|
let searchBoxVisility = false;
|
|
|
|
|
|
|
|
const showSearchBox = () => {
|
2020-06-06 01:14:21 +02:00
|
|
|
searchBoxContainer.classList.add('showSearchBox');
|
2020-06-04 03:54:39 +02:00
|
|
|
|
|
|
|
// Focus
|
|
|
|
searchBox.focus();
|
|
|
|
|
|
|
|
searchBoxVisility = !searchBoxVisility;
|
2020-06-06 01:31:43 +02:00
|
|
|
|
|
|
|
// Toggle overlay
|
|
|
|
centeredBoxOverlay.classList.toggle('showOverlay');
|
2020-06-04 03:54:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const hideSearchBox = () => {
|
2020-06-06 01:14:21 +02:00
|
|
|
searchBoxContainer.classList.remove('showSearchBox');
|
2020-06-04 03:54:39 +02:00
|
|
|
|
2020-06-06 01:31:43 +02:00
|
|
|
// Toggle overlay
|
|
|
|
centeredBoxOverlay.classList.toggle('showOverlay');
|
|
|
|
|
|
|
|
searchBox.value = '';
|
|
|
|
|
2020-06-06 05:13:45 +02:00
|
|
|
// Hide suggestions
|
|
|
|
hideSuggestions();
|
|
|
|
|
2020-06-04 03:54:39 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('toggle searchbox');
|
|
|
|
}
|