disable inputs if hidden

This commit is contained in:
Gerome Matilla 2020-06-06 18:16:34 +08:00
parent 44a903e59b
commit d0f2b3b74c
2 changed files with 42 additions and 1 deletions

View File

@ -3,12 +3,25 @@ var dashboardOverlay = document.getElementById("dashboardOverlay");
let rightDashboardVisibility = false; let rightDashboardVisibility = false;
// Disable/Enable inputs
var disableAllInputs = (status) => {
var elems = dashboard.getElementsByTagName('input');
var len = elems.length;
for (var i = 0; i < len; i++) {
elems[i].disabled = status;
}
}
const showDashboard = () => { const showDashboard = () => {
dashboard.classList.add('showRightDashboard'); dashboard.classList.add('showRightDashboard');
// Show overlay // Show overlay
dashboardOverlay.classList.add('showDashboardOverlay'); dashboardOverlay.classList.add('showDashboardOverlay');
// Enable Inputs
disableAllInputs(false);
rightDashboardVisibility = !rightDashboardVisibility; rightDashboardVisibility = !rightDashboardVisibility;
} }
@ -16,6 +29,9 @@ const hideDashboard = () => {
dashboard.classList.remove('showRightDashboard'); dashboard.classList.remove('showRightDashboard');
dashboard.scrollTop = 0; dashboard.scrollTop = 0;
// Disable Inputs
disableAllInputs(true);
// Hide overlay // Hide overlay
dashboardOverlay.classList.remove('showDashboardOverlay'); dashboardOverlay.classList.remove('showDashboardOverlay');
@ -73,4 +89,8 @@ dashboardOverlay.addEventListener(
toggleDashboard(); toggleDashboard();
} }
} }
); );
// Disable dashboard inputs on startup
window.onload = disableAllInputs(true);

View File

@ -8,6 +8,16 @@ let webMenuVisibility = false;
let webItemFocus; let webItemFocus;
let webListIndex = 0; let webListIndex = 0;
// Disable/Enable inputs
var disableAllInputs = (status) => {
var elems = webMenu.getElementsByTagName('input');
var len = elems.length;
for (var i = 0; i < len; i++) {
elems[i].disabled = status;
}
}
// Create mouse event for passed li // Create mouse event for passed li
const createCallback = (li, url) => { const createCallback = (li, url) => {
// Create a callback property for the passed li // Create a callback property for the passed li
@ -172,6 +182,10 @@ const getFirstItem = () => {
const showWebMenu = () => { const showWebMenu = () => {
webMenu.classList.add('showWebMenu'); webMenu.classList.add('showWebMenu');
// Enable inputs
disableAllInputs(false);
webMenuVisibility = !webMenuVisibility; webMenuVisibility = !webMenuVisibility;
// Focus to input field // Focus to input field
@ -198,6 +212,10 @@ const hideWebMenu = () => {
getFirstItem(); getFirstItem();
webMenu.classList.remove('showWebMenu'); webMenu.classList.remove('showWebMenu');
// Disable inputs
disableAllInputs(true);
webMenuVisibility = !webMenuVisibility; webMenuVisibility = !webMenuVisibility;
} }
@ -347,6 +365,9 @@ webMenuSearchBox.onkeydown = (event) => {
const initWebMenu = () => { const initWebMenu = () => {
populateWebMenu(); populateWebMenu();
getFirstItem(); getFirstItem();
// Disable inputs
disableAllInputs(true);
} }
// Initialize web menu // Initialize web menu