Skip to content

Commit

Permalink
Revert "Fixed #1420"
Browse files Browse the repository at this point in the history
This reverts commit e8a93c9.
  • Loading branch information
Çağatay Çivici committed Nov 24, 2016
1 parent e8a93c9 commit 1bcbae4
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions components/radiobutton/radiobutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export const RADIO_VALUE_ACCESSOR: any = {
template: `
<div class="ui-radiobutton ui-widget">
<div class="ui-helper-hidden-accessible">
<input #rb type="radio" [attr.name]="name" [attr.value]="value" [checked]="checked" (change)="onChange($event)"
<input type="radio" [attr.name]="name" [attr.value]="value" [checked]="checked" (change)="onChange($event)"
(focus)="onFocus($event)" (blur)="onBlur($event)">
</div>
<div (click)="handleClick(rb)" (mouseenter)="hover=true" (mouseleave)="hover=false"
<div (click)="handleClick()" (mouseenter)="hover=true" (mouseleave)="hover=false"
[ngClass]="{'ui-radiobutton-box ui-widget ui-state-default':true,
'ui-state-hover':hover&&!disabled,'ui-state-active':rb.checked,'ui-state-disabled':disabled,'ui-state-focus':focused}">
<span class="ui-radiobutton-icon" [ngClass]="{'fa fa-fw fa-circle':rb.checked}"></span>
'ui-state-hover':hover&&!disabled,'ui-state-active':checked,'ui-state-disabled':disabled,'ui-state-focus':focused}">
<span class="ui-radiobutton-icon" [ngClass]="{'fa fa-fw fa-circle':checked}"></span>
</div>
</div>
<label class="ui-radiobutton-label" (click)="select(rb)" *ngIf="label">{{label}}</label>
<label class="ui-radiobutton-label" (click)="select()" *ngIf="label">{{label}}</label>
`,
providers: [RADIO_VALUE_ACCESSOR]
})
Expand All @@ -37,7 +37,9 @@ export class RadioButton implements ControlValueAccessor {
@Input() label: string;

@Output() onClick: EventEmitter<any> = new EventEmitter();


public model: any;

public onModelChange: Function = () => {};

public onModelTouched: Function = () => {};
Expand All @@ -48,22 +50,23 @@ export class RadioButton implements ControlValueAccessor {

public focused: boolean;

handleClick(rb: HTMLInputElement) {
handleClick() {
if(!this.disabled) {
this.onClick.emit(null);
this.select(rb);
this.select();
}
}

select(rb: HTMLInputElement) {
select() {
if(!this.disabled) {
rb.checked = true;
this.checked = true;
this.onModelChange(this.value);
}
}

writeValue(model: any) : void {
this.checked = (model == this.value);
this.model = model;
this.checked = (this.model == this.value);
}

registerOnChange(fn: Function): void {
Expand All @@ -87,8 +90,8 @@ export class RadioButton implements ControlValueAccessor {
this.onModelTouched();
}

onChange(event,rb: HTMLInputElement) {
this.select(rb);
onChange(event) {
this.select();
}
}

Expand Down

0 comments on commit 1bcbae4

Please sign in to comment.