2020-06-09 04:02:03 +02:00
|
|
|
class Dashboard {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this._dashboard = document.querySelector('#rightDashboard');
|
|
|
|
this._dashboardOverlay = document.querySelector('#dashboardOverlay');
|
|
|
|
|
2020-06-09 09:55:50 +02:00
|
|
|
this._rightDashboardVisibility = false;
|
2020-06-09 04:02:03 +02:00
|
|
|
|
|
|
|
this._dashboardOverlayMouseUpEvent = this._dashboardOverlayMouseUpEvent.bind(this);
|
|
|
|
|
|
|
|
this._centeredBox = document.querySelector('#centeredBox');
|
|
|
|
this._webMenu = document.querySelector('#webMenu');
|
|
|
|
this._searchBoxContainer = document.querySelector('#searchBoxContainer');
|
|
|
|
this._weatherScreen = document.querySelector('#weatherScreen');
|
|
|
|
|
2020-06-09 12:13:12 +02:00
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
_init = () => {
|
2020-06-09 04:02:03 +02:00
|
|
|
this._registerOverlayMouseUpEvent();
|
2020-06-09 12:13:12 +02:00
|
|
|
this._disableDashboardInputs(true);
|
2020-06-09 04:02:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-09 12:13:12 +02:00
|
|
|
_disableDashboardInputs = status => {
|
2020-06-09 04:02:03 +02:00
|
|
|
const elems = this._dashboard.getElementsByTagName('input');
|
|
|
|
const len = elems.length;
|
|
|
|
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
elems[i].disabled = status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getRightDashboardVisibility = () => {
|
2020-06-09 09:55:50 +02:00
|
|
|
return this._rightDashboardVisibility;
|
2020-06-09 04:02:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
showDashboard = () => {
|
|
|
|
this._dashboard.classList.add('showRightDashboard');
|
|
|
|
|
|
|
|
// Show overlay
|
|
|
|
this._dashboardOverlay.classList.add('showDashboardOverlay');
|
|
|
|
|
|
|
|
// Enable Inputs
|
|
|
|
this._disableDashboardInputs(false);
|
|
|
|
|
2020-06-09 09:55:50 +02:00
|
|
|
this._rightDashboardVisibility = !this._rightDashboardVisibility;
|
2020-06-09 04:02:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hideDashboard = () => {
|
|
|
|
this._dashboard.classList.remove('showRightDashboard');
|
|
|
|
this._dashboard.scrollTop = 0;
|
|
|
|
|
|
|
|
// Disable Inputs
|
|
|
|
this._disableDashboardInputs(true);
|
|
|
|
|
|
|
|
// Hide overlay
|
|
|
|
this._dashboardOverlay.classList.remove('showDashboardOverlay');
|
|
|
|
|
2020-06-09 09:55:50 +02:00
|
|
|
this._rightDashboardVisibility = !this._rightDashboardVisibility;
|
2020-06-09 04:02:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toggleDashboard = () => {
|
|
|
|
|
|
|
|
console.log('toggle dashboard');
|
|
|
|
|
2020-06-09 09:55:50 +02:00
|
|
|
if (this._rightDashboardVisibility) {
|
2020-06-09 04:02:03 +02:00
|
|
|
|
|
|
|
// Hide dashboard
|
|
|
|
this.hideDashboard();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Show dashboard
|
|
|
|
this.showDashboard();
|
|
|
|
|
|
|
|
// If centered box is hidden, open it
|
|
|
|
if (this._centeredBox.classList.contains('hiddenBox')) {
|
|
|
|
|
|
|
|
console.log('centered box is hidden, reopening...');
|
|
|
|
|
|
|
|
// Rotate profile container
|
|
|
|
profileImage.rotateProfile();
|
|
|
|
|
|
|
|
// Toggle center box
|
|
|
|
centeredBox.toggleCenteredBox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if any of these are open, if yes, close it
|
|
|
|
if (this._searchBoxContainer.classList.contains('showSearchBox')) {
|
|
|
|
console.log('searchbox is open, closing...');
|
|
|
|
searchBoxShow.hideSearchBox();
|
|
|
|
|
|
|
|
} else if (this._webMenu.classList.contains('showWebMenu')) {
|
|
|
|
console.log('web menu is open, closing...');
|
|
|
|
webMenu.hideWebMenu();
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (this._weatherScreen.classList.contains('showWeatherScreen')) {
|
|
|
|
console.log('weather screen is open, closing...');
|
|
|
|
weatherScreen.hideWeatherScreen();
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_dashboardOverlayMouseUpEvent = e => {
|
2020-06-09 09:55:50 +02:00
|
|
|
if (this._rightDashboardVisibility) {
|
2020-06-09 04:02:03 +02:00
|
|
|
this.toggleDashboard();
|
|
|
|
}
|
|
|
|
console.log('dashboard overlay clicked...');
|
|
|
|
}
|
|
|
|
|
|
|
|
_registerOverlayMouseUpEvent = () => {
|
|
|
|
this._dashboardOverlay.addEventListener('mouseup', this._dashboardOverlayMouseUpEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|