fix searchbox switching problems

This commit is contained in:
Gerome Matilla 2020-06-06 07:31:43 +08:00
parent 35c932aa8f
commit c7cf0dcbec
5 changed files with 28 additions and 11 deletions

View File

@ -1,6 +1,4 @@
#searchBoxContainer { #searchBoxContainer {
background: #ff00ff;
width: auto; width: auto;
height: auto; height: auto;

View File

@ -53,7 +53,12 @@ const toggleDashboard = () => {
if (weatherScreen.classList.contains('showWeatherScreen')) { if (weatherScreen.classList.contains('showWeatherScreen')) {
console.log('weather screen is open, closing...'); console.log('weather screen is open, closing...');
hideWeatherScreen(); hideWeatherScreen();
return return;
} else if (searchBoxContainer.classList.contains('showSearchBox')) {
console.log('searchbox is open, closing...');
hideSearchBox();
} else if (webMenu.classList.contains('showWebMenu')) { } else if (webMenu.classList.contains('showWebMenu')) {
console.log('web menu is open, closing...'); console.log('web menu is open, closing...');
hideWebMenu(); hideWebMenu();

View File

@ -1,6 +1,5 @@
var searchBoxContainer = document.getElementById('searchBoxContainer');
var searchBox = document.getElementById('searchBox'); var searchBox = document.getElementById('searchBox');
var searchBoxContainer = document.getElementById('searchBoxContainer');
var centeredBoxOverlay = document.getElementById('centeredBoxOverlay'); var centeredBoxOverlay = document.getElementById('centeredBoxOverlay');
let searchBoxVisility = false; let searchBoxVisility = false;
@ -12,11 +11,19 @@ const showSearchBox = () => {
searchBox.focus(); searchBox.focus();
searchBoxVisility = !searchBoxVisility; searchBoxVisility = !searchBoxVisility;
// Toggle overlay
centeredBoxOverlay.classList.toggle('showOverlay');
} }
const hideSearchBox = () => { const hideSearchBox = () => {
searchBoxContainer.classList.remove('showSearchBox'); searchBoxContainer.classList.remove('showSearchBox');
// Toggle overlay
centeredBoxOverlay.classList.toggle('showOverlay');
searchBox.value = '';
searchBoxVisility = !searchBoxVisility; searchBoxVisility = !searchBoxVisility;
} }
@ -38,8 +45,5 @@ const toggleSearchBox = () => {
showSearchBox(); showSearchBox();
} }
// Show overlay
centeredBoxOverlay.classList.toggle('showOverlay');
console.log('toggle searchbox'); console.log('toggle searchbox');
} }

View File

@ -262,6 +262,11 @@ const toggleWeatherScreen = () => {
console.log('web menu is open, closing...'); console.log('web menu is open, closing...');
hideWebMenu(); hideWebMenu();
return; return;
} else if (searchBoxContainer.classList.contains('showSearchBox')) {
console.log('searchbox is open, closing...');
hideSearchBox();
} else if (dashboard.classList.contains('showRightDashboard')) { } else if (dashboard.classList.contains('showRightDashboard')) {
console.log('dashboard is open, closing...'); console.log('dashboard is open, closing...');
hideDashboard(); hideDashboard();

View File

@ -224,14 +224,19 @@ const toggleWebMenu = () => {
if (weatherScreen.classList.contains('showWeatherScreen')) { if (weatherScreen.classList.contains('showWeatherScreen')) {
console.log('weather screen is open, closing...'); console.log('weather screen is open, closing...');
hideWeatherScreen(); hideWeatherScreen();
return return;
} else if (searchBoxContainer.classList.contains('showSearchBox')) {
console.log('searchbox is open, closing...');
hideSearchBox();
} else if (dashboard.classList.contains('showRightDashboard')) { } else if (dashboard.classList.contains('showRightDashboard')) {
console.log('dashboard is open, closing...'); console.log('dashboard is open, closing...');
hideDashboard(); hideDashboard();
} }
// Toggle center box // Toggle center box
toggleCenteredBox(); toggleCenteredBox();
} }
// Remove class to focused item // Remove class to focused item