refactor(cssClass): update/cleanup css class usage

This commit is contained in:
Adam Bradley
2015-10-08 21:32:14 -05:00
parent 7ccdfed018
commit 18519d1576
25 changed files with 96 additions and 95 deletions

View File

@ -1,4 +1,4 @@
import {Directive, View, Host, Optional, ElementRef, Attribute, Query, QueryList, NgZone} from 'angular2/angular2';
import {Directive, View, Host, Optional, ElementRef, Renderer, Attribute, Query, QueryList, NgZone} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {IonicForm} from '../form/form';
@ -21,8 +21,7 @@ import {IonicPlatform} from '../../platform/platform';
'(touchend)': 'pointerEnd($event)',
'(mouseup)': 'pointerEnd($event)',
'[class.has-focus]': 'hasFocus',
'[class.has-value]': 'hasValue',
'class': 'item'
'[class.has-value]': 'hasValue'
}
})
export class TextInput {
@ -40,11 +39,14 @@ export class TextInput {
form: IonicForm,
elementRef: ElementRef,
config: IonicConfig,
renderer: Renderer,
app: IonicApp,
zone: NgZone,
platform: IonicPlatform,
@Optional() @Host() scrollView: Content
) {
renderer.setElementClass(elementRef, 'item', true);
this.form = form;
form.register(this);
@ -72,7 +74,8 @@ export class TextInput {
*/
onInit() {
if (this.input && this.label) {
this.input.labelledBy = this.label.id = (this.label.id || 'label-' + this.inputId);
this.label.id = (this.label.id || 'label-' + this.inputId)
this.input.labelledBy(this.label.id);
}
let self = this;
@ -384,9 +387,7 @@ export class TextInput {
'tabIndex'
],
host: {
'[tabIndex]': 'tabIndex',
'[attr.aria-labelledby]': 'labelledBy',
'class': 'text-input'
'[tabIndex]': 'tabIndex'
}
})
export class TextInputElement {
@ -395,6 +396,7 @@ export class TextInputElement {
form: IonicForm,
@Attribute('type') type: string,
elementRef: ElementRef,
renderer: Renderer,
@Optional() textInputWrapper: TextInput
) {
this.form = form;
@ -402,6 +404,9 @@ export class TextInputElement {
this.elementRef = elementRef;
this.tabIndex = 0;
this.renderer = renderer;
renderer.setElementAttribute(this.elementRef, 'text-input', '');
if (textInputWrapper) {
// it's within ionic's ion-input, let ion-input handle what's up
textInputWrapper.registerInput(this);
@ -412,6 +417,10 @@ export class TextInputElement {
}
}
labelledBy(val) {
this.renderer.setElementAttribute(this.elementRef, 'aria-labelledby', val);
}
initFocus() {
this.elementRef.nativeElement.focus();
}