1 | import { Component } from '@angular/core';
|
2 | import { isBs3 } from '../utils/ng2-bootstrap-config';
|
3 | import { DatePickerInnerComponent } from './datepicker-inner.component';
|
4 | export var MonthPickerComponent = (function () {
|
5 | function MonthPickerComponent(datePicker) {
|
6 | this.rows = [];
|
7 | this.datePicker = datePicker;
|
8 | }
|
9 | Object.defineProperty(MonthPickerComponent.prototype, "isBs4", {
|
10 | get: function () {
|
11 | return !isBs3();
|
12 | },
|
13 | enumerable: true,
|
14 | configurable: true
|
15 | });
|
16 | MonthPickerComponent.prototype.ngOnInit = function () {
|
17 | var self = this;
|
18 | this.datePicker.stepMonth = { years: 1 };
|
19 | this.datePicker.setRefreshViewHandler(function () {
|
20 | var months = new Array(12);
|
21 | var year = this.activeDate.getFullYear();
|
22 | var date;
|
23 | for (var i = 0; i < 12; i++) {
|
24 | date = new Date(year, i, 1);
|
25 | date = this.fixTimeZone(date);
|
26 | months[i] = this.createDateObject(date, this.formatMonth);
|
27 | months[i].uid = this.uniqueId + '-' + i;
|
28 | }
|
29 | self.title = this.dateFilter(this.activeDate, this.formatMonthTitle);
|
30 | self.rows = this.split(months, self.datePicker.monthColLimit);
|
31 | }, 'month');
|
32 | this.datePicker.setCompareHandler(function (date1, date2) {
|
33 | var d1 = new Date(date1.getFullYear(), date1.getMonth());
|
34 | var d2 = new Date(date2.getFullYear(), date2.getMonth());
|
35 | return d1.getTime() - d2.getTime();
|
36 | }, 'month');
|
37 | this.datePicker.refreshView();
|
38 | };
|
39 |
|
40 | MonthPickerComponent.decorators = [
|
41 | { type: Component, args: [{
|
42 | selector: 'monthpicker',
|
43 | template: "\n<table *ngIf=\"datePicker.datepickerMode==='month'\" role=\"grid\">\n <thead>\n <tr>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-left\"\n (click)=\"datePicker.move(-1)\" tabindex=\"-1\">\n <i class=\"glyphicon glyphicon-chevron-left\"></i>\n </button></th>\n <th [attr.colspan]=\"((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2\">\n <button [id]=\"datePicker.uniqueId + '-title'\"\n type=\"button\" class=\"btn btn-default btn-sm\"\n (click)=\"datePicker.toggleMode()\"\n [disabled]=\"datePicker.datepickerMode === maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{title}}</strong>\n </button>\n </th>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-right\"\n (click)=\"datePicker.move(1)\" tabindex=\"-1\">\n <i class=\"glyphicon glyphicon-chevron-right\"></i>\n </button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let rowz of rows\">\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" id=\"{{dtz.uid}}\" [ngClass]=\"dtz.customClass\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\"\n [ngClass]=\"{'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)}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}\">{{dtz.label}}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n "
|
44 | },] },
|
45 | ];
|
46 |
|
47 | MonthPickerComponent.ctorParameters = function () { return [
|
48 | { type: DatePickerInnerComponent, },
|
49 | ]; };
|
50 | return MonthPickerComponent;
|
51 | }());
|
52 |
|
\ | No newline at end of file |