the-glorious-startpage/js/animate-dashboard.js

96 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-06-04 04:23:40 +02:00
var dashboard = document.getElementById("rightDashboard");
2020-06-04 04:29:12 +02:00
var dashboardOverlay = document.getElementById("dashboardOverlay");
2020-06-04 04:23:40 +02:00
let rightDashboardVisibility = false;
2020-06-06 12:16:34 +02:00
// Disable/Enable inputs
2020-06-06 13:05:39 +02:00
var disableDashboardInputs = (status) => {
2020-06-06 12:16:34 +02:00
var elems = dashboard.getElementsByTagName('input');
var len = elems.length;
for (var i = 0; i < len; i++) {
elems[i].disabled = status;
}
}
2020-06-04 04:23:40 +02:00
const showDashboard = () => {
dashboard.classList.add('showRightDashboard');
2020-06-04 04:29:12 +02:00
// Show overlay
dashboardOverlay.classList.add('showDashboardOverlay');
2020-06-06 12:16:34 +02:00
// Enable Inputs
2020-06-06 13:05:39 +02:00
disableDashboardInputs(false);
2020-06-06 12:16:34 +02:00
2020-06-04 04:23:40 +02:00
rightDashboardVisibility = !rightDashboardVisibility;
}
const hideDashboard = () => {
dashboard.classList.remove('showRightDashboard');
dashboard.scrollTop = 0;
2020-06-06 12:16:34 +02:00
// Disable Inputs
2020-06-06 13:05:39 +02:00
disableDashboardInputs(true);
2020-06-06 12:16:34 +02:00
2020-06-04 04:29:12 +02:00
// Hide overlay
dashboardOverlay.classList.remove('showDashboardOverlay');
2020-06-04 04:23:40 +02:00
rightDashboardVisibility = !rightDashboardVisibility;
}
const toggleDashboard = () => {
console.log('toggle dashboard');
2020-06-04 04:23:40 +02:00
if (rightDashboardVisibility) {
2020-06-04 06:15:59 +02:00
// Hide dashboard
2020-06-04 04:23:40 +02:00
hideDashboard();
2020-06-04 04:23:40 +02:00
} else {
2020-06-04 06:15:59 +02:00
// Show dashboard
2020-06-04 04:23:40 +02:00
showDashboard();
// If centered box is hidden, open it
if (centeredBox.classList.contains('hiddenBox')) {
console.log('centered box is hidden, reopening...');
// Rotate profile container
rotateProfile();
// Toggle center box
toggleCenteredBox();
}
2020-06-04 04:23:40 +02:00
}
// Check if any of these are open, if yes, close it
if (weatherScreen.classList.contains('showWeatherScreen')) {
console.log('weather screen is open, closing...');
hideWeatherScreen();
2020-06-06 01:31:43 +02:00
return;
} else if (searchBoxContainer.classList.contains('showSearchBox')) {
console.log('searchbox is open, closing...');
hideSearchBox();
} else if (webMenu.classList.contains('showWebMenu')) {
console.log('web menu is open, closing...');
hideWebMenu();
return;
}
2020-06-04 04:29:12 +02:00
}
2020-06-04 04:23:40 +02:00
2020-06-04 04:29:12 +02:00
dashboardOverlay.addEventListener(
"mouseup",
() => {
if (rightDashboardVisibility) {
toggleDashboard();
}
}
2020-06-06 12:16:34 +02:00
);
// Disable dashboard inputs on startup
2020-06-06 13:05:39 +02:00
window.onload = disableDashboardInputs(true);