diff --git a/ionic/components/text-input/label.ts b/ionic/components/text-input/label.ts index e46eb0331b..1d8f2a2258 100644 --- a/ionic/components/text-input/label.ts +++ b/ionic/components/text-input/label.ts @@ -1,6 +1,7 @@ -import {Directive} from 'angular2/angular2'; +import {Directive, Optional} from 'angular2/angular2'; import {IonicConfig} from '../../config/config'; +import {TextInput} from './text-input'; import {pointerCoord, hasPointerMoved} from '../../util/dom'; /** @@ -25,8 +26,9 @@ export class Label { * TODO * @param {IonicConfig} config */ - constructor(config: IonicConfig) { + constructor(config: IonicConfig, @Optional() textInput: TextInput) { this.scrollAssist = config.get('keyboardScrollAssist'); + textInput && textInput.registerLabel(this); } /** diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index 47cb379314..74b83b8299 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -11,61 +11,6 @@ import * as dom from '../../util/dom'; import {IonicPlatform} 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 */ @@ -104,9 +49,7 @@ export class TextInput extends Ion { app: IonicApp, ngZone: NgZone, platform: IonicPlatform, - @Optional() @Host() scrollView: Content, - @Query(TextInputElement) inputQry: QueryList, - @Query(Label) labelQry: QueryList