import { Directive , Input , ElementRef , OnInit , OnDestroy , NgZone } from '@angular/core' ; import { DataTable , EventHelper } from '../base' ; @ Directive ( { selector : '[appBodyDblClick]' } ) export class BodyDblClickDirective implements OnInit , OnDestroy { @ Input ( ) table : DataTable ; element : HTMLElement ; private clickListener : any ; constructor ( element , private ngZone ) { this . element = element . nativeElement ; } ngOnInit ( ) { const editable = this . table . columns . some ( x => x . editable ) ; if ( editable ) { this . ngZone . runOutsideAngular ( ( ) => { this . clickListener = this . onDblClick . bind ( this ) ; this . element . addEventListener ( 'dblclick' , this . clickListener ) ; } ) ; } } ngOnDestroy ( ) { this . element . removeEventListener ( 'dblclick' , this . clickListener ) ; } onDblClick ( event ) { const cellEventArgs = EventHelper . findCellEvent ( event , this . element ) ; if ( cellEventArgs ) { this . ngZone . run ( ( ) => { this . table . events . onDblClickCell ( cellEventArgs ) ; } ) ; } } }