ngx-bootstrap
Version:
Angular Bootstrap
91 lines • 3.85 kB
JavaScript
// @deprecated
import { Component } from '@angular/core';
import { isBs3 } from 'ngx-bootstrap/utils';
import { DatePickerInnerComponent } from './datepicker-inner.component';
export class MonthPickerComponent {
constructor(datePicker) {
this.rows = [];
this.datePicker = datePicker;
}
get isBs4() {
return !isBs3();
}
ngOnInit() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
this.datePicker.stepMonth = { years: 1 };
this.datePicker.setRefreshViewHandler(function () {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this;
const months = new Array(12);
const year = that.activeDate.getFullYear();
let date;
for (let i = 0; i < 12; i++) {
date = new Date(year, i, 1);
date = that.fixTimeZone(date);
months[i] = that.createDateObject(date, that.formatMonth);
months[i].uid = that.uniqueId + '-' + i;
}
self.title = that.dateFilter(that.activeDate, that.formatMonthTitle);
self.rows = that.split(months, self.datePicker.monthColLimit);
}, 'month');
this.datePicker.setCompareHandler(function (date1, date2) {
const d1 = new Date(date1.getFullYear(), date1.getMonth());
const d2 = new Date(date2.getFullYear(), date2.getMonth());
return d1.getTime() - d2.getTime();
}, 'month');
this.datePicker.refreshView();
}
}
MonthPickerComponent.decorators = [
{ type: Component, args: [{
selector: 'monthpicker',
template: `
<table *ngIf="datePicker.datepickerMode==='month'" role="grid">
<thead>
<tr>
<th>
<button type="button" class="btn btn-default btn-sm pull-left float-left"
(click)="datePicker.move(-1)" tabindex="-1">‹</button></th>
<th [attr.colspan]="((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2">
<button [id]="datePicker.uniqueId + '-title'"
type="button" class="btn btn-default btn-sm"
(click)="datePicker.toggleMode(0)"
[]="datePicker.datepickerMode === maxMode"
[]="{disabled: datePicker.datepickerMode === maxMode}" tabindex="-1" style="width:100%;">
<strong>{{ title }}</strong>
</button>
</th>
<th>
<button type="button" class="btn btn-default btn-sm pull-right float-right"
(click)="datePicker.move(1)" tabindex="-1">›</button>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let rowz of rows">
<td *ngFor="let dtz of rowz" class="text-center" role="gridcell" [attr.id]="dtz.uid" [ngClass]="dtz.customClass">
<button type="button" style="min-width:100%;" class="btn btn-default"
[]="{'btn-link': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected || (isBs4 && !dtz.selected && datePicker.isActive(dtz)), disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz)}"
[]="dtz.disabled"
(click)="datePicker.select(dtz.date)" tabindex="-1">
<span [ngClass]="{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}">{{ dtz.label }}</span>
</button>
</td>
</tr>
</tbody>
</table>
`,
styles: [`
:host .btn-info .text-success {
color:
}
`]
},] }
];
MonthPickerComponent.ctorParameters = () => [
{ type: DatePickerInnerComponent }
];
//# sourceMappingURL=monthpicker.component.js.map