| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922 |
- "use strict";
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- var __metadata = (this && this.__metadata) || function (k, v) {
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var core_1 = require("@angular/core");
- var animations_1 = require("@angular/animations");
- var common_1 = require("@angular/common");
- var button_1 = require("../button/button");
- var domhandler_1 = require("../dom/domhandler");
- var shared_1 = require("../common/shared");
- var forms_1 = require("@angular/forms");
- exports.CALENDAR_VALUE_ACCESSOR = {
- provide: forms_1.NG_VALUE_ACCESSOR,
- useExisting: core_1.forwardRef(function () { return Calendar; }),
- multi: true
- };
- var Calendar = /** @class */ (function () {
- function Calendar(el, renderer, cd, zone) {
- this.el = el;
- this.renderer = renderer;
- this.cd = cd;
- this.zone = zone;
- this.dateFormat = 'mm/dd/yy';
- this.multipleSeparator = ',';
- this.rangeSeparator = '-';
- this.inline = false;
- this.showOtherMonths = true;
- this.icon = 'pi pi-calendar';
- this.shortYearCutoff = '+10';
- this.hourFormat = '24';
- this.stepHour = 1;
- this.stepMinute = 1;
- this.stepSecond = 1;
- this.showSeconds = false;
- this.showOnFocus = true;
- this.showWeek = false;
- this.dataType = 'date';
- this.selectionMode = 'single';
- this.todayButtonStyleClass = 'ui-button-secondary';
- this.clearButtonStyleClass = 'ui-button-secondary';
- this.autoZIndex = true;
- this.baseZIndex = 0;
- this.keepInvalid = false;
- this.hideOnDateTimeSelect = false;
- this.numberOfMonths = 1;
- this.view = 'date';
- this.timeSeparator = ":";
- this.showTransitionOptions = '225ms ease-out';
- this.hideTransitionOptions = '195ms ease-in';
- this.onFocus = new core_1.EventEmitter();
- this.onBlur = new core_1.EventEmitter();
- this.onClose = new core_1.EventEmitter();
- this.onSelect = new core_1.EventEmitter();
- this.onInput = new core_1.EventEmitter();
- this.onTodayClick = new core_1.EventEmitter();
- this.onClearClick = new core_1.EventEmitter();
- this.onMonthChange = new core_1.EventEmitter();
- this.onYearChange = new core_1.EventEmitter();
- this._locale = {
- firstDayOfWeek: 0,
- dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
- dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
- dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
- monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
- monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
- today: 'Today',
- clear: 'Clear',
- dateFormat: 'mm/dd/yy',
- weekHeader: 'Wk'
- };
- this.onModelChange = function () { };
- this.onModelTouched = function () { };
- this.inputFieldValue = null;
- }
- Object.defineProperty(Calendar.prototype, "utc", {
- get: function () {
- return this._utc;
- },
- set: function (_utc) {
- this._utc = _utc;
- console.log("Setting utc has no effect as built-in UTC support is dropped.");
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "minDate", {
- get: function () {
- return this._minDate;
- },
- set: function (date) {
- this._minDate = date;
- if (this.currentMonth != undefined && this.currentMonth != null && this.currentYear) {
- this.createMonths(this.currentMonth, this.currentYear);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "maxDate", {
- get: function () {
- return this._maxDate;
- },
- set: function (date) {
- this._maxDate = date;
- if (this.currentMonth != undefined && this.currentMonth != null && this.currentYear) {
- this.createMonths(this.currentMonth, this.currentYear);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "disabledDates", {
- get: function () {
- return this._disabledDates;
- },
- set: function (disabledDates) {
- this._disabledDates = disabledDates;
- if (this.currentMonth != undefined && this.currentMonth != null && this.currentYear) {
- this.createMonths(this.currentMonth, this.currentYear);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "disabledDays", {
- get: function () {
- return this._disabledDays;
- },
- set: function (disabledDays) {
- this._disabledDays = disabledDays;
- if (this.currentMonth != undefined && this.currentMonth != null && this.currentYear) {
- this.createMonths(this.currentMonth, this.currentYear);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "yearRange", {
- get: function () {
- return this._yearRange;
- },
- set: function (yearRange) {
- this._yearRange = yearRange;
- if (this.yearNavigator && yearRange) {
- var years = yearRange.split(':');
- var yearStart = parseInt(years[0]);
- var yearEnd = parseInt(years[1]);
- this.populateYearOptions(yearStart, yearEnd);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "showTime", {
- get: function () {
- return this._showTime;
- },
- set: function (showTime) {
- this._showTime = showTime;
- if (this.currentHour === undefined) {
- this.initTime(this.value || new Date());
- }
- this.updateInputfield();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Calendar.prototype, "locale", {
- get: function () {
- return this._locale;
- },
- set: function (newLocale) {
- this._locale = newLocale;
- if (this.view === 'date') {
- this.createWeekDays();
- this.createMonths(this.currentMonth, this.currentYear);
- }
- else if (this.view === 'month') {
- this.createMonthPickerValues();
- }
- },
- enumerable: true,
- configurable: true
- });
- Calendar.prototype.ngOnInit = function () {
- var date = this.defaultDate || new Date();
- this.currentMonth = date.getMonth();
- this.currentYear = date.getFullYear();
- if (this.view === 'date') {
- this.createWeekDays();
- this.initTime(date);
- this.createMonths(this.currentMonth, this.currentYear);
- this.ticksTo1970 = (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000);
- }
- else if (this.view === 'month') {
- this.createMonthPickerValues();
- }
- };
- Calendar.prototype.ngAfterContentInit = function () {
- var _this = this;
- this.templates.forEach(function (item) {
- switch (item.getType()) {
- case 'date':
- _this.dateTemplate = item.template;
- break;
- default:
- _this.dateTemplate = item.template;
- break;
- }
- });
- };
- Calendar.prototype.populateYearOptions = function (start, end) {
- this.yearOptions = [];
- for (var i = start; i <= end; i++) {
- this.yearOptions.push(i);
- }
- };
- Calendar.prototype.createWeekDays = function () {
- this.weekDays = [];
- var dayIndex = this.locale.firstDayOfWeek;
- for (var i = 0; i < 7; i++) {
- this.weekDays.push(this.locale.dayNamesMin[dayIndex]);
- dayIndex = (dayIndex == 6) ? 0 : ++dayIndex;
- }
- };
- Calendar.prototype.createMonthPickerValues = function () {
- this.monthPickerValues = [];
- for (var i = 0; i <= 11; i++) {
- this.monthPickerValues.push(this.locale.monthNamesShort[i]);
- }
- };
- Calendar.prototype.createMonths = function (month, year) {
- this.months = this.months = [];
- for (var i = 0; i < this.numberOfMonths; i++) {
- var m = month + i;
- var y = year;
- if (m > 11) {
- m = m % 11 - 1;
- y = year + 1;
- }
- this.months.push(this.createMonth(m, y));
- }
- };
- Calendar.prototype.getWeekNumber = function (date) {
- var checkDate = new Date(date.getTime());
- checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
- var time = checkDate.getTime();
- checkDate.setMonth(0);
- checkDate.setDate(1);
- return Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1;
- };
- Calendar.prototype.createMonth = function (month, year) {
- var dates = [];
- var firstDay = this.getFirstDayOfMonthIndex(month, year);
- var daysLength = this.getDaysCountInMonth(month, year);
- var prevMonthDaysLength = this.getDaysCountInPrevMonth(month, year);
- var dayNo = 1;
- var today = new Date();
- var weekNumbers = [];
- var monthRows = Math.ceil((daysLength + firstDay) / 7);
- for (var i = 0; i < monthRows; i++) {
- var week = [];
- if (i == 0) {
- for (var j = (prevMonthDaysLength - firstDay + 1); j <= prevMonthDaysLength; j++) {
- var prev = this.getPreviousMonthAndYear(month, year);
- week.push({ day: j, month: prev.month, year: prev.year, otherMonth: true,
- today: this.isToday(today, j, prev.month, prev.year), selectable: this.isSelectable(j, prev.month, prev.year, true) });
- }
- var remainingDaysLength = 7 - week.length;
- for (var j = 0; j < remainingDaysLength; j++) {
- week.push({ day: dayNo, month: month, year: year, today: this.isToday(today, dayNo, month, year),
- selectable: this.isSelectable(dayNo, month, year, false) });
- dayNo++;
- }
- }
- else {
- for (var j = 0; j < 7; j++) {
- if (dayNo > daysLength) {
- var next = this.getNextMonthAndYear(month, year);
- week.push({ day: dayNo - daysLength, month: next.month, year: next.year, otherMonth: true,
- today: this.isToday(today, dayNo - daysLength, next.month, next.year),
- selectable: this.isSelectable((dayNo - daysLength), next.month, next.year, true) });
- }
- else {
- week.push({ day: dayNo, month: month, year: year, today: this.isToday(today, dayNo, month, year),
- selectable: this.isSelectable(dayNo, month, year, false) });
- }
- dayNo++;
- }
- }
- if (this.showWeek) {
- weekNumbers.push(this.getWeekNumber(new Date(week[0].year, week[0].month, week[0].day)));
- }
- dates.push(week);
- }
- return {
- month: month,
- year: year,
- dates: dates,
- weekNumbers: weekNumbers
- };
- };
- Calendar.prototype.initTime = function (date) {
- this.pm = date.getHours() > 11;
- if (this.showTime) {
- this.currentMinute = date.getMinutes();
- this.currentSecond = date.getSeconds();
- if (this.hourFormat == '12')
- this.currentHour = date.getHours() == 0 ? 12 : date.getHours() % 12;
- else
- this.currentHour = date.getHours();
- }
- else if (this.timeOnly) {
- this.currentMinute = 0;
- this.currentHour = 0;
- this.currentSecond = 0;
- }
- };
- Calendar.prototype.navBackward = function (event) {
- event.stopPropagation();
- if (this.disabled) {
- event.preventDefault();
- return;
- }
- if (this.view === 'month') {
- this.decrementYear();
- }
- else {
- if (this.currentMonth === 0) {
- this.currentMonth = 11;
- this.decrementYear();
- }
- else {
- this.currentMonth--;
- }
- this.onMonthChange.emit({ month: this.currentMonth + 1, year: this.currentYear });
- this.createMonths(this.currentMonth, this.currentYear);
- }
- };
- Calendar.prototype.navForward = function (event) {
- event.stopPropagation();
- if (this.disabled) {
- event.preventDefault();
- return;
- }
- if (this.view === 'month') {
- this.incrementYear();
- }
- else {
- if (this.currentMonth === 11) {
- this.currentMonth = 0;
- this.incrementYear();
- }
- else {
- this.currentMonth++;
- }
- this.onMonthChange.emit({ month: this.currentMonth + 1, year: this.currentYear });
- this.createMonths(this.currentMonth, this.currentYear);
- }
- };
- Calendar.prototype.decrementYear = function () {
- this.currentYear--;
- if (this.yearNavigator && this.currentYear < this.yearOptions[0]) {
- var difference = this.yearOptions[this.yearOptions.length - 1] - this.yearOptions[0];
- this.populateYearOptions(this.yearOptions[0] - difference, this.yearOptions[this.yearOptions.length - 1] - difference);
- }
- };
- Calendar.prototype.incrementYear = function () {
- this.currentYear++;
- if (this.yearNavigator && this.currentYear > this.yearOptions[this.yearOptions.length - 1]) {
- var difference = this.yearOptions[this.yearOptions.length - 1] - this.yearOptions[0];
- this.populateYearOptions(this.yearOptions[0] + difference, this.yearOptions[this.yearOptions.length - 1] + difference);
- }
- };
- Calendar.prototype.onDateSelect = function (event, dateMeta) {
- var _this = this;
- if (this.disabled || !dateMeta.selectable) {
- event.preventDefault();
- return;
- }
- if (this.isMultipleSelection() && this.isSelected(dateMeta)) {
- this.value = this.value.filter(function (date, i) {
- return !_this.isDateEquals(date, dateMeta);
- });
- this.updateModel(this.value);
- }
- else {
- if (this.shouldSelectDate(dateMeta)) {
- if (dateMeta.otherMonth) {
- this.currentMonth = dateMeta.month;
- this.currentYear = dateMeta.year;
- this.createMonths(this.currentMonth, this.currentYear);
- this.selectDate(dateMeta);
- }
- else {
- this.selectDate(dateMeta);
- }
- }
- }
- if (this.isSingleSelection() && (!this.showTime || this.hideOnDateTimeSelect)) {
- setTimeout(function () {
- event.preventDefault();
- _this.hideOverlay();
- if (_this.mask) {
- _this.disableModality();
- }
- _this.cd.markForCheck();
- }, 150);
- }
- this.updateInputfield();
- event.preventDefault();
- };
- Calendar.prototype.shouldSelectDate = function (dateMeta) {
- if (this.isMultipleSelection())
- return this.maxDateCount != null ? this.maxDateCount > (this.value ? this.value.length : 0) : true;
- else
- return true;
- };
- Calendar.prototype.onMonthSelect = function (event, index) {
- this.onDateSelect(event, { year: this.currentYear, month: index, day: 1, selectable: true });
- };
- Calendar.prototype.updateInputfield = function () {
- var formattedValue = '';
- if (this.value) {
- if (this.isSingleSelection()) {
- formattedValue = this.formatDateTime(this.value);
- }
- else if (this.isMultipleSelection()) {
- for (var i = 0; i < this.value.length; i++) {
- var dateAsString = this.formatDateTime(this.value[i]);
- formattedValue += dateAsString;
- if (i !== (this.value.length - 1)) {
- formattedValue += this.multipleSeparator + ' ';
- }
- }
- }
- else if (this.isRangeSelection()) {
- if (this.value && this.value.length) {
- var startDate = this.value[0];
- var endDate = this.value[1];
- formattedValue = this.formatDateTime(startDate);
- if (endDate) {
- formattedValue += ' ' + this.rangeSeparator + ' ' + this.formatDateTime(endDate);
- }
- }
- }
- }
- this.inputFieldValue = formattedValue;
- this.updateFilledState();
- if (this.inputfieldViewChild && this.inputfieldViewChild.nativeElement) {
- this.inputfieldViewChild.nativeElement.value = this.inputFieldValue;
- }
- };
- Calendar.prototype.formatDateTime = function (date) {
- var formattedValue = null;
- if (date) {
- if (this.timeOnly) {
- formattedValue = this.formatTime(date);
- }
- else {
- formattedValue = this.formatDate(date, this.getDateFormat());
- if (this.showTime) {
- formattedValue += ' ' + this.formatTime(date);
- }
- }
- }
- return formattedValue;
- };
- Calendar.prototype.selectDate = function (dateMeta) {
- var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
- if (this.showTime) {
- if (this.hourFormat == '12') {
- if (this.currentHour === 12)
- date.setHours(this.pm ? 12 : 0);
- else
- date.setHours(this.pm ? this.currentHour + 12 : this.currentHour);
- }
- else {
- date.setHours(this.currentHour);
- }
- date.setMinutes(this.currentMinute);
- date.setSeconds(this.currentSecond);
- }
- if (this.minDate && this.minDate > date) {
- date = this.minDate;
- this.currentHour = date.getHours();
- this.currentMinute = date.getMinutes();
- this.currentSecond = date.getSeconds();
- }
- if (this.maxDate && this.maxDate < date) {
- date = this.maxDate;
- this.currentHour = date.getHours();
- this.currentMinute = date.getMinutes();
- this.currentSecond = date.getSeconds();
- }
- if (this.isSingleSelection()) {
- this.updateModel(date);
- }
- else if (this.isMultipleSelection()) {
- this.updateModel(this.value ? this.value.concat([date]) : [date]);
- }
- else if (this.isRangeSelection()) {
- if (this.value && this.value.length) {
- var startDate = this.value[0];
- var endDate = this.value[1];
- if (!endDate && date.getTime() >= startDate.getTime()) {
- endDate = date;
- }
- else {
- startDate = date;
- endDate = null;
- }
- this.updateModel([startDate, endDate]);
- }
- else {
- this.updateModel([date, null]);
- }
- }
- this.onSelect.emit(date);
- };
- Calendar.prototype.updateModel = function (value) {
- var _this = this;
- this.value = value;
- if (this.dataType == 'date') {
- this.onModelChange(this.value);
- }
- else if (this.dataType == 'string') {
- if (this.isSingleSelection()) {
- this.onModelChange(this.formatDateTime(this.value));
- }
- else {
- var stringArrValue = null;
- if (this.value) {
- stringArrValue = this.value.map(function (date) { return _this.formatDateTime(date); });
- }
- this.onModelChange(stringArrValue);
- }
- }
- };
- Calendar.prototype.getFirstDayOfMonthIndex = function (month, year) {
- var day = new Date();
- day.setDate(1);
- day.setMonth(month);
- day.setFullYear(year);
- var dayIndex = day.getDay() + this.getSundayIndex();
- return dayIndex >= 7 ? dayIndex - 7 : dayIndex;
- };
- Calendar.prototype.getDaysCountInMonth = function (month, year) {
- return 32 - this.daylightSavingAdjust(new Date(year, month, 32)).getDate();
- };
- Calendar.prototype.getDaysCountInPrevMonth = function (month, year) {
- var prev = this.getPreviousMonthAndYear(month, year);
- return this.getDaysCountInMonth(prev.month, prev.year);
- };
- Calendar.prototype.getPreviousMonthAndYear = function (month, year) {
- var m, y;
- if (month === 0) {
- m = 11;
- y = year - 1;
- }
- else {
- m = month - 1;
- y = year;
- }
- return { 'month': m, 'year': y };
- };
- Calendar.prototype.getNextMonthAndYear = function (month, year) {
- var m, y;
- if (month === 11) {
- m = 0;
- y = year + 1;
- }
- else {
- m = month + 1;
- y = year;
- }
- return { 'month': m, 'year': y };
- };
- Calendar.prototype.getSundayIndex = function () {
- return this.locale.firstDayOfWeek > 0 ? 7 - this.locale.firstDayOfWeek : 0;
- };
- Calendar.prototype.isSelected = function (dateMeta) {
- if (this.value) {
- if (this.isSingleSelection()) {
- return this.isDateEquals(this.value, dateMeta);
- }
- else if (this.isMultipleSelection()) {
- var selected = false;
- for (var _i = 0, _a = this.value; _i < _a.length; _i++) {
- var date = _a[_i];
- selected = this.isDateEquals(date, dateMeta);
- if (selected) {
- break;
- }
- }
- return selected;
- }
- else if (this.isRangeSelection()) {
- if (this.value[1])
- return this.isDateEquals(this.value[0], dateMeta) || this.isDateEquals(this.value[1], dateMeta) || this.isDateBetween(this.value[0], this.value[1], dateMeta);
- else
- return this.isDateEquals(this.value[0], dateMeta);
- }
- }
- else {
- return false;
- }
- };
- Calendar.prototype.isMonthSelected = function (month) {
- var day = this.value ? (Array.isArray(this.value) ? this.value[0].getDate() : this.value.getDate()) : 1;
- return this.isSelected({ year: this.currentYear, month: month, day: day, selectable: true });
- };
- Calendar.prototype.isDateEquals = function (value, dateMeta) {
- if (value)
- return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;
- else
- return false;
- };
- Calendar.prototype.isDateBetween = function (start, end, dateMeta) {
- var between = false;
- if (start && end) {
- var date = new Date(dateMeta.year, dateMeta.month, dateMeta.day);
- return start.getTime() <= date.getTime() && end.getTime() >= date.getTime();
- }
- return between;
- };
- Calendar.prototype.isSingleSelection = function () {
- return this.selectionMode === 'single';
- };
- Calendar.prototype.isRangeSelection = function () {
- return this.selectionMode === 'range';
- };
- Calendar.prototype.isMultipleSelection = function () {
- return this.selectionMode === 'multiple';
- };
- Calendar.prototype.isToday = function (today, day, month, year) {
- return today.getDate() === day && today.getMonth() === month && today.getFullYear() === year;
- };
- Calendar.prototype.isSelectable = function (day, month, year, otherMonth) {
- var validMin = true;
- var validMax = true;
- var validDate = true;
- var validDay = true;
- if (otherMonth && !this.selectOtherMonths) {
- return false;
- }
- if (this.minDate) {
- if (this.minDate.getFullYear() > year) {
- validMin = false;
- }
- else if (this.minDate.getFullYear() === year) {
- if (this.minDate.getMonth() > month) {
- validMin = false;
- }
- else if (this.minDate.getMonth() === month) {
- if (this.minDate.getDate() > day) {
- validMin = false;
- }
- }
- }
- }
- if (this.maxDate) {
- if (this.maxDate.getFullYear() < year) {
- validMax = false;
- }
- else if (this.maxDate.getFullYear() === year) {
- if (this.maxDate.getMonth() < month) {
- validMax = false;
- }
- else if (this.maxDate.getMonth() === month) {
- if (this.maxDate.getDate() < day) {
- validMax = false;
- }
- }
- }
- }
- if (this.disabledDates) {
- validDate = !this.isDateDisabled(day, month, year);
- }
- if (this.disabledDays) {
- validDay = !this.isDayDisabled(day, month, year);
- }
- return validMin && validMax && validDate && validDay;
- };
- Calendar.prototype.isDateDisabled = function (day, month, year) {
- if (this.disabledDates) {
- for (var _i = 0, _a = this.disabledDates; _i < _a.length; _i++) {
- var disabledDate = _a[_i];
- if (disabledDate.getFullYear() === year && disabledDate.getMonth() === month && disabledDate.getDate() === day) {
- return true;
- }
- }
- }
- return false;
- };
- Calendar.prototype.isDayDisabled = function (day, month, year) {
- if (this.disabledDays) {
- var weekday = new Date(year, month, day);
- var weekdayNumber = weekday.getDay();
- return this.disabledDays.indexOf(weekdayNumber) !== -1;
- }
- return false;
- };
- Calendar.prototype.onInputFocus = function (event) {
- this.focus = true;
- if (this.showOnFocus) {
- this.showOverlay();
- }
- this.onFocus.emit(event);
- };
- Calendar.prototype.onInputClick = function (event) {
- if (this.overlay && this.autoZIndex) {
- this.overlay.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
- }
- if (this.showOnFocus && !this.overlayVisible) {
- this.showOverlay();
- }
- };
- Calendar.prototype.onInputBlur = function (event) {
- this.focus = false;
- this.onBlur.emit(event);
- if (!this.keepInvalid) {
- this.updateInputfield();
- }
- this.onModelTouched();
- };
- Calendar.prototype.onButtonClick = function (event, inputfield) {
- if (!this.overlayVisible) {
- inputfield.focus();
- this.showOverlay();
- }
- else {
- this.hideOverlay();
- }
- };
- Calendar.prototype.onInputKeydown = function (event) {
- this.isKeydown = true;
- if (event.keyCode === 9) {
- this.hideOverlay();
- }
- };
- Calendar.prototype.onMonthDropdownChange = function (m) {
- this.currentMonth = parseInt(m);
- this.onMonthChange.emit({ month: this.currentMonth + 1, year: this.currentYear });
- this.createMonths(this.currentMonth, this.currentYear);
- };
- Calendar.prototype.onYearDropdownChange = function (y) {
- this.currentYear = parseInt(y);
- this.onYearChange.emit({ month: this.currentMonth + 1, year: this.currentYear });
- this.createMonths(this.currentMonth, this.currentYear);
- };
- Calendar.prototype.incrementHour = function (event) {
- var prevHour = this.currentHour;
- var newHour = this.currentHour + this.stepHour;
- if (this.validateHour(newHour)) {
- if (this.hourFormat == '24')
- this.currentHour = (newHour >= 24) ? (newHour - 24) : newHour;
- else if (this.hourFormat == '12') {
- // Before the AM/PM break, now after
- if (prevHour < 12 && newHour > 11) {
- this.pm = !this.pm;
- }
- this.currentHour = (newHour >= 13) ? (newHour - 12) : newHour;
- }
- }
- event.preventDefault();
- };
- Calendar.prototype.onTimePickerElementMouseDown = function (event, type, direction) {
- if (!this.disabled) {
- this.repeat(event, null, type, direction);
- event.preventDefault();
- }
- };
- Calendar.prototype.onTimePickerElementMouseUp = function (event) {
- if (!this.disabled) {
- this.clearTimePickerTimer();
- this.updateTime();
- }
- };
- Calendar.prototype.repeat = function (event, interval, type, direction) {
- var _this = this;
- var i = interval || 500;
- this.clearTimePickerTimer();
- this.timePickerTimer = setTimeout(function () {
- _this.repeat(event, 100, type, direction);
- }, i);
- switch (type) {
- case 0:
- if (direction === 1)
- this.incrementHour(event);
- else
- this.decrementHour(event);
- break;
- case 1:
- if (direction === 1)
- this.incrementMinute(event);
- else
- this.decrementMinute(event);
- break;
- case 2:
- if (direction === 1)
- this.incrementSecond(event);
- else
- this.decrementSecond(event);
- break;
- }
- this.updateInputfield();
- };
- Calendar.prototype.clearTimePickerTimer = function () {
- if (this.timePickerTimer) {
- clearInterval(this.timePickerTimer);
- }
- };
- Calendar.prototype.decrementHour = function (event) {
- var newHour = this.currentHour - this.stepHour;
- if (this.validateHour(newHour)) {
- if (this.hourFormat == '24')
- this.currentHour = (newHour < 0) ? (24 + newHour) : newHour;
- else if (this.hourFormat == '12') {
- // If we were at noon/midnight, then switch
- if (this.currentHour === 12) {
- this.pm = !this.pm;
- }
- this.currentHour = (newHour <= 0) ? (12 + newHour) : newHour;
- }
- }
- event.preventDefault();
- };
- Calendar.prototype.validateHour = function (hour) {
- var valid = true;
- var value = this.value;
- if (this.isRangeSelection()) {
- value = this.value[1] || this.value[0];
- }
- if (this.isMultipleSelection()) {
- value = this.value[this.value.length - 1];
- }
- var valueDateString = value ? value.toDateString() : null;
- if (this.minDate && valueDateString && this.minDate.toDateString() === valueDateString) {
- if (this.minDate.getHours() > hour) {
- valid = false;
- }
- }
- if (this.maxDate && valueDateString && this.maxDate.toDateString() === valueDateString) {
- if (this.maxDate.getHours() < hour) {
- valid = false;
- }
- }
- return valid;
- };
- Calendar.prototype.incrementMinute = function (event) {
- var newMinute = this.currentMinute + this.stepMinute;
- if (this.validateMinute(newMinute)) {
- this.currentMinute = (newMinute > 59) ? newMinute - 60 : newMinute;
- }
- event.preventDefault();
- };
- Calendar.prototype.decrementMinute = function (event) {
- var newMinute = this.currentMinute - this.stepMinute;
- newMinute = (newMinute < 0) ? 60 + newMinute : newMinute;
- if (this.validateMinute(newMinute)) {
- this.currentMinute = newMinute;
- }
- event.preventDefault();
- };
- Calendar.prototype.validateMinute = function (minute) {
- var valid = true;
- var value = this.value;
- if (this.isRangeSelection()) {
- value = this.value[1] || this.value[0];
- }
- if (this.isMultipleSelection()) {
- value = this.value[this.value.length - 1];
- }
- var valueDateString = value ? value.toDateString() : null;
- if (this.minDate && valueDateString && this.minDate.toDateString() === valueDateString) {
- if (value.getHours() == this.minDate.getHours()) {
- if (this.minDate.getMinutes() > minute) {
- valid = false;
- }
- }
- }
- if (this.maxDate && valueDateString && this.maxDate.toDateString() === valueDateString) {
- if (value.getHours() == this.maxDate.getHours()) {
- if (this.maxDate.getMinutes() < minute) {
- valid = false;
- }
- }
- }
- return valid;
- };
- Calendar.prototype.incrementSecond = function (event) {
- var newSecond = this.currentSecond + this.stepSecond;
- if (this.validateSecond(newSecond)) {
- this.currentSecond = (newSecond > 59) ? newSecond - 60 : newSecond;
- }
- event.preventDefault();
- };
- Calendar.prototype.decrementSecond = function (event) {
- var newSecond = this.currentSecond - this.stepSecond;
- newSecond = (newSecond < 0) ? 60 + newSecond : newSecond;
- if (this.validateSecond(newSecond)) {
- this.currentSecond = newSecond;
- }
- event.preventDefault();
- };
- Calendar.prototype.validateSecond = function (second) {
- var valid = true;
- var value = this.value;
- if (this.isRangeSelection()) {
- value = this.value[1] || this.value[0];
- }
- if (this.isMultipleSelection()) {
- value = this.value[this.value.length - 1];
- }
- var valueDateString = value ? value.toDateString() : null;
- if (this.minDate && valueDateString && this.minDate.toDateString() === valueDateString) {
- if (this.minDate.getSeconds() > second) {
- valid = false;
- }
- }
- if (this.maxDate && valueDateString && this.maxDate.toDateString() === valueDateString) {
- if (this.maxDate.getSeconds() < second) {
- valid = false;
- }
- }
- return valid;
- };
- Calendar.prototype.updateTime = function () {
- var value = this.value;
- if (this.isRangeSelection()) {
- value = this.value[1] || this.value[0];
- }
- if (this.isMultipleSelection()) {
- value = this.value[this.value.length - 1];
- }
- value = value ? new Date(value.getTime()) : new Date();
- if (this.hourFormat == '12') {
- if (this.currentHour === 12)
- value.setHours(this.pm ? 12 : 0);
- else
- value.setHours(this.pm ? this.currentHour + 12 : this.currentHour);
- }
- else {
- value.setHours(this.currentHour);
- }
- value.setMinutes(this.currentMinute);
- value.setSeconds(this.currentSecond);
- if (this.isRangeSelection()) {
- if (this.value[1])
- value = [this.value[0], value];
- else
- value = [value, null];
- }
- if (this.isMultipleSelection()) {
- value = this.value.slice(0, -1).concat([value]);
- }
- this.updateModel(value);
- this.onSelect.emit(value);
- this.updateInputfield();
- };
- Calendar.prototype.toggleAMPM = function (event) {
- this.pm = !this.pm;
- this.updateTime();
- event.preventDefault();
- };
- Calendar.prototype.onUserInput = function (event) {
- // IE 11 Workaround for input placeholder : https://github.com/primefaces/primeng/issues/2026
- if (!this.isKeydown) {
- return;
- }
- this.isKeydown = false;
- var val = event.target.value;
- try {
- var value = this.parseValueFromString(val);
- if (this.isValidSelection(value)) {
- this.updateModel(value);
- this.updateUI();
- }
- }
- catch (err) {
- //invalid date
- this.updateModel(null);
- }
- this.filled = val != null && val.length;
- this.onInput.emit(event);
- };
- Calendar.prototype.isValidSelection = function (value) {
- var _this = this;
- var isValid = true;
- if (this.isSingleSelection()) {
- if (!this.isSelectable(value.getDate(), value.getMonth(), value.getFullYear(), false)) {
- isValid = false;
- }
- }
- else if (value.every(function (v) { return _this.isSelectable(v.getDate(), v.getMonth(), v.getFullYear(), false); })) {
- if (this.isRangeSelection()) {
- isValid = value.length > 1 && value[1] > value[0] ? true : false;
- }
- }
- return isValid;
- };
- Calendar.prototype.parseValueFromString = function (text) {
- if (!text || text.trim().length === 0) {
- return null;
- }
- var value;
- if (this.isSingleSelection()) {
- value = this.parseDateTime(text);
- }
- else if (this.isMultipleSelection()) {
- var tokens = text.split(this.multipleSeparator);
- value = [];
- for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
- var token = tokens_1[_i];
- value.push(this.parseDateTime(token.trim()));
- }
- }
- else if (this.isRangeSelection()) {
- var tokens = text.split(' ' + this.rangeSeparator + ' ');
- value = [];
- for (var i = 0; i < tokens.length; i++) {
- value[i] = this.parseDateTime(tokens[i].trim());
- }
- }
- return value;
- };
- Calendar.prototype.parseDateTime = function (text) {
- var date;
- var parts = text.split(' ');
- if (this.timeOnly) {
- date = new Date();
- this.populateTime(date, parts[0], parts[1]);
- }
- else {
- var dateFormat = this.getDateFormat();
- if (this.showTime) {
- var ampm = this.hourFormat == '12' ? parts.pop() : null;
- var timeString = parts.pop();
- date = this.parseDate(parts.join(' '), dateFormat);
- this.populateTime(date, timeString, ampm);
- }
- else {
- date = this.parseDate(text, dateFormat);
- }
- }
- return date;
- };
- Calendar.prototype.populateTime = function (value, timeString, ampm) {
- if (this.hourFormat == '12' && !ampm) {
- throw 'Invalid Time';
- }
- this.pm = (ampm === 'PM' || ampm === 'pm');
- var time = this.parseTime(timeString);
- value.setHours(time.hour);
- value.setMinutes(time.minute);
- value.setSeconds(time.second);
- };
- Calendar.prototype.updateUI = function () {
- var val = this.value || this.defaultDate || new Date();
- if (Array.isArray(val)) {
- val = val[0];
- }
- this.currentMonth = val.getMonth();
- this.currentYear = val.getFullYear();
- this.createMonths(this.currentMonth, this.currentYear);
- if (this.showTime || this.timeOnly) {
- var hours = val.getHours();
- if (this.hourFormat == '12') {
- this.pm = hours > 11;
- if (hours >= 12) {
- this.currentHour = (hours == 12) ? 12 : hours - 12;
- }
- else {
- this.currentHour = (hours == 0) ? 12 : hours;
- }
- }
- else {
- this.currentHour = val.getHours();
- }
- this.currentMinute = val.getMinutes();
- this.currentSecond = val.getSeconds();
- }
- };
- Calendar.prototype.showOverlay = function () {
- if (!this.overlayVisible) {
- this.updateUI();
- this.overlayVisible = true;
- }
- };
- Calendar.prototype.hideOverlay = function () {
- this.overlayVisible = false;
- if (this.touchUI) {
- this.disableModality();
- }
- };
- Calendar.prototype.toggle = function () {
- if (!this.inline) {
- if (!this.overlayVisible) {
- this.showOverlay();
- this.inputfieldViewChild.nativeElement.focus();
- }
- else {
- this.hideOverlay();
- }
- }
- };
- Calendar.prototype.onOverlayAnimationStart = function (event) {
- switch (event.toState) {
- case 'visible':
- case 'visibleTouchUI':
- if (!this.inline) {
- this.overlay = event.element;
- this.appendOverlay();
- if (this.autoZIndex) {
- this.overlay.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
- }
- this.alignOverlay();
- }
- break;
- case 'void':
- this.onOverlayHide();
- this.onClose.emit(event);
- break;
- }
- };
- Calendar.prototype.onOverlayAnimationDone = function (event) {
- switch (event.toState) {
- case 'visible':
- case 'visibleTouchUI':
- if (!this.inline) {
- this.bindDocumentClickListener();
- this.bindDocumentResizeListener();
- }
- break;
- }
- };
- Calendar.prototype.appendOverlay = function () {
- if (this.appendTo) {
- if (this.appendTo === 'body')
- document.body.appendChild(this.overlay);
- else
- domhandler_1.DomHandler.appendChild(this.overlay, this.appendTo);
- }
- };
- Calendar.prototype.restoreOverlayAppend = function () {
- if (this.overlay && this.appendTo) {
- this.el.nativeElement.appendChild(this.overlay);
- }
- };
- Calendar.prototype.alignOverlay = function () {
- if (this.touchUI) {
- this.enableModality(this.overlay);
- }
- else {
- if (this.appendTo)
- domhandler_1.DomHandler.absolutePosition(this.overlay, this.inputfieldViewChild.nativeElement);
- else
- domhandler_1.DomHandler.relativePosition(this.overlay, this.inputfieldViewChild.nativeElement);
- }
- };
- Calendar.prototype.enableModality = function (element) {
- var _this = this;
- if (!this.mask) {
- this.mask = document.createElement('div');
- this.mask.style.zIndex = String(parseInt(element.style.zIndex) - 1);
- var maskStyleClass = 'ui-widget-overlay ui-datepicker-mask ui-datepicker-mask-scrollblocker';
- domhandler_1.DomHandler.addMultipleClasses(this.mask, maskStyleClass);
- this.maskClickListener = this.renderer.listen(this.mask, 'click', function (event) {
- _this.disableModality();
- });
- document.body.appendChild(this.mask);
- domhandler_1.DomHandler.addClass(document.body, 'ui-overflow-hidden');
- }
- };
- Calendar.prototype.disableModality = function () {
- if (this.mask) {
- document.body.removeChild(this.mask);
- var bodyChildren = document.body.children;
- var hasBlockerMasks = void 0;
- for (var i = 0; i < bodyChildren.length; i++) {
- var bodyChild = bodyChildren[i];
- if (domhandler_1.DomHandler.hasClass(bodyChild, 'ui-datepicker-mask-scrollblocker')) {
- hasBlockerMasks = true;
- break;
- }
- }
- if (!hasBlockerMasks) {
- domhandler_1.DomHandler.removeClass(document.body, 'ui-overflow-hidden');
- }
- this.unbindMaskClickListener();
- this.mask = null;
- }
- };
- Calendar.prototype.unbindMaskClickListener = function () {
- if (this.maskClickListener) {
- this.maskClickListener();
- this.maskClickListener = null;
- }
- };
- Calendar.prototype.writeValue = function (value) {
- this.value = value;
- if (this.value && typeof this.value === 'string') {
- this.value = this.parseValueFromString(this.value);
- }
- this.updateInputfield();
- this.updateUI();
- };
- Calendar.prototype.registerOnChange = function (fn) {
- this.onModelChange = fn;
- };
- Calendar.prototype.registerOnTouched = function (fn) {
- this.onModelTouched = fn;
- };
- Calendar.prototype.setDisabledState = function (val) {
- this.disabled = val;
- };
- Calendar.prototype.getDateFormat = function () {
- return this.dateFormat || this.locale.dateFormat;
- };
- // Ported from jquery-ui datepicker formatDate
- Calendar.prototype.formatDate = function (date, format) {
- if (!date) {
- return '';
- }
- var iFormat;
- var lookAhead = function (match) {
- var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
- if (matches) {
- iFormat++;
- }
- return matches;
- }, formatNumber = function (match, value, len) {
- var num = '' + value;
- if (lookAhead(match)) {
- while (num.length < len) {
- num = '0' + num;
- }
- }
- return num;
- }, formatName = function (match, value, shortNames, longNames) {
- return (lookAhead(match) ? longNames[value] : shortNames[value]);
- };
- var output = '';
- var literal = false;
- if (date) {
- for (iFormat = 0; iFormat < format.length; iFormat++) {
- if (literal) {
- if (format.charAt(iFormat) === '\'' && !lookAhead('\'')) {
- literal = false;
- }
- else {
- output += format.charAt(iFormat);
- }
- }
- else {
- switch (format.charAt(iFormat)) {
- case 'd':
- output += formatNumber('d', date.getDate(), 2);
- break;
- case 'D':
- output += formatName('D', date.getDay(), this.locale.dayNamesShort, this.locale.dayNames);
- break;
- case 'o':
- output += formatNumber('o', Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() -
- new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
- break;
- case 'm':
- output += formatNumber('m', date.getMonth() + 1, 2);
- break;
- case 'M':
- output += formatName('M', date.getMonth(), this.locale.monthNamesShort, this.locale.monthNames);
- break;
- case 'y':
- output += lookAhead('y') ? date.getFullYear() : (date.getFullYear() % 100 < 10 ? '0' : '') + (date.getFullYear() % 100);
- break;
- case '@':
- output += date.getTime();
- break;
- case '!':
- output += date.getTime() * 10000 + this.ticksTo1970;
- break;
- case '\'':
- if (lookAhead('\'')) {
- output += '\'';
- }
- else {
- literal = true;
- }
- break;
- default:
- output += format.charAt(iFormat);
- }
- }
- }
- }
- return output;
- };
- Calendar.prototype.formatTime = function (date) {
- if (!date) {
- return '';
- }
- var output = '';
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var seconds = date.getSeconds();
- if (this.hourFormat == '12' && hours > 11 && hours != 12) {
- hours -= 12;
- }
- if (this.hourFormat == '12') {
- output += hours === 0 ? 12 : (hours < 10) ? '0' + hours : hours;
- }
- else {
- output += (hours < 10) ? '0' + hours : hours;
- }
- output += ':';
- output += (minutes < 10) ? '0' + minutes : minutes;
- if (this.showSeconds) {
- output += ':';
- output += (seconds < 10) ? '0' + seconds : seconds;
- }
- if (this.hourFormat == '12') {
- output += date.getHours() > 11 ? ' PM' : ' AM';
- }
- return output;
- };
- Calendar.prototype.parseTime = function (value) {
- var tokens = value.split(':');
- var validTokenLength = this.showSeconds ? 3 : 2;
- if (tokens.length !== validTokenLength) {
- throw "Invalid time";
- }
- var h = parseInt(tokens[0]);
- var m = parseInt(tokens[1]);
- var s = this.showSeconds ? parseInt(tokens[2]) : null;
- if (isNaN(h) || isNaN(m) || h > 23 || m > 59 || (this.hourFormat == '12' && h > 12) || (this.showSeconds && (isNaN(s) || s > 59))) {
- throw "Invalid time";
- }
- else {
- if (this.hourFormat == '12') {
- if (h !== 12 && this.pm) {
- h += 12;
- }
- else if (!this.pm && h === 12) {
- h -= 12;
- }
- }
- return { hour: h, minute: m, second: s };
- }
- };
- // Ported from jquery-ui datepicker parseDate
- Calendar.prototype.parseDate = function (value, format) {
- if (format == null || value == null) {
- throw "Invalid arguments";
- }
- value = (typeof value === "object" ? value.toString() : value + "");
- if (value === "") {
- return null;
- }
- var iFormat, dim, extra, iValue = 0, shortYearCutoff = (typeof this.shortYearCutoff !== "string" ? this.shortYearCutoff : new Date().getFullYear() % 100 + parseInt(this.shortYearCutoff, 10)), year = -1, month = -1, day = -1, doy = -1, literal = false, date, lookAhead = function (match) {
- var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
- if (matches) {
- iFormat++;
- }
- return matches;
- }, getNumber = function (match) {
- var isDoubled = lookAhead(match), size = (match === "@" ? 14 : (match === "!" ? 20 :
- (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))), minSize = (match === "y" ? size : 1), digits = new RegExp("^\\d{" + minSize + "," + size + "}"), num = value.substring(iValue).match(digits);
- if (!num) {
- throw "Missing number at position " + iValue;
- }
- iValue += num[0].length;
- return parseInt(num[0], 10);
- }, getName = function (match, shortNames, longNames) {
- var index = -1;
- var arr = lookAhead(match) ? longNames : shortNames;
- var names = [];
- for (var i = 0; i < arr.length; i++) {
- names.push([i, arr[i]]);
- }
- names.sort(function (a, b) {
- return -(a[1].length - b[1].length);
- });
- for (var i = 0; i < names.length; i++) {
- var name_1 = names[i][1];
- if (value.substr(iValue, name_1.length).toLowerCase() === name_1.toLowerCase()) {
- index = names[i][0];
- iValue += name_1.length;
- break;
- }
- }
- if (index !== -1) {
- return index + 1;
- }
- else {
- throw "Unknown name at position " + iValue;
- }
- }, checkLiteral = function () {
- if (value.charAt(iValue) !== format.charAt(iFormat)) {
- throw "Unexpected literal at position " + iValue;
- }
- iValue++;
- };
- if (this.view === 'month') {
- day = 1;
- }
- for (iFormat = 0; iFormat < format.length; iFormat++) {
- if (literal) {
- if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
- literal = false;
- }
- else {
- checkLiteral();
- }
- }
- else {
- switch (format.charAt(iFormat)) {
- case "d":
- day = getNumber("d");
- break;
- case "D":
- getName("D", this.locale.dayNamesShort, this.locale.dayNames);
- break;
- case "o":
- doy = getNumber("o");
- break;
- case "m":
- month = getNumber("m");
- break;
- case "M":
- month = getName("M", this.locale.monthNamesShort, this.locale.monthNames);
- break;
- case "y":
- year = getNumber("y");
- break;
- case "@":
- date = new Date(getNumber("@"));
- year = date.getFullYear();
- month = date.getMonth() + 1;
- day = date.getDate();
- break;
- case "!":
- date = new Date((getNumber("!") - this.ticksTo1970) / 10000);
- year = date.getFullYear();
- month = date.getMonth() + 1;
- day = date.getDate();
- break;
- case "'":
- if (lookAhead("'")) {
- checkLiteral();
- }
- else {
- literal = true;
- }
- break;
- default:
- checkLiteral();
- }
- }
- }
- if (iValue < value.length) {
- extra = value.substr(iValue);
- if (!/^\s+/.test(extra)) {
- throw "Extra/unparsed characters found in date: " + extra;
- }
- }
- if (year === -1) {
- year = new Date().getFullYear();
- }
- else if (year < 100) {
- year += new Date().getFullYear() - new Date().getFullYear() % 100 +
- (year <= shortYearCutoff ? 0 : -100);
- }
- if (doy > -1) {
- month = 1;
- day = doy;
- do {
- dim = this.getDaysCountInMonth(year, month - 1);
- if (day <= dim) {
- break;
- }
- month++;
- day -= dim;
- } while (true);
- }
- date = this.daylightSavingAdjust(new Date(year, month - 1, day));
- if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
- throw "Invalid date"; // E.g. 31/02/00
- }
- return date;
- };
- Calendar.prototype.daylightSavingAdjust = function (date) {
- if (!date) {
- return null;
- }
- date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
- return date;
- };
- Calendar.prototype.updateFilledState = function () {
- this.filled = this.inputFieldValue && this.inputFieldValue != '';
- };
- Calendar.prototype.onTodayButtonClick = function (event) {
- var date = new Date();
- var dateMeta = { day: date.getDate(), month: date.getMonth(), year: date.getFullYear(), otherMonth: date.getMonth() !== this.currentMonth || date.getFullYear() !== this.currentYear, today: true, selectable: true };
- this.onDateSelect(event, dateMeta);
- this.onTodayClick.emit(event);
- };
- Calendar.prototype.onClearButtonClick = function (event) {
- this.updateModel(null);
- this.updateInputfield();
- this.hideOverlay();
- this.onClearClick.emit(event);
- };
- Calendar.prototype.bindDocumentClickListener = function () {
- var _this = this;
- if (!this.documentClickListener) {
- this.zone.runOutsideAngular(function () {
- _this.documentClickListener = _this.renderer.listen('document', 'click', function (event) {
- if (_this.isOutsideClicked(event) && _this.overlayVisible) {
- _this.zone.run(function () {
- _this.hideOverlay();
- _this.cd.markForCheck();
- });
- }
- });
- });
- }
- };
- Calendar.prototype.unbindDocumentClickListener = function () {
- if (this.documentClickListener) {
- this.documentClickListener();
- this.documentClickListener = null;
- }
- };
- Calendar.prototype.bindDocumentResizeListener = function () {
- if (!this.documentResizeListener && !this.touchUI) {
- this.documentResizeListener = this.onWindowResize.bind(this);
- window.addEventListener('resize', this.documentResizeListener);
- }
- };
- Calendar.prototype.unbindDocumentResizeListener = function () {
- if (this.documentResizeListener) {
- window.removeEventListener('resize', this.documentResizeListener);
- this.documentResizeListener = null;
- }
- };
- Calendar.prototype.isOutsideClicked = function (event) {
- return !(this.el.nativeElement.isSameNode(event.target) || this.isNavIconClicked(event) ||
- this.el.nativeElement.contains(event.target) || (this.overlay && this.overlay.contains(event.target)));
- };
- Calendar.prototype.isNavIconClicked = function (event) {
- return (domhandler_1.DomHandler.hasClass(event.target, 'ui-datepicker-prev') || domhandler_1.DomHandler.hasClass(event.target, 'ui-datepicker-prev-icon')
- || domhandler_1.DomHandler.hasClass(event.target, 'ui-datepicker-next') || domhandler_1.DomHandler.hasClass(event.target, 'ui-datepicker-next-icon'));
- };
- Calendar.prototype.onWindowResize = function () {
- if (this.overlayVisible && !domhandler_1.DomHandler.isAndroid()) {
- this.hideOverlay();
- }
- };
- Calendar.prototype.onOverlayHide = function () {
- this.unbindDocumentClickListener();
- this.unbindMaskClickListener();
- this.unbindDocumentResizeListener();
- this.overlay = null;
- this.disableModality();
- };
- Calendar.prototype.ngOnDestroy = function () {
- this.restoreOverlayAppend();
- this.onOverlayHide();
- };
- __decorate([
- core_1.Input(),
- __metadata("design:type", Date)
- ], Calendar.prototype, "defaultDate", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "style", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "styleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "inputStyle", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "inputId", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "name", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "inputStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "placeholder", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "disabled", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "dateFormat", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "multipleSeparator", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "rangeSeparator", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "inline", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showOtherMonths", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "selectOtherMonths", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showIcon", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "icon", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "appendTo", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "readonlyInput", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "shortYearCutoff", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "monthNavigator", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "yearNavigator", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "hourFormat", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "timeOnly", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "stepHour", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "stepMinute", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "stepSecond", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showSeconds", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "required", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showOnFocus", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showWeek", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "dataType", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "selectionMode", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "maxDateCount", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "showButtonBar", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "todayButtonStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "clearButtonStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "autoZIndex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "baseZIndex", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "panelStyleClass", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object)
- ], Calendar.prototype, "panelStyle", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "keepInvalid", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "hideOnDateTimeSelect", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "numberOfMonths", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "view", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean)
- ], Calendar.prototype, "touchUI", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "timeSeparator", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "showTransitionOptions", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String)
- ], Calendar.prototype, "hideTransitionOptions", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onFocus", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onBlur", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onClose", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onSelect", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onInput", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onTodayClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onClearClick", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onMonthChange", void 0);
- __decorate([
- core_1.Output(),
- __metadata("design:type", core_1.EventEmitter)
- ], Calendar.prototype, "onYearChange", void 0);
- __decorate([
- core_1.ContentChildren(shared_1.PrimeTemplate),
- __metadata("design:type", core_1.QueryList)
- ], Calendar.prototype, "templates", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Number)
- ], Calendar.prototype, "tabindex", void 0);
- __decorate([
- core_1.ViewChild('inputfield', { static: false }),
- __metadata("design:type", core_1.ElementRef)
- ], Calendar.prototype, "inputfieldViewChild", void 0);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean),
- __metadata("design:paramtypes", [Boolean])
- ], Calendar.prototype, "utc", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Date),
- __metadata("design:paramtypes", [Date])
- ], Calendar.prototype, "minDate", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Date),
- __metadata("design:paramtypes", [Date])
- ], Calendar.prototype, "maxDate", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Array),
- __metadata("design:paramtypes", [Array])
- ], Calendar.prototype, "disabledDates", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Array),
- __metadata("design:paramtypes", [Array])
- ], Calendar.prototype, "disabledDays", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", String),
- __metadata("design:paramtypes", [String])
- ], Calendar.prototype, "yearRange", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Boolean),
- __metadata("design:paramtypes", [Boolean])
- ], Calendar.prototype, "showTime", null);
- __decorate([
- core_1.Input(),
- __metadata("design:type", Object),
- __metadata("design:paramtypes", [Object])
- ], Calendar.prototype, "locale", null);
- Calendar = __decorate([
- core_1.Component({
- selector: 'p-calendar',
- template: "\n <span [ngClass]=\"{'ui-calendar':true, 'ui-calendar-w-btn': showIcon, 'ui-calendar-timeonly': timeOnly}\" [ngStyle]=\"style\" [class]=\"styleClass\">\n <ng-template [ngIf]=\"!inline\">\n <input #inputfield type=\"text\" [attr.id]=\"inputId\" [attr.name]=\"name\" [attr.required]=\"required\" [value]=\"inputFieldValue\" (focus)=\"onInputFocus($event)\" (keydown)=\"onInputKeydown($event)\" (click)=\"onInputClick($event)\" (blur)=\"onInputBlur($event)\"\n [readonly]=\"readonlyInput\" (input)=\"onUserInput($event)\" [ngStyle]=\"inputStyle\" [class]=\"inputStyleClass\" [placeholder]=\"placeholder||''\" [disabled]=\"disabled\" [attr.tabindex]=\"tabindex\"\n [ngClass]=\"'ui-inputtext ui-widget ui-state-default ui-corner-all'\" autocomplete=\"off\"\n ><button type=\"button\" [icon]=\"icon\" pButton *ngIf=\"showIcon\" (click)=\"onButtonClick($event,inputfield)\" class=\"ui-datepicker-trigger ui-calendar-button\"\n [ngClass]=\"{'ui-state-disabled':disabled}\" [disabled]=\"disabled\" tabindex=\"-1\"></button>\n </ng-template>\n <div [class]=\"panelStyleClass\" [ngStyle]=\"panelStyle\" [ngClass]=\"{'ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all': true, 'ui-datepicker-inline':inline,'ui-shadow':!inline,\n 'ui-state-disabled':disabled,'ui-datepicker-timeonly':timeOnly,'ui-datepicker-multiple-month': this.numberOfMonths > 1, 'ui-datepicker-monthpicker': (view === 'month'), 'ui-datepicker-touch-ui': touchUI}\"\n [@overlayAnimation]=\"touchUI ? {value: 'visibleTouchUI', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}: \n {value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}\" \n [@.disabled]=\"inline === true\" (@overlayAnimation.start)=\"onOverlayAnimationStart($event)\" (@overlayAnimation.done)=\"onOverlayAnimationDone($event)\" *ngIf=\"inline || overlayVisible\">\n <ng-content select=\"p-header\"></ng-content>\n <ng-container *ngIf=\"!timeOnly\">\n <div class=\"ui-datepicker-group ui-widget-content\" *ngFor=\"let month of months; let i = index;\">\n <div class=\"ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all\">\n <a class=\"ui-datepicker-prev ui-corner-all\" (click)=\"navBackward($event)\" *ngIf=\"i === 0\">\n <span class=\"ui-datepicker-prev-icon pi pi-chevron-left\"></span>\n </a>\n <a class=\"ui-datepicker-next ui-corner-all\" (click)=\"navForward($event)\" *ngIf=\"numberOfMonths === 1 ? true : (i === numberOfMonths -1)\">\n <span class=\"ui-datepicker-next-icon pi pi-chevron-right\"></span>\n </a>\n <div class=\"ui-datepicker-title\">\n <span class=\"ui-datepicker-month\" *ngIf=\"!monthNavigator && (view !== 'month')\">{{locale.monthNames[month.month]}}</span>\n <select class=\"ui-datepicker-month\" *ngIf=\"monthNavigator && (view !== 'month') && numberOfMonths === 1\" (change)=\"onMonthDropdownChange($event.target.value)\">\n <option [value]=\"i\" *ngFor=\"let monthName of locale.monthNames;let i = index\" [selected]=\"i === month.month\">{{monthName}}</option>\n </select>\n <select class=\"ui-datepicker-year\" *ngIf=\"yearNavigator && numberOfMonths === 1\" (change)=\"onYearDropdownChange($event.target.value)\">\n <option [value]=\"year\" *ngFor=\"let year of yearOptions\" [selected]=\"year === currentYear\">{{year}}</option>\n </select>\n <span class=\"ui-datepicker-year\" *ngIf=\"!yearNavigator\">{{view === 'month' ? currentYear : month.year}}</span>\n </div>\n </div>\n <div class=\"ui-datepicker-calendar-container\" *ngIf=\"view ==='date'\">\n <table class=\"ui-datepicker-calendar\">\n <thead>\n <tr>\n <th *ngIf=\"showWeek\" class=\"ui-datepicker-weekheader\">\n <span>{{locale['weekHeader']}}</span>\n </th>\n <th scope=\"col\" *ngFor=\"let weekDay of weekDays;let begin = first; let end = last\">\n <span>{{weekDay}}</span>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let week of month.dates; let i = index;\">\n <td *ngIf=\"showWeek\" class=\"ui-datepicker-weeknumber ui-state-disabled\">\n <span>\n {{month.weekNumbers[i]}}\n </span>\n </td>\n <td *ngFor=\"let date of week\" [ngClass]=\"{'ui-datepicker-other-month': date.otherMonth,\n 'ui-datepicker-current-day':isSelected(date),'ui-datepicker-today':date.today}\">\n <ng-container *ngIf=\"date.otherMonth ? showOtherMonths : true\">\n <a class=\"ui-state-default\" *ngIf=\"date.selectable\" [ngClass]=\"{'ui-state-active':isSelected(date), 'ui-state-highlight':date.today}\"\n (click)=\"onDateSelect($event,date)\" draggable=\"false\">\n <ng-container *ngIf=\"!dateTemplate\">{{date.day}}</ng-container>\n <ng-container *ngTemplateOutlet=\"dateTemplate; context: {$implicit: date}\"></ng-container>\n </a>\n <span class=\"ui-state-default ui-state-disabled\" [ngClass]=\"{'ui-state-active':isSelected(date), 'ui-state-highlight':date.today}\" *ngIf=\"!date.selectable\">\n {{date.day}}\n </span>\n </ng-container>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n <div class=\"ui-monthpicker\" *ngIf=\"view === 'month'\">\n <a tabindex=\"0\" *ngFor=\"let m of monthPickerValues; let i = index\" (click)=\"onMonthSelect($event, i)\" class=\"ui-monthpicker-month\" [ngClass]=\"{'ui-state-active': isMonthSelected(i)}\">\n {{m}}\n </a>\n </div>\n </ng-container>\n <div class=\"ui-timepicker ui-widget-header ui-corner-all\" *ngIf=\"showTime||timeOnly\">\n <div class=\"ui-hour-picker\">\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 0, 1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span [ngStyle]=\"{'display': currentHour < 10 ? 'inline': 'none'}\">0</span><span>{{currentHour}}</span>\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 0, -1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n <div class=\"ui-separator\">\n <a tabindex=\"0\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span>{{timeSeparator}}</span>\n <a tabindex=\"0\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n <div class=\"ui-minute-picker\">\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 1, 1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span [ngStyle]=\"{'display': currentMinute < 10 ? 'inline': 'none'}\">0</span><span>{{currentMinute}}</span>\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 1, -1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n <div class=\"ui-separator\" *ngIf=\"showSeconds\">\n <a tabindex=\"0\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span>{{timeSeparator}}</span>\n <a tabindex=\"0\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n <div class=\"ui-second-picker\" *ngIf=\"showSeconds\">\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 2, 1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span [ngStyle]=\"{'display': currentSecond < 10 ? 'inline': 'none'}\">0</span><span>{{currentSecond}}</span>\n <a tabindex=\"0\" (mousedown)=\"onTimePickerElementMouseDown($event, 2, -1)\" (mouseup)=\"onTimePickerElementMouseUp($event)\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n <div class=\"ui-ampm-picker\" *ngIf=\"hourFormat=='12'\">\n <a tabindex=\"0\" (click)=\"toggleAMPM($event)\">\n <span class=\"pi pi-chevron-up\"></span>\n </a>\n <span>{{pm ? 'PM' : 'AM'}}</span>\n <a tabindex=\"0\" (click)=\"toggleAMPM($event)\">\n <span class=\"pi pi-chevron-down\"></span>\n </a>\n </div>\n </div>\n <div class=\"ui-datepicker-buttonbar ui-widget-header\" *ngIf=\"showButtonBar\">\n <div class=\"ui-g\">\n <div class=\"ui-g-6\">\n <button type=\"button\" [label]=\"_locale.today\" (click)=\"onTodayButtonClick($event)\" pButton [ngClass]=\"[todayButtonStyleClass]\"></button>\n </div>\n <div class=\"ui-g-6\">\n <button type=\"button\" [label]=\"_locale.clear\" (click)=\"onClearButtonClick($event)\" pButton [ngClass]=\"[clearButtonStyleClass]\"></button>\n </div>\n </div>\n </div>\n <ng-content select=\"p-footer\"></ng-content>\n </div>\n </span>\n ",
- animations: [
- animations_1.trigger('overlayAnimation', [
- animations_1.state('visible', animations_1.style({
- transform: 'translateY(0)',
- opacity: 1
- })),
- animations_1.state('visibleTouchUI', animations_1.style({
- transform: 'translate(-50%,-50%)',
- opacity: 1
- })),
- animations_1.transition('void => visible', [
- animations_1.style({ transform: 'translateY(5%)', opacity: 0 }),
- animations_1.animate('{{showTransitionParams}}')
- ]),
- animations_1.transition('visible => void', [
- animations_1.animate(('{{hideTransitionParams}}'), animations_1.style({
- opacity: 0,
- transform: 'translateY(5%)'
- }))
- ]),
- animations_1.transition('void => visibleTouchUI', [
- animations_1.style({ opacity: 0, transform: 'translate3d(-50%, -40%, 0) scale(0.9)' }),
- animations_1.animate('{{showTransitionParams}}')
- ]),
- animations_1.transition('visibleTouchUI => void', [
- animations_1.animate(('{{hideTransitionParams}}'), animations_1.style({
- opacity: 0,
- transform: 'translate3d(-50%, -40%, 0) scale(0.9)'
- }))
- ])
- ])
- ],
- host: {
- '[class.ui-inputwrapper-filled]': 'filled',
- '[class.ui-inputwrapper-focus]': 'focus'
- },
- providers: [exports.CALENDAR_VALUE_ACCESSOR]
- }),
- __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, core_1.ChangeDetectorRef, core_1.NgZone])
- ], Calendar);
- return Calendar;
- }());
- exports.Calendar = Calendar;
- var CalendarModule = /** @class */ (function () {
- function CalendarModule() {
- }
- CalendarModule = __decorate([
- core_1.NgModule({
- imports: [common_1.CommonModule, button_1.ButtonModule, shared_1.SharedModule],
- exports: [Calendar, button_1.ButtonModule, shared_1.SharedModule],
- declarations: [Calendar]
- })
- ], CalendarModule);
- return CalendarModule;
- }());
- exports.CalendarModule = CalendarModule;
- //# sourceMappingURL=calendar.js.map
|