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;
// 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 = () => {
dashboard.classList.add('showRightDashboard');
// Show overlay
dashboardOverlay.classList.add('showDashboardOverlay');
// Enable Inputs
disableAllInputs(false);
rightDashboardVisibility = !rightDashboardVisibility;
}
@ -16,6 +29,9 @@ const hideDashboard = () => {
dashboard.classList.remove('showRightDashboard');
dashboard.scrollTop = 0;
// Disable Inputs
disableAllInputs(true);
// Hide overlay
dashboardOverlay.classList.remove('showDashboardOverlay');
@ -73,4 +89,8 @@ dashboardOverlay.addEventListener(
toggleDashboard();
}
}
);
);
// Disable dashboard inputs on startup
window.onload = disableAllInputs(true);

View File

@ -8,6 +8,16 @@ let webMenuVisibility = false;
let webItemFocus;
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
const createCallback = (li, url) => {
// Create a callback property for the passed li
@ -172,6 +182,10 @@ const getFirstItem = () => {
const showWebMenu = () => {
webMenu.classList.add('showWebMenu');
// Enable inputs
disableAllInputs(false);
webMenuVisibility = !webMenuVisibility;
// Focus to input field
@ -198,6 +212,10 @@ const hideWebMenu = () => {
getFirstItem();
webMenu.classList.remove('showWebMenu');
// Disable inputs
disableAllInputs(true);
webMenuVisibility = !webMenuVisibility;
}
@ -347,6 +365,9 @@ webMenuSearchBox.onkeydown = (event) => {
const initWebMenu = () => {
populateWebMenu();
getFirstItem();
// Disable inputs
disableAllInputs(true);
}
// Initialize web menu