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 './label'; import {Ion} from '../ion'; import {IonicApp} from '../app/app'; import {Content} from '../content/content'; import {ClickBlock} from '../../util/click-block'; import * as dom from '../../util/dom'; import {Platform} from '../../platform/platform'; /** * TODO */ @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 { /** * TODO * @param {string} type The value of the underlying element's type attribute. * @param {ElementRef} elementRef TODO * @param {IonicConfig} config TODO */ constructor( @Attribute('type') type: string, elementRef: ElementRef, config: IonicConfig ) { this.type = type; this.elementRef = elementRef; this.tabIndex = this.tabIndex || ''; } /** * Focus the input. */ setFocus() { this.elementRef.nativeElement.focus(); } /** * Whether the input has focus or not. * @returns {boolean} true if the input has focus, otherwise false. */ get hasFocus() { return dom.hasFocus(this.elementRef); } /** * Whether the input has a value. * @returns {boolean} true if the input has a value, otherwise false. */ get hasValue() { return (this.elementRef.nativeElement.value !== ''); } } /** * TODO */ @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', '[class.has-value]': 'inputHasValue', '[tabIndex]': 'activeTabIndex', 'class': 'item' } }) export class TextInput extends Ion { /** * TODO * @param {ElementRef} elementRef TODO * @param {IonicConfig} config TODO * @param {IonicApp} app TODO * @param {NgZone} ngZone TODO * @param {Content=} scrollView The parent scroll view. * @param {QueryList} inputQry TODO * @param {QueryList