39 lines
871 B
TypeScript
39 lines
871 B
TypeScript
import {Component, ElementRef, EventEmitter, HostListener, OnInit, Output} from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'app-profile',
|
|
templateUrl: './profile.component.html',
|
|
styleUrls: ['./profile.component.scss']
|
|
})
|
|
export class ProfileComponent implements OnInit {
|
|
|
|
initialClick = true;
|
|
@Output() showProfilePopoverChange = new EventEmitter<boolean>();
|
|
|
|
isLoggedIn = true;
|
|
|
|
constructor(private eRef: ElementRef) {
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
/**
|
|
* Used to close Profile component when user clicks outside the component
|
|
* @param event
|
|
*/
|
|
@HostListener('document:click', ['$event'])
|
|
@HostListener('document:touchstart', ['$event'])
|
|
handleOutsideClick(event: any) {
|
|
if (this.initialClick) {
|
|
this.initialClick = false;
|
|
return;
|
|
}
|
|
|
|
if (!this.eRef.nativeElement.contains(event.target)) {
|
|
this.showProfilePopoverChange.emit(false);
|
|
}
|
|
}
|
|
|
|
}
|