|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
import {Component, OnInit} from '@angular/core';
|
|
|
|
|
import {Component, HostListener, OnInit} from '@angular/core';
|
|
|
|
|
import {User} from '../../models/user';
|
|
|
|
|
import {StorageService} from '../../services/storage.service';
|
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
@@ -12,12 +12,15 @@ export class HeaderComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
showProfilePopOver: boolean = false;
|
|
|
|
|
user?: User;
|
|
|
|
|
initialClickMobileMenu : boolean = true
|
|
|
|
|
dropdownContentStyle! : CSSStyleDeclaration;
|
|
|
|
|
|
|
|
|
|
constructor(private router: Router) {
|
|
|
|
|
this.user = StorageService.getUserInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.dropdownContentStyle = document.getElementById('menu-mobile-dropdown-content')!.style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openProfile(): void {
|
|
|
|
@@ -29,20 +32,45 @@ export class HeaderComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getUserName(): string {
|
|
|
|
|
return this.user ? this.user.firstName : 'Logged out';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navigate(path: string): void {
|
|
|
|
|
this.initialClickMobileMenu = true;
|
|
|
|
|
this.router.navigate([path]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggleMobileDropdown(): void {
|
|
|
|
|
const dropdownContentStyle = document.getElementById('menu-mobile-dropdown-content')!.style;
|
|
|
|
|
if (dropdownContentStyle.display == 'block') {
|
|
|
|
|
dropdownContentStyle.display = 'none';
|
|
|
|
|
} else {
|
|
|
|
|
dropdownContentStyle.display = 'block';
|
|
|
|
|
openMobileDropdown() : void {
|
|
|
|
|
if (!this.isMobileDropdownOpen()) {
|
|
|
|
|
this.dropdownContentStyle.display = 'block';
|
|
|
|
|
this.initialClickMobileMenu = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeMobileDropdown() : void {
|
|
|
|
|
this.dropdownContentStyle.display = 'none';
|
|
|
|
|
this.initialClickMobileMenu = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isMobileDropdownOpen() : Boolean {
|
|
|
|
|
return this.dropdownContentStyle.display == 'block';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@HostListener('document:click', ['$event'])
|
|
|
|
|
@HostListener('document:touchstart', ['$event'])
|
|
|
|
|
handleOutsideClick(event: any) {
|
|
|
|
|
if (!document.getElementById("menu-mobile-dropdown-content")!.contains(event.target)) {
|
|
|
|
|
if(this.isMobileDropdownOpen()) {
|
|
|
|
|
if(this.initialClickMobileMenu) {
|
|
|
|
|
this.initialClickMobileMenu = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.closeMobileDropdown();
|
|
|
|
|
console.log("Zu gemacht!")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|