Skip to content

Commit

Permalink
fix(aot): 2 more private methods made public
Browse files Browse the repository at this point in the history
fixes #1093
  • Loading branch information
valorkin committed Oct 7, 2016
1 parent b070237 commit 0dbbf09
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 66 deletions.
124 changes: 63 additions & 61 deletions components/datepicker/datepicker-inner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,61 +45,61 @@ const SHORTCUT_PROPAGATION = false;
`
})
export class DatePickerInnerComponent implements OnInit, OnChanges {
@Input() public datepickerMode:string;
@Input() public startingDay:number;
@Input() public yearRange:number;

@Input() public minDate:Date;
@Input() public maxDate:Date;
@Input() public minMode:string;
@Input() public maxMode:string;
@Input() public showWeeks:boolean;
@Input() public formatDay:string;
@Input() public formatMonth:string;
@Input() public formatYear:string;
@Input() public formatDayHeader:string;
@Input() public formatDayTitle:string;
@Input() public formatMonthTitle:string;
@Input() public onlyCurrentMonth:boolean;
@Input() public shortcutPropagation:boolean;
@Input() public customClass:Array<{date:Date, mode:string, clazz:string}>;
@Input() public datepickerMode: string;
@Input() public startingDay: number;
@Input() public yearRange: number;

@Input() public minDate: Date;
@Input() public maxDate: Date;
@Input() public minMode: string;
@Input() public maxMode: string;
@Input() public showWeeks: boolean;
@Input() public formatDay: string;
@Input() public formatMonth: string;
@Input() public formatYear: string;
@Input() public formatDayHeader: string;
@Input() public formatDayTitle: string;
@Input() public formatMonthTitle: string;
@Input() public onlyCurrentMonth: boolean;
@Input() public shortcutPropagation: boolean;
@Input() public customClass: Array<{date: Date, mode: string, clazz: string}>;
// todo: change type during implementation
@Input() public dateDisabled:any;
@Input() public initDate:Date;
@Input() public dateDisabled: any;
@Input() public initDate: Date;

@Output() public selectionDone:EventEmitter<Date> = new EventEmitter<Date>(undefined);
@Output() public selectionDone: EventEmitter<Date> = new EventEmitter<Date>(undefined);

@Output() public update:EventEmitter<Date> = new EventEmitter<Date>(false);
@Output() public update: EventEmitter<Date> = new EventEmitter<Date>(false);

public stepDay:any = {};
public stepMonth:any = {};
public stepYear:any = {};
public stepDay: any = {};
public stepMonth: any = {};
public stepYear: any = {};

private modes:Array<string> = ['day', 'month', 'year'];
private dateFormatter:DateFormatter = new DateFormatter();
private uniqueId:string;
private _activeDate:Date;
private selectedDate:Date;
private activeDateId:string;
private modes: Array<string> = ['day', 'month', 'year'];
private dateFormatter: DateFormatter = new DateFormatter();
private uniqueId: string;
private _activeDate: Date;
private selectedDate: Date;
private activeDateId: string;

private refreshViewHandlerDay:Function;
private compareHandlerDay:Function;
private refreshViewHandlerMonth:Function;
private compareHandlerMonth:Function;
private refreshViewHandlerYear:Function;
private compareHandlerYear:Function;
private refreshViewHandlerDay: Function;
private compareHandlerDay: Function;
private refreshViewHandlerMonth: Function;
private compareHandlerMonth: Function;
private refreshViewHandlerYear: Function;
private compareHandlerYear: Function;

@Input()
public get activeDate():Date {
public get activeDate(): Date {
return this._activeDate;
}

public set activeDate(value:Date) {
public set activeDate(value: Date) {
this._activeDate = value;
}

// todo: add formatter value to Date object
public ngOnInit():void {
public ngOnInit(): void {
this.formatDay = this.formatDay || FORMAT_DAY;
this.formatMonth = this.formatMonth || FORMAT_MONTH;
this.formatYear = this.formatYear || FORMAT_YEAR;
Expand Down Expand Up @@ -133,11 +133,11 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {

// this.refreshView should be called here to reflect the changes on the fly
// tslint:disable-next-line:no-unused-variable
public ngOnChanges(changes:SimpleChanges):void {
public ngOnChanges(changes: SimpleChanges): void {
this.refreshView();
}

public setCompareHandler(handler:Function, type:string):void {
public setCompareHandler(handler: Function, type: string): void {
if (type === 'day') {
this.compareHandlerDay = handler;
}
Expand All @@ -151,7 +151,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}
}

public compare(date1:Date, date2:Date):number {
public compare(date1: Date, date2: Date): number {
if (date1 === undefined || date2 === undefined) {
return undefined;
}
Expand All @@ -171,7 +171,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
return void 0;
}

public setRefreshViewHandler(handler:Function, type:string):void {
public setRefreshViewHandler(handler: Function, type: string): void {
if (type === 'day') {
this.refreshViewHandlerDay = handler;
}
Expand All @@ -185,7 +185,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}
}

public refreshView():void {
public refreshView(): void {
if (this.datepickerMode === 'day' && this.refreshViewHandlerDay) {
this.refreshViewHandlerDay();
}
Expand All @@ -199,11 +199,11 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}
}

public dateFilter(date:Date, format:string):string {
public dateFilter(date: Date, format: string): string {
return this.dateFormatter.format(date, format);
}

public isActive(dateObject:any):boolean {
public isActive(dateObject: any): boolean {
if (this.compare(dateObject.date, this.activeDate) === 0) {
this.activeDateId = dateObject.uid;
return true;
Expand All @@ -212,8 +212,8 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
return false;
}

public createDateObject(date:Date, format:string):any {
let dateObject:any = {};
public createDateObject(date: Date, format: string): any {
let dateObject: any = {};
dateObject.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
dateObject.label = this.dateFilter(date, format);
dateObject.selected = this.compare(date, this.selectedDate) === 0;
Expand All @@ -223,8 +223,8 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
return dateObject;
}

public split(arr:Array<any>, size:number):Array<any> {
let arrays:Array<any> = [];
public split(arr: Array<any>, size: number): Array<any> {
let arrays: Array<any> = [];
while (arr.length > 0) {
arrays.push(arr.splice(0, size));
}
Expand All @@ -237,19 +237,21 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
// var date = new Date(2014, 0, 1);
// console.log(date.getFullYear(), date.getMonth(), date.getDate(),
// date.getHours()); can result in "2013 11 31 23" because of the bug.
public fixTimeZone(date:Date):Date {
public fixTimeZone(date: Date): Date {
let hours = date.getHours();
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours === 23 ? hours + 2 : 0);
}

public select(date:Date):void {
public select(date: Date, isManual: boolean = true): void {
if (this.datepickerMode === this.minMode) {
if (!this.activeDate) {
this.activeDate = new Date(0, 0, 0, 0, 0, 0, 0);
}

this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
this.selectionDone.emit(this.activeDate);
if (isManual) {
this.selectionDone.emit(this.activeDate);
}
} else {
this.activeDate = date;
this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
Expand All @@ -260,8 +262,8 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
this.refreshView();
}

public move(direction:number):void {
let expectedStep:any;
public move(direction: number): void {
let expectedStep: any;
if (this.datepickerMode === 'day') {
expectedStep = this.stepDay;
}
Expand All @@ -283,7 +285,7 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
}
}

public toggleMode(direction:number):void {
public toggleMode(direction: number): void {
direction = direction || 1;

if ((this.datepickerMode === this.maxMode && direction === 1) ||
Expand All @@ -295,20 +297,20 @@ export class DatePickerInnerComponent implements OnInit, OnChanges {
this.refreshView();
}

private getCustomClassForDate(date:Date):string {
private getCustomClassForDate(date: Date): string {
if (!this.customClass) {
return '';
}
// todo: build a hash of custom classes, it will work faster
const customClassObject:{date:Date, mode:string, clazz:string} = this.customClass
.find((customClass:any) => {
const customClassObject: {date: Date, mode: string, clazz: string} = this.customClass
.find((customClass: any) => {
return customClass.date.valueOf() === date.valueOf() &&
customClass.mode === this.datepickerMode;
}, this);
return customClassObject === undefined ? '' : customClassObject.clazz;
}

private isDisabled(date:Date):boolean {
private isDisabled(date: Date): boolean {
// todo: implement dateDisabled attribute
return ((this.minDate && this.compare(date, this.minDate) < 0) ||
(this.maxDate && this.compare(date, this.maxDate) > 0));
Expand Down
8 changes: 4 additions & 4 deletions components/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ export class DatePickerComponent implements ControlValueAccessor {

@Output() public selectionDone:EventEmitter<Date> = new EventEmitter<Date>(undefined);

@ViewChild(DatePickerInnerComponent) public _datePicker: DatePickerInnerComponent;

public onChange:any = Function.prototype;
public onTouched:any = Function.prototype;

public cd:NgModel;
private _now:Date = new Date();
private _activeDate:Date;

@ViewChild(DatePickerInnerComponent) private datePicker: DatePickerInnerComponent;

@Input()
public get activeDate():Date {
return this._activeDate || this._now;
Expand All @@ -94,12 +94,12 @@ export class DatePickerComponent implements ControlValueAccessor {

// todo: support null value
public writeValue(value:any):void {
if (this.datePicker.compare(value, this._activeDate) === 0) {
if (this._datePicker.compare(value, this._activeDate) === 0) {
return;
}
if (value && value instanceof Date) {
this.activeDate = value;
this.datePicker.select(value);
this._datePicker.select(value);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion components/timepicker/timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class TimepickerComponent implements ControlValueAccessor, OnInit {
this.readonlyInput = isDisabled;
}

protected updateHours():void {
public updateHours():void {
if (this.readonlyInput) {
return;
}
Expand Down

0 comments on commit 0dbbf09

Please sign in to comment.