UNPKG

ng2-bootstrap

Version:
52 lines 4.05 kB
import { Component } from '@angular/core'; import { isBs3 } from '../utils/ng2-bootstrap-config'; import { DatePickerInnerComponent } from './datepicker-inner.component'; export var MonthPickerComponent = (function () { function MonthPickerComponent(datePicker) { this.rows = []; this.datePicker = datePicker; } Object.defineProperty(MonthPickerComponent.prototype, "isBs4", { get: function () { return !isBs3(); }, enumerable: true, configurable: true }); MonthPickerComponent.prototype.ngOnInit = function () { var self = this; this.datePicker.stepMonth = { years: 1 }; this.datePicker.setRefreshViewHandler(function () { var months = new Array(12); var year = this.activeDate.getFullYear(); var date; for (var i = 0; i < 12; i++) { date = new Date(year, i, 1); date = this.fixTimeZone(date); months[i] = this.createDateObject(date, this.formatMonth); months[i].uid = this.uniqueId + '-' + i; } self.title = this.dateFilter(this.activeDate, this.formatMonthTitle); self.rows = this.split(months, self.datePicker.monthColLimit); }, 'month'); this.datePicker.setCompareHandler(function (date1, date2) { var d1 = new Date(date1.getFullYear(), date1.getMonth()); var d2 = new Date(date2.getFullYear(), date2.getMonth()); return d1.getTime() - d2.getTime(); }, 'month'); this.datePicker.refreshView(); }; // todo: key events implementation MonthPickerComponent.decorators = [ { type: Component, args: [{ selector: 'monthpicker', 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 " },] }, ]; /** @nocollapse */ MonthPickerComponent.ctorParameters = function () { return [ { type: DatePickerInnerComponent, }, ]; }; return MonthPickerComponent; }()); //# sourceMappingURL=monthpicker.component.js.map