import { Component , OnInit , Input } from '@angular/core' ; import { Line } from '../../models/itinerary' ; import { Analytics } from '../../core/analytics' ; import strings from '../../strings' ; class @ Component ( { selector : 'map-snackbar' , templateUrl : 'template.html' , } ) export class MapSnackbar implements OnInit { @ Input ( ) public line : Line ; @ Input ( ) public swapable : boolean ; @ Input ( ) public swapDirection : ( ) => boolean ; public coming : string ; public going : string ; public get Text ( ) : any { return strings ; } return { void } public ngOnInit ( ) { if ( this . line && this . line . Description . indexOf ( ' X ' ) > - 1 ) { let tmp = this . line . Description . split ( ' X ' ) ; this . coming = tmp [ 0 ] ; this . going = tmp [ 1 ] ; } } return { void } public onToggleDirection ( ) { Analytics . trackEvent ( 'Toggle direction button' , 'click' ) ; let toggle = this . swapDirection ( ) ; if ( toggle ) { let tmp = this . coming ; this . coming = this . going ; this . going = tmp ; } } }