mod/date/vendor/tempusdominus/docs/js/tempusdominus-bootstrap-4.js in card-1.98.0 vs mod/date/vendor/tempusdominus/docs/js/tempusdominus-bootstrap-4.js in card-1.98.1
- old
+ new
@@ -1,7 +1,7 @@
/*@preserve
- * Tempus Dominus Bootstrap4 v5.0.0-alpha18 (https://tempusdominus.github.io/bootstrap-4/)
+ * Tempus Dominus Bootstrap4 v5.1.2 (https://tempusdominus.github.io/bootstrap-4/)
* Copyright 2016-2018 Jonathan Peterson
* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
*/
if (typeof jQuery === 'undefined') {
@@ -36,17 +36,15 @@
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// ReSharper disable once InconsistentNaming
-var DateTimePicker = function ($) {
+var DateTimePicker = function ($, moment) {
// ReSharper disable InconsistentNaming
var NAME = 'datetimepicker',
- VERSION = '5.0.0-alpha7',
DATA_KEY = '' + NAME,
EVENT_KEY = '.' + DATA_KEY,
- EMIT_EVENT_KEY = DATA_KEY + '.',
DATA_API_KEY = '.data-api',
Selector = {
DATA_TOGGLE: '[data-toggle="' + DATA_KEY + '"]'
},
ClassName = {
@@ -58,26 +56,77 @@
KEYUP: 'keyup' + EVENT_KEY,
KEYDOWN: 'keydown' + EVENT_KEY,
FOCUS: 'focus' + EVENT_KEY,
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
//emitted
- UPDATE: EMIT_EVENT_KEY + 'update',
- ERROR: EMIT_EVENT_KEY + 'error',
- HIDE: EMIT_EVENT_KEY + 'hide',
- SHOW: EMIT_EVENT_KEY + 'show'
+ UPDATE: 'update' + EVENT_KEY,
+ ERROR: 'error' + EVENT_KEY,
+ HIDE: 'hide' + EVENT_KEY,
+ SHOW: 'show' + EVENT_KEY
},
- Default = {
+ DatePickerModes = [{
+ CLASS_NAME: 'days',
+ NAV_FUNCTION: 'M',
+ NAV_STEP: 1
+ }, {
+ CLASS_NAME: 'months',
+ NAV_FUNCTION: 'y',
+ NAV_STEP: 1
+ }, {
+ CLASS_NAME: 'years',
+ NAV_FUNCTION: 'y',
+ NAV_STEP: 10
+ }, {
+ CLASS_NAME: 'decades',
+ NAV_FUNCTION: 'y',
+ NAV_STEP: 100
+ }],
+ KeyMap = {
+ 'up': 38,
+ 38: 'up',
+ 'down': 40,
+ 40: 'down',
+ 'left': 37,
+ 37: 'left',
+ 'right': 39,
+ 39: 'right',
+ 'tab': 9,
+ 9: 'tab',
+ 'escape': 27,
+ 27: 'escape',
+ 'enter': 13,
+ 13: 'enter',
+ 'pageUp': 33,
+ 33: 'pageUp',
+ 'pageDown': 34,
+ 34: 'pageDown',
+ 'shift': 16,
+ 16: 'shift',
+ 'control': 17,
+ 17: 'control',
+ 'space': 32,
+ 32: 'space',
+ 't': 84,
+ 84: 't',
+ 'delete': 46,
+ 46: 'delete'
+ },
+ ViewModes = ['times', 'days', 'months', 'years', 'decades'],
+ keyState = {},
+ keyPressHandled = {};
+
+ var Default = {
timeZone: '',
format: false,
dayViewHeaderFormat: 'MMMM YYYY',
extraFormats: false,
stepping: 1,
minDate: false,
maxDate: false,
useCurrent: true,
collapse: true,
- locale: window.moment.locale(),
+ locale: moment.locale(),
defaultDate: false,
disabledDates: false,
enabledDates: false,
icons: {
time: 'fa fa-clock-o',
@@ -228,10 +277,13 @@
this.date(d.clone().add(1, 'M'));
}
return true;
},
enter: function enter() {
+ if (!this.widget) {
+ return false;
+ }
this.hide();
return true;
},
escape: function escape() {
if (!this.widget) {
@@ -248,10 +300,13 @@
this.widget.find('.btn[data-action="togglePeriod"]').click();
}
return true;
},
t: function t() {
+ if (!this.widget) {
+ return false;
+ }
this.date(this.getMoment());
return true;
},
'delete': function _delete() {
if (!this.widget) {
@@ -267,63 +322,12 @@
disabledHours: false,
enabledHours: false,
viewDate: false,
allowMultidate: false,
multidateSeparator: ','
- },
- DatePickerModes = [{
- CLASS_NAME: 'days',
- NAV_FUNCTION: 'M',
- NAV_STEP: 1
- }, {
- CLASS_NAME: 'months',
- NAV_FUNCTION: 'y',
- NAV_STEP: 1
- }, {
- CLASS_NAME: 'years',
- NAV_FUNCTION: 'y',
- NAV_STEP: 10
- }, {
- CLASS_NAME: 'decades',
- NAV_FUNCTION: 'y',
- NAV_STEP: 100
- }],
- KeyMap = {
- 'up': 38,
- 38: 'up',
- 'down': 40,
- 40: 'down',
- 'left': 37,
- 37: 'left',
- 'right': 39,
- 39: 'right',
- 'tab': 9,
- 9: 'tab',
- 'escape': 27,
- 27: 'escape',
- 'enter': 13,
- 13: 'enter',
- 'pageUp': 33,
- 33: 'pageUp',
- 'pageDown': 34,
- 34: 'pageDown',
- 'shift': 16,
- 16: 'shift',
- 'control': 17,
- 17: 'control',
- 'space': 32,
- 32: 'space',
- 't': 84,
- 84: 't',
- 'delete': 46,
- 46: 'delete'
- },
- ViewModes = ['times', 'days', 'months', 'years', 'decades'],
- keyState = {},
- keyPressHandled = {};
+ };
- var MinViewModeNumber = 0;
// ReSharper restore InconsistentNaming
// ReSharper disable once DeclarationHides
// ReSharper disable once InconsistentNaming
@@ -344,10 +348,11 @@
this.widget = false;
this.use24Hours = null;
this.actualFormat = null;
this.parseFormats = null;
this.currentViewMode = null;
+ this.MinViewModeNumber = 0;
this._int();
}
/**
@@ -378,13 +383,13 @@
this.options(this._options);
this._initFormatting();
if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) {
- this._setValue(this._parseInputDate(this.input.val().trim()));
+ this._setValue(this._parseInputDate(this.input.val().trim()), 0);
} else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) {
- this._setValue(this._options.defaultDate);
+ this._setValue(this._options.defaultDate, 0);
}
if (this._options.inline) {
this.show();
}
};
@@ -497,11 +502,11 @@
options = $.extend(true, {}, Default, options);
return options;
};
DateTimePicker.prototype._hasTimeZone = function _hasTimeZone() {
- return window.moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== '';
+ return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== '';
};
DateTimePicker.prototype._isEnabled = function _isEnabled(granularity) {
if (typeof granularity !== 'string' || granularity.length > 1) {
throw new TypeError('isEnabled expects a single character string parameter');
@@ -518,10 +523,13 @@
return this.actualFormat.toLowerCase().indexOf('h') !== -1;
case 'm':
return this.actualFormat.indexOf('m') !== -1;
case 's':
return this.actualFormat.indexOf('s') !== -1;
+ case 'a':
+ case 'A':
+ return this.actualFormat.toLowerCase().indexOf('a') !== -1;
default:
return false;
}
};
@@ -573,11 +581,11 @@
DateTimePicker.prototype._showMode = function _showMode(dir) {
if (!this.widget) {
return;
}
if (dir) {
- this.currentViewMode = Math.max(MinViewModeNumber, Math.min(3, this.currentViewMode + dir));
+ this.currentViewMode = Math.max(this.MinViewModeNumber, Math.min(3, this.currentViewMode + dir));
}
this.widget.find('.datepicker > div').hide().filter('.datepicker-' + DatePickerModes[this.currentViewMode].CLASS_NAME).show();
};
DateTimePicker.prototype._isInDisabledDates = function _isInDisabledDates(testDate) {
@@ -636,11 +644,11 @@
return true;
};
DateTimePicker.prototype._parseInputDate = function _parseInputDate(inputDate) {
if (this._options.parseInputDate === undefined) {
- if (!window.moment.isMoment(inputDate)) {
+ if (!moment.isMoment(inputDate)) {
inputDate = this.getMoment(inputDate);
}
} else {
inputDate = this._options.parseInputDate(inputDate);
}
@@ -688,11 +696,11 @@
}
}
}
if (handler) {
- if (handler.call(this.widget)) {
+ if (handler.call(this)) {
e.stopPropagation();
e.preventDefault();
}
}
};
@@ -749,20 +757,20 @@
}
this.use24Hours = this.actualFormat.toLowerCase().indexOf('a') < 1 && this.actualFormat.replace(/\[.*?]/g, '').indexOf('h') < 1;
if (this._isEnabled('y')) {
- MinViewModeNumber = 2;
+ this.MinViewModeNumber = 2;
}
if (this._isEnabled('M')) {
- MinViewModeNumber = 1;
+ this.MinViewModeNumber = 1;
}
if (this._isEnabled('d')) {
- MinViewModeNumber = 0;
+ this.MinViewModeNumber = 0;
}
- this.currentViewMode = Math.max(MinViewModeNumber, this.currentViewMode);
+ this.currentViewMode = Math.max(this.MinViewModeNumber, this.currentViewMode);
if (!this.unset) {
this._setValue(this._dates[0], 0);
}
};
@@ -780,17 +788,17 @@
DateTimePicker.prototype.getMoment = function getMoment(d) {
var returnMoment = void 0;
if (d === undefined || d === null) {
- returnMoment = window.moment(); //TODO should this use format? and locale?
+ returnMoment = moment(); //TODO should this use format? and locale?
} else if (this._hasTimeZone()) {
// There is a string to parse and a default time zone
// parse with the tz function which takes a default time zone if it is not in the format string
- returnMoment = window.moment.tz(d, this.parseFormats, this._options.useStrict, this._options.timeZone);
+ returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone);
} else {
- returnMoment = window.moment(d, this.parseFormats, this._options.useStrict);
+ returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict);
}
if (this._hasTimeZone()) {
returnMoment.tz(this._options.timeZone);
}
@@ -840,21 +848,18 @@
} else {
return this._dates[index].clone();
}
}
- if (newDate !== null && typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) {
+ if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
}
this._setValue(newDate === null ? null : this._parseInputDate(newDate), index);
};
DateTimePicker.prototype.format = function format(newFormat) {
- ///<summary>test su</summary>
- ///<param name="newFormat">info about para</param>
- ///<returns type="string|boolean">returns foo</returns>
if (arguments.length === 0) {
return this._options.format;
}
if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
@@ -1091,14 +1096,16 @@
DateTimePicker.prototype.locale = function locale(_locale) {
if (arguments.length === 0) {
return this._options.locale;
}
- if (!window.moment.localeData(_locale)) {
+ if (!moment.localeData(_locale)) {
throw new TypeError('locale() locale ' + _locale + ' is not loaded from moment locales!');
}
+ this._options.locale = _locale;
+
for (var i = 0; i < this._dates.length; i++) {
this._dates[i].locale(this._options.locale);
}
this._viewDate.locale(this._options.locale);
@@ -1226,11 +1233,11 @@
if (DateTimePicker.ViewModes.indexOf(_viewMode) === -1) {
throw new TypeError('viewMode() parameter must be one of (' + DateTimePicker.ViewModes.join(', ') + ') value');
}
this._options.viewMode = _viewMode;
- this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, DateTimePicker.MinViewModeNumber);
+ this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, this.MinViewModeNumber);
this._showMode();
};
DateTimePicker.prototype.calendarWeeks = function calendarWeeks(_calendarWeeks) {
@@ -1463,11 +1470,11 @@
if (!newDate) {
this._viewDate = (this._dates[0] || this.getMoment()).clone();
return true;
}
- if (typeof newDate !== 'string' && !window.moment.isMoment(newDate) && !(newDate instanceof Date)) {
+ if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
}
this._viewDate = this._parseInputDate(newDate);
this._viewUpdate();
@@ -1502,20 +1509,10 @@
/**
* @return {string}
*/
}, {
- key: 'VERSION',
- get: function get() {
- return VERSION;
- }
-
- /**
- * @return {string}
- */
-
- }, {
key: 'DATA_KEY',
get: function get() {
return DATA_KEY;
}
@@ -1546,21 +1543,11 @@
}, {
key: 'ViewModes',
get: function get() {
return ViewModes;
}
-
- /**
- * @return {number}
- */
-
}, {
- key: 'MinViewModeNumber',
- get: function get() {
- return MinViewModeNumber;
- }
- }, {
key: 'Event',
get: function get() {
return Event;
}
}, {
@@ -1570,10 +1557,13 @@
}
}, {
key: 'Default',
get: function get() {
return Default;
+ },
+ set: function set(value) {
+ Default = value;
}
}, {
key: 'ClassName',
get: function get() {
return ClassName;
@@ -1582,11 +1572,11 @@
return DateTimePicker;
}();
return DateTimePicker;
-}(jQuery);
+}(jQuery, moment);
//noinspection JSUnusedGlobalSymbols
/* global DateTimePicker */
var TempusDominusBootstrap4 = function ($) {
// eslint-disable-line no-unused-vars
@@ -1752,16 +1742,25 @@
'data-action': 'today',
'title': this._options.tooltips.today
}).append($('<span>').addClass(this._options.icons.today))));
}
if (!this._options.sideBySide && this._hasDate() && this._hasTime()) {
+ var title = void 0,
+ icon = void 0;
+ if (this._options.viewMode === 'times') {
+ title = this._options.tooltips.selectDate;
+ icon = this._options.icons.date;
+ } else {
+ title = this._options.tooltips.selectTime;
+ icon = this._options.icons.time;
+ }
row.push($('<td>').append($('<a>').attr({
href: '#',
tabindex: '-1',
'data-action': 'togglePicker',
- 'title': this._options.tooltips.selectTime
- }).append($('<span>').addClass(this._options.icons.time))));
+ 'title': title
+ }).append($('<span>').addClass(icon))));
}
if (this._options.buttons.showClear) {
row.push($('<td>').append($('<a>').attr({
href: '#',
tabindex: '-1',
@@ -1812,17 +1811,17 @@
if (this._options.toolbarPlacement === 'top') {
content.append(toolbar);
}
if (this._hasDate()) {
- content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'time' ? '' : 'show').append(dateView));
+ content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'times' ? '' : 'show').append(dateView));
}
if (this._options.toolbarPlacement === 'default') {
content.append(toolbar);
}
if (this._hasTime()) {
- content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'time' ? 'show' : '').append(timeView));
+ content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'times' ? 'show' : '').append(timeView));
}
if (this._options.toolbarPlacement === 'bottom') {
content.append(toolbar);
}
return template.append(content);
@@ -1986,16 +1985,16 @@
if (this._options.maxDate && this._options.maxDate.isBefore(endYear, 'y')) {
yearsViewHeader.eq(2).addClass('disabled');
}
- html += '<span data-action="selectYear" class="year old">' + (startYear.year() - 1) + '</span>';
+ html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + (startYear.year() - 1) + '</span>';
while (!startYear.isAfter(endYear, 'y')) {
html += '<span data-action="selectYear" class="year' + (startYear.isSame(this._getLastPickedDate(), 'y') && !this.unset ? ' active' : '') + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
startYear.add(1, 'y');
}
- html += '<span data-action="selectYear" class="year old">' + startYear.year() + '</span>';
+ html += '<span data-action="selectYear" class="year old' + (!this._isValid(startYear, 'y') ? ' disabled' : '') + '">' + startYear.year() + '</span>';
yearsView.find('td').html(html);
};
TempusDominusBootstrap4.prototype._updateDecades = function _updateDecades() {
@@ -2231,11 +2230,11 @@
break;
case 'selectMonth':
{
var month = $(e.target).closest('tbody').find('span').index($(e.target));
this._viewDate.month(month);
- if (this.currentViewMode === DateTimePicker.MinViewModeNumber) {
+ if (this.currentViewMode === this.MinViewModeNumber) {
this._setValue(lastPicked.clone().year(this._viewDate.year()).month(this._viewDate.month()), this._getLastPickedDateIndex());
if (!this._options.inline) {
this.hide();
}
} else {
@@ -2247,11 +2246,11 @@
}
case 'selectYear':
{
var year = parseInt($(e.target).text(), 10) || 0;
this._viewDate.year(year);
- if (this.currentViewMode === DateTimePicker.MinViewModeNumber) {
+ if (this.currentViewMode === this.MinViewModeNumber) {
this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
if (!this._options.inline) {
this.hide();
}
} else {
@@ -2263,11 +2262,11 @@
}
case 'selectDecade':
{
var _year = parseInt($(e.target).data('selection'), 10) || 0;
this._viewDate.year(_year);
- if (this.currentViewMode === DateTimePicker.MinViewModeNumber) {
+ if (this.currentViewMode === this.MinViewModeNumber) {
this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
if (!this._options.inline) {
this.hide();
}
} else {
@@ -2284,12 +2283,25 @@
day.subtract(1, 'M');
}
if ($(e.target).is('.new')) {
day.add(1, 'M');
}
- this._setValue(day.date(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());
- if (!this._hasTime() && !this._options.keepOpen && !this._options.inline) {
+
+ var selectDate = day.date(parseInt($(e.target).text(), 10)),
+ index = 0;
+ if (this._options.allowMultidate) {
+ index = this._datesFormatted.indexOf(selectDate.format('YYYY-MM-DD'));
+ if (index !== -1) {
+ this._setValue(null, index); //deselect multidate
+ } else {
+ this._setValue(selectDate, this._getLastPickedDateIndex() + 1);
+ }
+ } else {
+ this._setValue(selectDate, this._getLastPickedDateIndex());
+ }
+
+ if (!this._hasTime() && !this._options.keepOpen && !this._options.inline && !this._options.allowMultidate) {
this.hide();
}
break;
}
case 'incrementHours':
@@ -2749,10 +2761,10 @@
return;
}
if (!config._options.allowInputToggle) {
return;
}
- TempusDominusBootstrap4._jQueryInterface.call($target, config, event);
+ TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event);
});
$.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface;
$.fn[DateTimePicker.NAME].Constructor = TempusDominusBootstrap4;
$.fn[DateTimePicker.NAME].noConflict = function () {