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

71 lines
1.7 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;
const showDashboard = () => {
dashboard.classList.add('showRightDashboard');
2020-06-04 04:29:12 +02:00
// Show overlay
dashboardOverlay.classList.add('showDashboardOverlay');
2020-06-04 04:23:40 +02:00
rightDashboardVisibility = !rightDashboardVisibility;
}
const hideDashboard = () => {
dashboard.classList.remove('showRightDashboard');
dashboard.scrollTop = 0;
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();
return
} 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();
}
}
);