import {Directive, View, Host, Optional, ElementRef, Attribute, Query, QueryList, NgZone} from 'angular2/angular2'; import {IonicDirective} from '../../config/annotations'; import {IonicConfig} from '../../config/config'; import {IonInput} from '../form/input'; import {Label} from '../form/label'; import {Ion} from '../ion'; import {IonicApp} from '../app/app'; import {Content} from '../content/content'; import {ClickBlock} from '../../util/click-block'; import {Platform} from '../../platform/platform'; import * as dom from '../../util/dom'; @Directive({ selector: 'textarea,input[type=text],input[type=password],input[type=number],input[type=search],input[type=email],input[type=url],input[type=tel]', property: [ 'tabIndex' ], host: { '[tabIndex]': 'tabIndex', '[attr.aria-labelledby]': 'labelledBy', 'class': 'text-input input' } }) export class TextInputElement { constructor( @Attribute('type') type: string, elementRef: ElementRef, config: IonicConfig ) { this.type = type; this.elementRef = elementRef; this.tabIndex = this.tabIndex || ''; } setFocus() { this.elementRef.nativeElement.focus(); } get hasFocus() { return dom.hasFocus(this.elementRef); } } @IonicDirective({ selector: 'ion-input', classId: 'item-input', properties: [ 'tabIndex' ], host: { '(focus)': 'receivedFocus(true)', '(blur)': 'receivedFocus(false)', '(^touchstart)': 'pointerStart($event)', '(^touchend)': 'pointerEnd($event)', '(^mouseup)': 'pointerEnd($event)', '[class.has-focus]': 'inputHasFocus', '[tabIndex]': 'activeTabIndex', 'class': 'item' } }) export class TextInput extends Ion { constructor( elementRef: ElementRef, config: IonicConfig, app: IonicApp, ngZone: NgZone, @Optional() @Host() scrollView: Content, @Query(TextInputElement) inputQry: QueryList, @Query(Label) labelQry: QueryList