/** * Created by Menna on 8/24/16. */ import { ElementRef, Input, Component, AfterViewInit, ViewChild } from '@angular/core'; import { DatePicker } from './datetimepicker.widget' import { Mediator } from '../../services/mediator'; import { CoreMediatorChannels } from '../../utils/mediator-channels'; import { TranslateService } from '../../services/translate-service'; import DatePickerOptions = kendo.ui.DatePickerOptions; @Component({ selector: 'kendo_datepicker', template: ``, //styleUrls: ['./datetimepicker.widget.css'] }) export class DatePickerComponent implements AfterViewInit { @Input() private options: DatePickerOptions; @ViewChild('devRef') private element: ElementRef; private protoType: DatePicker; private lang = ''; constructor(private translateService: TranslateService) { this.lang = this.translateService.instant('lang-key'); } ngAfterViewInit() { this.protoType = new DatePicker(this.element.nativeElement, this.options); if (this.lang == 'ar') { this.protoType.options.culture = "ar-EG"; this.protoType.setOptions(this.protoType.options); } Mediator.subscribe(CoreMediatorChannels.CHANGE_SYSTEM_LANGUAGE, () => { this.lang = this.translateService.instant('lang-key'); if (this.lang == 'ar') { this.protoType.options.culture = "ar-EG"; this.protoType.setOptions(this.protoType.options); } else { this.protoType.options.culture = ""; this.protoType.setOptions(this.protoType.options); } }); } get ProtoType(): DatePicker { return this.protoType; } set ProtoType(protoType: DatePicker) { this.protoType = protoType; } }