Skip to content

Commit

Permalink
Fixed #269
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Apr 27, 2016
1 parent a4ae85f commit c2627e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CALENDAR_VALUE_ACCESSOR: Provider = CONST_EXPR(
<span [attr.style]="style" [class]="styleClass" [ngClass]="'ui-calendar'" *ngIf="!inline">
<input #in type="text" [attr.placeholder]="placeholder" [attr.style]="inputStyle" [class]="inputStyleClass"
[value]="value||''" (input)="onInput($event)" [readonly]="readonlyInput"
[disabled]="disabled" (mouseenter)="hovered=true" (mouseleave)="hovered=false" (focus)="focused=true" (blur)="onBlur($event)"
[disabled]="disabled" (mouseenter)="hovered=true" (mouseleave)="hovered=false" (focus)="focused=true" (blur)="handleBlur($event)"
[ngClass]="{'ui-inputtext ui-widget ui-state-default': true, 'ui-corner-all': !showIcon, 'ui-corner-left': showIcon,
'ui-state-hover':hovered,'ui-state-focus':focused,'ui-state-disabled':disabled}"
><button type="button" icon="fa-calendar" pButton *ngIf="showIcon" (click)="onButtonClick($event,in)" class="ui-datepicker-trigger"></button></span>
Expand Down Expand Up @@ -109,6 +109,8 @@ export class Calendar implements AfterViewInit,OnChanges,OnDestroy,ControlValueA

@Input() locale: any;

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

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

value: string;
Expand Down Expand Up @@ -191,10 +193,11 @@ export class Calendar implements AfterViewInit,OnChanges,OnDestroy,ControlValueA
this.onModelChange(event.target.value);
}

onBlur(event) {
handleBlur(event) {
this.value = event.target.value;
this.onModelTouched();
this.focused=false;
this.onBlur.emit(event);
}

writeValue(value: any) : void {
Expand Down
6 changes: 6 additions & 0 deletions showcase/demo/calendar/calendardemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ <h3>Events</h3>
</td>
<td>Callback to invoke when a date is selected.</td>
</tr>
<tr>
<td>onBlur</td>
<td>event: Blur event
</td>
<td>Callback to invoke on blur of input field.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit c2627e3

Please sign in to comment.