import { Directive , ElementRef , EventEmitter , HostListener , Output } from '@angular/core' ; import { isNotKeyboardEventOnButton } from '../../utilities' ; @ Directive ( { selector : '[obMasterLayoutNavigationToggle]' , exportAs : 'obMasterLayoutNavigationToggle' , host : { class : 'ob-master-layout-navigation-toggle' } } ) export class ObMasterLayoutNavigationToggleDirective { @ Output ( ) readonly onToggle = new EventEmitter < MouseEvent | KeyboardEvent > ( ) ; public back = false ; constructor ( private readonly elementRef ) { this . back = elementRef . nativeElement . classList . contains ( 'navbar-primary-back' ) ; } @ HostListener ( 'click' , [ '$event' ] ) @ HostListener ( 'keyup.enter' , [ '$event' ] ) onClick ( event ? ) { if ( isNotKeyboardEventOnButton ( event ) ) { event . preventDefault ( ) ; this . onToggle . next ( event ) ; } } }