Skip to content

Commit

Permalink
release 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Eonasdan committed Jun 5, 2018
1 parent ac1dd49 commit 106740a
Show file tree
Hide file tree
Showing 26 changed files with 11,673 additions and 4,804 deletions.
2 changes: 1 addition & 1 deletion build/css/tempusdominus-bootstrap-4.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*@preserve
* Tempus Dominus Bootstrap4 v5.0.0-alpha18 (https://tempusdominus.github.io/bootstrap-4/)
* Tempus Dominus Bootstrap4 v5.0.0 (https://tempusdominus.github.io/bootstrap-4/)
* Copyright 2016-2018 Jonathan Peterson
* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
*/
Expand Down
2 changes: 1 addition & 1 deletion build/css/tempusdominus-bootstrap-4.min.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*@preserve
* Tempus Dominus Bootstrap4 v5.0.0-alpha18 (https://tempusdominus.github.io/bootstrap-4/)
* Tempus Dominus Bootstrap4 v5.0.0 (https://tempusdominus.github.io/bootstrap-4/)
* Copyright 2016-2018 Jonathan Peterson
* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
*/
Expand Down
180 changes: 90 additions & 90 deletions build/js/tempusdominus-bootstrap-4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*@preserve
* Tempus Dominus Bootstrap4 v5.0.0-alpha18 (https://tempusdominus.github.io/bootstrap-4/)
* Tempus Dominus Bootstrap4 v5.0.0 (https://tempusdominus.github.io/bootstrap-4/)
* Copyright 2016-2018 Jonathan Peterson
* Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
*/
Expand Down Expand Up @@ -38,13 +38,11 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
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 + '"]'
Expand All @@ -60,11 +58,63 @@ var DateTimePicker = function ($) {
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
},
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,
Default = {
timeZone: '',
format: false,
Expand All @@ -75,7 +125,7 @@ var DateTimePicker = function ($) {
maxDate: false,
useCurrent: true,
collapse: true,
locale: window.moment.locale(),
locale: moment.locale(),
defaultDate: false,
disabledDates: false,
enabledDates: false,
Expand Down Expand Up @@ -230,6 +280,9 @@ var DateTimePicker = function ($) {
return true;
},
enter: function enter() {
if (!this.widget) {
return false;
}
this.hide();
return true;
},
Expand All @@ -250,6 +303,9 @@ var DateTimePicker = function ($) {
return true;
},
t: function t() {
if (!this.widget) {
return false;
}
this.date(this.getMoment());
return true;
},
Expand All @@ -269,59 +325,8 @@ var DateTimePicker = function ($) {
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
Expand Down Expand Up @@ -380,9 +385,9 @@ var DateTimePicker = function ($) {
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();
Expand Down Expand Up @@ -499,7 +504,7 @@ var DateTimePicker = function ($) {
};

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) {
Expand All @@ -520,6 +525,9 @@ var DateTimePicker = function ($) {
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;
}
Expand Down Expand Up @@ -553,7 +561,7 @@ var DateTimePicker = function ($) {
};

DateTimePicker.prototype._notifyEvent = function _notifyEvent(e) {
if (e.type === DateTimePicker.Event.CHANGE && ((e.date && e.date.isSame(e.oldDate)) || (!e.date && !e.oldDate))) {
if (e.type === DateTimePicker.Event.CHANGE && e.date && e.date.isSame(e.oldDate) || !e.date && !e.oldDate) {
return;
}
this._element.trigger(e);
Expand Down Expand Up @@ -638,7 +646,7 @@ var DateTimePicker = function ($) {

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 {
Expand Down Expand Up @@ -690,7 +698,7 @@ var DateTimePicker = function ($) {
}

if (handler) {
if (handler.call(this.widget)) {
if (handler.call(this)) {
e.stopPropagation();
e.preventDefault();
}
Expand Down Expand Up @@ -782,13 +790,13 @@ var DateTimePicker = function ($) {
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()) {
Expand Down Expand Up @@ -842,17 +850,14 @@ var DateTimePicker = function ($) {
}
}

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;
}
Expand Down Expand Up @@ -1093,10 +1098,12 @@ var DateTimePicker = function ($) {
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);
}
Expand Down Expand Up @@ -1465,7 +1472,7 @@ var DateTimePicker = function ($) {
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]');
}

Expand Down Expand Up @@ -1503,16 +1510,6 @@ var DateTimePicker = function ($) {
* @return {string}
*/

}, {
key: 'VERSION',
get: function get() {
return VERSION;
}

/**
* @return {string}
*/

}, {
key: 'DATA_KEY',
get: function get() {
Expand Down Expand Up @@ -1572,6 +1569,9 @@ var DateTimePicker = function ($) {
key: 'Default',
get: function get() {
return Default;
},
set: function set(value) {
Default = value;
}
}, {
key: 'ClassName',
Expand All @@ -1584,7 +1584,7 @@ var DateTimePicker = function ($) {
}();

return DateTimePicker;
}(jQuery);
}(jQuery, moment);

//noinspection JSUnusedGlobalSymbols
/* global DateTimePicker */
Expand Down Expand Up @@ -1988,12 +1988,12 @@ var TempusDominusBootstrap4 = function ($) {
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);
};
Expand Down Expand Up @@ -2751,7 +2751,7 @@ var TempusDominusBootstrap4 = function ($) {
if (!config._options.allowInputToggle) {
return;
}
TempusDominusBootstrap4._jQueryInterface.call($target, config, event);
TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event);
});

$.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface;
Expand Down
6 changes: 3 additions & 3 deletions build/js/tempusdominus-bootstrap-4.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tempusdominus/bootstrap-4",
"type": "component",
"version": "5.0.0-alpha18",
"version": "5.0.0",
"description": "Date/time picker widget based on twitter bootstrap",
"keywords": [
"bootstrap",
Expand Down

0 comments on commit 106740a

Please sign in to comment.