import { Color } from '../../color' ; import { Span as SpanDefinition } from './span' ; import { ViewBase } from '../core/view-base' ; import { FontStyle , FontWeight } from '../styling/font' ; import { CoreTypes } from '../../core-types' ; import { EventData } from '../../data/observable' ; import { isNullOrUndefined , isString } from '../../utils/types' ; export class Span extends ViewBase implements SpanDefinition { static linkTapEvent = 'linkTap' ; private _text : string ; private _tappable = false ; get fontFamily ( ) : string { return this . style . fontFamily ; } set fontFamily ( value ) { this . style . fontFamily = value ; } get fontSize ( ) : number { return this . style . fontSize ; } set fontSize ( value ) { this . style . fontSize = value ; } get fontStyle ( ) : FontStyle { return this . style . fontStyle ; } set fontStyle ( value ) { this . style . fontStyle = value ; } get fontWeight ( ) : FontWeight { return this . style . fontWeight ; } set fontWeight ( value ) { this . style . fontWeight = value ; } get textDecoration ( ) : CoreTypes . TextDecorationType { return this . style . textDecoration ; } set textDecoration ( value ) { this . style . textDecoration = value ; } get color ( ) : Color { return this . style . color ; } set color ( value ) { this . style . color = value ; } get backgroundColor ( ) : Color { return this . style . backgroundColor ; } set backgroundColor ( value ) { this . style . backgroundColor = value ; } get text ( ) : string { return this . _text ; } set text ( value ) { if ( this . _text !== value ) { if ( isNullOrUndefined ( value ) ) { this . _text = '' ; } else { this . _text = isString ( value ) ? `${ value }` . replace ( '\\n' , '\n' ) . replace ( '\\t' , '\t' ) : `${ value }` ; } this . notifyPropertyChange ( 'text' , this . _text ) ; } } get tappable ( ) : boolean { return this . _tappable ; } addEventListener ( arg , callback , thisArg ? ) { super . addEventListener ( arg , callback , thisArg ) ; this . _setTappable ( this . hasListeners ( Span . linkTapEvent ) ) ; } removeEventListener ( arg , callback ? , thisArg ? ) { super . removeEventListener ( arg , callback , thisArg ) ; this . _setTappable ( this . hasListeners ( Span . linkTapEvent ) ) ; } _setTextInternal ( value ) { this . _text = value ; } private _setTappable ( value ) { if ( this . _tappable !== value ) { this . _tappable = value ; this . notifyPropertyChange ( 'tappable' , value ) ; } } }