Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Apr 6, 2016
1 parent 30a1bd9 commit 66708d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
13 changes: 3 additions & 10 deletions components/inputtext/inputtext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Directive,ElementRef,HostListener,Input} from 'angular2/core';
import {NgModel} from 'angular2/common';

@Directive({
selector: '[pInputText]',
Expand All @@ -10,18 +9,16 @@ import {NgModel} from 'angular2/common';
'[class.ui-widget]': 'true',
'[class.ui-state-hover]': 'hover',
'[class.ui-state-focus]': 'focus',
'[class.ui-state-disabled]': 'isDisabled()',
'[class.ui-state-error]': 'isInvalid()'
},
providers: [NgModel]
'[class.ui-state-disabled]': 'isDisabled()'
}
})
export class InputText {

hover: boolean;

focus: boolean;

constructor(private el: ElementRef, private control: NgModel) {}
constructor(private el: ElementRef) {}

@HostListener('mouseover', ['$event'])
onMouseover(e) {
Expand All @@ -46,8 +43,4 @@ export class InputText {
isDisabled() {
return this.el.nativeElement.disabled;
}

isInvalid() {
return !this.control.valid;
}
}
11 changes: 2 additions & 9 deletions components/inputtextarea/inputtextarea.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Directive,ElementRef,HostListener,Input,OnInit} from 'angular2/core';
import {NgModel} from 'angular2/common';

@Directive({
selector: '[pInputTextarea]',
Expand All @@ -11,11 +10,9 @@ import {NgModel} from 'angular2/common';
'[class.ui-state-hover]': 'hover',
'[class.ui-state-focus]': 'focus',
'[class.ui-state-disabled]': 'isDisabled()',
'[class.ui-state-error]': 'isInvalid()',
'[attr.rows]': 'rows',
'[attr.cols]': 'cols'
},
providers: [NgModel]
}
})
export class InputTextarea implements OnInit {

Expand All @@ -33,7 +30,7 @@ export class InputTextarea implements OnInit {

colsDefault: number;

constructor(private el: ElementRef, private control: NgModel) {}
constructor(private el: ElementRef) {}

ngOnInit() {
this.rowsDefault = this.rows;
Expand Down Expand Up @@ -72,10 +69,6 @@ export class InputTextarea implements OnInit {
return this.el.nativeElement.disabled;
}

isInvalid() {
return !this.control.valid;
}

@HostListener('keyup', ['$event'])
onKeyup(e) {
if(this.autoResize) {
Expand Down

0 comments on commit 66708d8

Please sign in to comment.