Use document.querySelectorAll()

Co-authored-by: kkthxbye <400797+kkthxbye-code@users.noreply.github.com>
This commit is contained in:
Jonathan Senecal 2023-08-17 23:47:47 -04:00 committed by GitHub
parent b31e25cfab
commit 922e3e27fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,36 +4,19 @@ import { apiPatch, hasError } from './util';
function lockDashboard(): void { function lockDashboard(): void {
const dashboard = document.getElementById('dashboard') as any; const dashboard = document.getElementById('dashboard') as any;
const gridUnlockButton = document.getElementById('unlock_dashboard') as HTMLButtonElement;
const gridLockButton = document.getElementById('lock_dashboard') as HTMLButtonElement;
if (dashboard) { if (dashboard) {
dashboard.gridstack.disable(); dashboard.gridstack.disable();
// Hide the grid stack items buttons // Hide the grid stack items buttons
Array.from(document.getElementsByClassName("grid-stack-item-button")).forEach(function (element) { document.querySelectorAll(".grid-stack-item-button, #unlock_dashboard, #lock_dashboard").forEach(el => el.classList.toggle('invisible'));
element.classList.add('invisible');
});
}
if (gridUnlockButton && gridLockButton) {
gridUnlockButton.classList.remove('invisible');
gridLockButton.classList.add('invisible');
} }
} }
function unlockDashboard(): void { function unlockDashboard(): void {
const dashboard = document.getElementById('dashboard') as any; const dashboard = document.getElementById('dashboard') as any;
const gridUnlockButton = document.getElementById('unlock_dashboard') as HTMLButtonElement;
const gridLockButton = document.getElementById('lock_dashboard') as HTMLButtonElement;
if (dashboard) { if (dashboard) {
dashboard.gridstack.enable(); dashboard.gridstack.enable();
// Show the grid stack items buttons // Show the grid stack items buttons
Array.from(document.getElementsByClassName("grid-stack-item-button")).forEach(function (element) { document.querySelectorAll(".grid-stack-item-button, #unlock_dashboard, #lock_dashboard").forEach(el => el.classList.toggle('invisible'));
element.classList.remove('invisible');
});
}
if (gridUnlockButton && gridLockButton) {
gridUnlockButton.classList.add('invisible');
gridLockButton.classList.remove('invisible');
} }
} }