import { ElementRef , Input , Renderer } from '@angular/core' ; import { Config } from '../config/config' ; /**
 * Base class for all Ionic components. Exposes some common functionality
 * that all Ionic components need, such as accessing underlying native elements and
 * sending/receiving app-level events.
 */ hidden export class Ion { hidden _config : Config ; hidden _elementRef : ElementRef ; hidden _renderer : Renderer ; hidden _color : string ; hidden _mode : string ; hidden _componentName : string ; input @ Input ( ) set color ( val ) { this . _setColor ( val ) ; } get color ( ) : string { return this . _color ; } input @ Input ( ) set mode ( val ) { this . _setMode ( val ) ; } get mode ( ) : string { return this . _mode ; } constructor ( config , elementRef , renderer , componentName ? ) { this . _config = config ; this . _elementRef = elementRef ; this . _renderer = renderer ; this . _componentName = componentName ; if ( componentName ) { this . _setComponentName ( ) ; this . _setMode ( config . get ( 'mode' ) ) ; } } hidden setElementClass ( className , isAdd ) { this . _renderer . setElementClass ( this . _elementRef . nativeElement , className , isAdd ) ; } hidden setElementAttribute ( attributeName , attributeValue ) { this . _renderer . setElementAttribute ( this . _elementRef . nativeElement , attributeName , attributeValue ) ; } hidden setElementStyle ( property , value ) { this . _renderer . setElementStyle ( this . _elementRef . nativeElement , property , value ) ; } hidden _setColor ( newColor , componentName ? ) { if ( componentName ) { this . _componentName = componentName ; } if ( this . _color ) { this . setElementClass ( `${ this . _componentName }-${ this . _mode }-${ this . _color }` , false ) ; } if ( newColor ) { this . setElementClass ( `${ this . _componentName }-${ this . _mode }-${ newColor }` , true ) ; this . _color = newColor ; } } hidden _setMode ( newMode ) { if ( this . _mode ) { this . setElementClass ( `${ this . _componentName }-${ this . _mode }` , false ) ; } if ( newMode ) { this . setElementClass ( `${ this . _componentName }-${ newMode }` , true ) ; this . _setColor ( null ) ; this . _mode = newMode ; this . _setColor ( this . _color ) ; } } hidden _setComponentName ( ) { this . setElementClass ( this . _componentName , true ) ; } hidden getElementRef ( ) { return this . _elementRef ; } hidden getNativeElement ( ) { return this . _elementRef . nativeElement ; } }