Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

import { Component, DoCheck, Input, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { DOCUMENT } from '@angular/platform-browser';
import { WindowRefService } from '../../window-ref.service';
import { MenuModel } from './menu.component.model';
@Component({
selector: 'app-menu',
templateUrl: './menu.component.html',
styleUrls: ['./menu.component.scss']
})
export class MenuComponent implements DoCheck {
navOneFocus = false;
navTwoFocus = false;
navThreeFocus = false;
navFourFocus = false;
navFiveFocus = false;
navSixFocus = false;
menuName = '';

@Output()
clickNotify = new EventEmitter();
@Input()
menu: MenuModel;
@Input()
tabIdx = '0';
constructor(private router: Router, private windowRef: WindowRefService) {}

// ngOnInit() {
// // this.menu = this.ewvMenu;
// }
emitClick(event, item) {
this.clickNotify.emit(item);
}
ngDoCheck() {
this.onFocusCheck().subscribe(bool => {
if (bool) {
this.windowRef.nativeWindow.onclick = () => {
this.onClearMenu();
};
} else {
this.windowRef.nativeWindow.onclick = undefined;
}
});
}

focus(focus: string) {
this.navOneFocus = false;
this.navTwoFocus = false;
this.navThreeFocus = false;
this.navFourFocus = false;
this.navFiveFocus = false;
this.navSixFocus = false;
this[focus] = true;
this.menuName = focus;
}

onClearMenu() {
this.focus(undefined);
this.menuName = '';
}

onFocusCheck(): Observable<boolean> {
const bools = [
this.navOneFocus,
this.navTwoFocus,
this.navThreeFocus,
this.navFourFocus,
this.navFiveFocus,
this.navSixFocus
];
return new Observable(observer =>
observer.next(bools.some(b => b === true))
);
}
}