Merge branch 'master' into feature/update-php-date-formatter

This commit is contained in:
Valeriy 2022-04-06 14:48:42 +03:00 committed by GitHub
commit 382ca171bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 3236 additions and 80 deletions

View File

@ -1,7 +1,5 @@
language: node_js language: node_js
node_js: node_js:
- "8" - "8"
before_script: services:
- "export DISPLAY=:99.0" - xvfb
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

View File

@ -5,9 +5,7 @@
[![npm version](https://badge.fury.io/js/jquery-datetimepicker.svg)](https://badge.fury.io/js/jquery-datetimepicker) [![npm version](https://badge.fury.io/js/jquery-datetimepicker.svg)](https://badge.fury.io/js/jquery-datetimepicker)
[![npm](https://img.shields.io/npm/dm/jquery-datetimepicker.svg)](https://www.npmjs.com/package/jquery-datetimepicker) [![npm](https://img.shields.io/npm/dm/jquery-datetimepicker.svg)](https://www.npmjs.com/package/jquery-datetimepicker)
PLEASE. Help me update the documentation.
PLEASE. Help me update documentation.
[Doc.tpl](https://github.com/xdan/datetimepicker/blob/master/doc.tpl) [Doc.tpl](https://github.com/xdan/datetimepicker/blob/master/doc.tpl)
This file will be automatically displayed on the site This file will be automatically displayed on the site
@ -24,7 +22,7 @@ or download [zip](https://github.com/xdan/datetimepicker/releases)
# datetimepicker # datetimepicker
============== ==============
**!!! The latest version of the options 'lang' obsolete. The language setting is now global. !!!** **!!! In the latest version the 'lang' option is obsolete. The language setting is now global. !!!**
Use this: Use this:
```javascript ```javascript
@ -66,7 +64,7 @@ Install:
2. Run `npm install`. npm will look at `package.json` and automatically install the necessary dependencies. 2. Run `npm install`. npm will look at `package.json` and automatically install the necessary dependencies.
3. Run `bower install`, which installs front-end packages defined in `bower.json`. 3. Run `bower install`, which installs front-end packages defined in `bower.json`.
Notice: If you use Bower v1.5.2, you will get error: `The "main" field cannot contain minified files` Notice: If you use Bower v1.5.2, you will get the error: `The "main" field cannot contain minified files`
You can regress to version 1.3.12 You can regress to version 1.3.12
1. `npm uninstall bower -g` 1. `npm uninstall bower -g`
@ -77,7 +75,7 @@ Build:
First install npm requirements: `npm install -g uglifycss concat-cli` First install npm requirements: `npm install -g uglifycss concat-cli`
Then build the files: `npm run build` Then build the files: `npm run build`
When build completed, you'll have the following files: When the build completes, you'll have the following files:
- **build/jquery.datetimepicker.full.js** - browser file - **build/jquery.datetimepicker.full.js** - browser file
- **build/jquery.datetimepicker.full.min.js** - browser minified file - **build/jquery.datetimepicker.full.min.js** - browser minified file
- **build/jquery.datetimepicker.min.js** - amd module style minified file - **build/jquery.datetimepicker.min.js** - amd module style minified file

View File

@ -1135,11 +1135,11 @@ var datetimepickerFactory = function ($) {
$(this).parent().parent().hide(); $(this).parent().parent().hide();
datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('xchange.xdsoft');
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) { if (year !== _xdsoft_datetime.currentTime.getFullYear() && typeof options.onChangeYear === 'function') {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
} }
@ -1154,15 +1154,15 @@ var datetimepickerFactory = function ($) {
options = $.extend(true, {}, options, _options); options = $.extend(true, {}, options, _options);
if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) { if (_options.allowTimes && Array.isArray(_options.allowTimes) && _options.allowTimes.length) {
options.allowTimes = $.extend(true, [], _options.allowTimes); options.allowTimes = $.extend(true, [], _options.allowTimes);
} }
if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) { if (_options.weekends && Array.isArray(_options.weekends) && _options.weekends.length) {
options.weekends = $.extend(true, [], _options.weekends); options.weekends = $.extend(true, [], _options.weekends);
} }
if (_options.allowDates && $.isArray(_options.allowDates) && _options.allowDates.length) { if (_options.allowDates && Array.isArray(_options.allowDates) && _options.allowDates.length) {
options.allowDates = $.extend(true, [], _options.allowDates); options.allowDates = $.extend(true, [], _options.allowDates);
} }
@ -1170,7 +1170,7 @@ var datetimepickerFactory = function ($) {
options.allowDateRe = new RegExp(_options.allowDateRe); options.allowDateRe = new RegExp(_options.allowDateRe);
} }
if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) { if (_options.highlightedDates && Array.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
$.each(_options.highlightedDates, function (index, value) { $.each(_options.highlightedDates, function (index, value) {
var splitData = $.map(value.split(','), $.trim), var splitData = $.map(value.split(','), $.trim),
exDesc, exDesc,
@ -1189,7 +1189,7 @@ var datetimepickerFactory = function ($) {
options.highlightedDates = $.extend(true, [], highlightedDates); options.highlightedDates = $.extend(true, [], highlightedDates);
} }
if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) { if (_options.highlightedPeriods && Array.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
highlightedDates = $.extend(true, [], options.highlightedDates); highlightedDates = $.extend(true, [], options.highlightedDates);
$.each(_options.highlightedPeriods, function (index, value) { $.each(_options.highlightedPeriods, function (index, value) {
var dateTest, // start date var dateTest, // start date
@ -1199,7 +1199,7 @@ var datetimepickerFactory = function ($) {
keyDate, keyDate,
exDesc, exDesc,
style; style;
if ($.isArray(value)) { if (Array.isArray(value)) {
dateTest = value[0]; dateTest = value[0];
dateEnd = value[1]; dateEnd = value[1];
desc = value[2]; desc = value[2];
@ -1231,11 +1231,11 @@ var datetimepickerFactory = function ($) {
options.highlightedDates = $.extend(true, [], highlightedDates); options.highlightedDates = $.extend(true, [], highlightedDates);
} }
if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) { if (_options.disabledDates && Array.isArray(_options.disabledDates) && _options.disabledDates.length) {
options.disabledDates = $.extend(true, [], _options.disabledDates); options.disabledDates = $.extend(true, [], _options.disabledDates);
} }
if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) { if (_options.disabledWeekDays && Array.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays); options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
} }
@ -1319,8 +1319,8 @@ var datetimepickerFactory = function ($) {
input input
.off('blur.xdsoft') .off('blur.xdsoft')
.on('blur.xdsoft', function () { .on('blur.xdsoft', function () {
if (options.allowBlank && (!$.trim($(this).val()).length || if (options.allowBlank && (!$(this).val().trim().length ||
(typeof options.mask === "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) { (typeof options.mask === "string" && $(this).val().trim() === options.mask.replace(/[0-9]/g, '_')))) {
$(this).val(null); $(this).val(null);
datetimepicker.data('xdsoft_datetime').empty(); datetimepicker.data('xdsoft_datetime').empty();
} else { } else {
@ -1473,11 +1473,11 @@ var datetimepickerFactory = function ($) {
); );
_this.currentTime.setMonth(month); _this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) { if (year !== _this.currentTime.getFullYear() && typeof options.onChangeYear === 'function') {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
@ -1503,7 +1503,7 @@ var datetimepickerFactory = function ($) {
) )
); );
_this.currentTime.setMonth(month); _this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('xchange.xdsoft');
@ -1511,7 +1511,7 @@ var datetimepickerFactory = function ($) {
}; };
_this.getWeekOfYear = function (datetime) { _this.getWeekOfYear = function (datetime) {
if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) { if (options.onGetWeekOfYear && typeof options.onGetWeekOfYear === 'function') {
var week = options.onGetWeekOfYear.call(datetimepicker, datetime); var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
if (typeof week !== 'undefined') { if (typeof week !== 'undefined') {
return week; return week;
@ -1790,7 +1790,7 @@ var datetimepickerFactory = function ($) {
classes.push('xdsoft_date'); classes.push('xdsoft_date');
if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) { if (options.beforeShowDay && typeof options.beforeShowDay.call === 'function') {
customDateSettings = options.beforeShowDay.call(datetimepicker, start); customDateSettings = options.beforeShowDay.call(datetimepicker, start);
} else { } else {
customDateSettings = null; customDateSettings = null;
@ -1851,7 +1851,7 @@ var datetimepickerFactory = function ($) {
description = hDate.desc === undefined ? '' : hDate.desc; description = hDate.desc === undefined ? '' : hDate.desc;
} }
if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) { if (options.beforeShowDay && typeof options.beforeShowDay === 'function') {
classes.push(options.beforeShowDay(start)); classes.push(options.beforeShowDay(start));
} }
@ -1917,7 +1917,7 @@ var datetimepickerFactory = function ($) {
line_time = function line_time(h, m) { line_time = function line_time(h, m) {
var now = _xdsoft_datetime.now(), current_time, var now = _xdsoft_datetime.now(), current_time,
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length; isALlowTimesInit = options.allowTimes && Array.isArray(options.allowTimes) && options.allowTimes.length;
now.setHours(h); now.setHours(h);
h = parseInt(now.getHours(), 10); h = parseInt(now.getHours(), 10);
now.setMinutes(m); now.setMinutes(m);
@ -1948,7 +1948,7 @@ var datetimepickerFactory = function ($) {
time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>'; time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>';
}; };
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) { if (!options.allowTimes || !Array.isArray(options.allowTimes) || !options.allowTimes.length) {
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) { for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
for (j = 0; j < 60; j += options.step) { for (j = 0; j < 60; j += options.step) {
var currentMinutesOfDay = i * 60 + j; var currentMinutesOfDay = i * 60 + j;
@ -2034,7 +2034,7 @@ var datetimepickerFactory = function ($) {
input.val(_xdsoft_datetime.str()); input.val(_xdsoft_datetime.str());
if (options.onSelectDate && $.isFunction(options.onSelectDate)) { if (options.onSelectDate && typeof options.onSelectDate === 'function') {
options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent); options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
} }
@ -2074,7 +2074,7 @@ var datetimepickerFactory = function ($) {
datetimepicker.data('input').val(_xdsoft_datetime.str()); datetimepicker.data('input').val(_xdsoft_datetime.str());
if (options.onSelectTime && $.isFunction(options.onSelectTime)) { if (options.onSelectTime && typeof options.onSelectTime === 'function') {
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent); options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
} }
datetimepicker.data('changed', true); datetimepicker.data('changed', true);
@ -2126,7 +2126,7 @@ var datetimepickerFactory = function ($) {
datetimepicker datetimepicker
.on('changedatetime.xdsoft', function (event) { .on('changedatetime.xdsoft', function (event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) { if (options.onChangeDateTime && typeof options.onChangeDateTime === 'function') {
var $input = datetimepicker.data('input'); var $input = datetimepicker.data('input');
options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event); options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value; delete options.value;
@ -2134,7 +2134,7 @@ var datetimepickerFactory = function ($) {
} }
}) })
.on('generate.xdsoft', function () { .on('generate.xdsoft', function () {
if (options.onGenerate && $.isFunction(options.onGenerate)) { if (options.onGenerate && typeof options.onGenerate === 'function') {
options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (triggerAfterOpen) { if (triggerAfterOpen) {
@ -2284,7 +2284,7 @@ var datetimepickerFactory = function ($) {
datetimepicker datetimepicker
.on('open.xdsoft', function (event) { .on('open.xdsoft', function (event) {
var onShow = true; var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) { if (options.onShow && typeof options.onShow === 'function') {
onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event); onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
} }
if (onShow !== false) { if (onShow !== false) {
@ -2308,7 +2308,7 @@ var datetimepickerFactory = function ($) {
.find('.xdsoft_month,.xdsoft_year') .find('.xdsoft_month,.xdsoft_year')
.find('.xdsoft_select') .find('.xdsoft_select')
.hide(); .hide();
if (options.onClose && $.isFunction(options.onClose)) { if (options.onClose && typeof options.onClose === 'function') {
onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event); onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
} }
if (onClose !== false && !options.opened && !options.inline) { if (onClose !== false && !options.opened && !options.inline) {
@ -2424,7 +2424,7 @@ var datetimepickerFactory = function ($) {
} }
} }
if ($.type(options.mask) === 'string') { if (typeof options.mask === 'string') {
if (!isValidValue(options.mask, input.val())) { if (!isValidValue(options.mask, input.val())) {
input.val(options.mask.replace(/[0-9]/g, '_')); input.val(options.mask.replace(/[0-9]/g, '_'));
setCaretPos(input[0], 0); setCaretPos(input[0], 0);
@ -2454,7 +2454,7 @@ var datetimepickerFactory = function ($) {
if (isValidValue(options.mask, val)) { if (isValidValue(options.mask, val)) {
this.value = val; this.value = val;
setCaretPos(this, pos); setCaretPos(this, pos);
} else if ($.trim(val) === '') { } else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_'); this.value = options.mask.replace(/[0-9]/g, '_');
} else { } else {
input.trigger('error_input.xdsoft'); input.trigger('error_input.xdsoft');
@ -2534,7 +2534,7 @@ var datetimepickerFactory = function ($) {
val = valueBeforeCursor + insertChar + valueAfterNextChar val = valueBeforeCursor + insertChar + valueAfterNextChar
} }
if ($.trim(val) === '') { if (val.trim() === '') {
// if empty, set to default // if empty, set to default
val = defaultBlank val = defaultBlank
} else { } else {
@ -2555,7 +2555,7 @@ var datetimepickerFactory = function ($) {
if (isValidValue(options.mask, val)) { if (isValidValue(options.mask, val)) {
this.value = val; this.value = val;
setCaretPos(this, pos); setCaretPos(this, pos);
} else if ($.trim(val) === '') { } else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_'); this.value = options.mask.replace(/[0-9]/g, '_');
} else { } else {
input.trigger('error_input.xdsoft'); input.trigger('error_input.xdsoft');
@ -2657,7 +2657,7 @@ var datetimepickerFactory = function ($) {
this.each(function () { this.each(function () {
var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input; var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
if (datetimepicker) { if (datetimepicker) {
if ($.type(opt) === 'string') { if (typeof opt === 'string') {
switch (opt) { switch (opt) {
case 'show': case 'show':
$(this).select().focus(); $(this).select().focus();
@ -2684,7 +2684,7 @@ var datetimepickerFactory = function ($) {
$input.trigger('blur.xdsoft'); $input.trigger('blur.xdsoft');
break; break;
default: default:
if (datetimepicker[opt] && $.isFunction(datetimepicker[opt])) { if (datetimepicker[opt] && typeof datetimepicker[opt] === 'function') {
result = datetimepicker[opt](opt2); result = datetimepicker[opt](opt2);
} }
} }
@ -2694,7 +2694,7 @@ var datetimepickerFactory = function ($) {
} }
return 0; return 0;
} }
if ($.type(opt) !== 'string') { if (typeof opt !== 'string') {
if (!options.lazyInit || options.open || options.inline) { if (!options.lazyInit || options.open || options.inline) {
createDateTimePicker($(this)); createDateTimePicker($(this));
} else { } else {

File diff suppressed because one or more lines are too long

View File

@ -1122,11 +1122,11 @@ var datetimepickerFactory = function ($) {
$(this).parent().parent().hide(); $(this).parent().parent().hide();
datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('xchange.xdsoft');
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) { if (year !== _xdsoft_datetime.currentTime.getFullYear() && typeof options.onChangeYear === 'function') {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
} }
@ -1141,15 +1141,15 @@ var datetimepickerFactory = function ($) {
options = $.extend(true, {}, options, _options); options = $.extend(true, {}, options, _options);
if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) { if (_options.allowTimes && Array.isArray(_options.allowTimes) && _options.allowTimes.length) {
options.allowTimes = $.extend(true, [], _options.allowTimes); options.allowTimes = $.extend(true, [], _options.allowTimes);
} }
if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) { if (_options.weekends && Array.isArray(_options.weekends) && _options.weekends.length) {
options.weekends = $.extend(true, [], _options.weekends); options.weekends = $.extend(true, [], _options.weekends);
} }
if (_options.allowDates && $.isArray(_options.allowDates) && _options.allowDates.length) { if (_options.allowDates && Array.isArray(_options.allowDates) && _options.allowDates.length) {
options.allowDates = $.extend(true, [], _options.allowDates); options.allowDates = $.extend(true, [], _options.allowDates);
} }
@ -1157,7 +1157,7 @@ var datetimepickerFactory = function ($) {
options.allowDateRe = new RegExp(_options.allowDateRe); options.allowDateRe = new RegExp(_options.allowDateRe);
} }
if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) { if (_options.highlightedDates && Array.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
$.each(_options.highlightedDates, function (index, value) { $.each(_options.highlightedDates, function (index, value) {
var splitData = $.map(value.split(','), $.trim), var splitData = $.map(value.split(','), $.trim),
exDesc, exDesc,
@ -1176,7 +1176,7 @@ var datetimepickerFactory = function ($) {
options.highlightedDates = $.extend(true, [], highlightedDates); options.highlightedDates = $.extend(true, [], highlightedDates);
} }
if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) { if (_options.highlightedPeriods && Array.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
highlightedDates = $.extend(true, [], options.highlightedDates); highlightedDates = $.extend(true, [], options.highlightedDates);
$.each(_options.highlightedPeriods, function (index, value) { $.each(_options.highlightedPeriods, function (index, value) {
var dateTest, // start date var dateTest, // start date
@ -1186,7 +1186,7 @@ var datetimepickerFactory = function ($) {
keyDate, keyDate,
exDesc, exDesc,
style; style;
if ($.isArray(value)) { if (Array.isArray(value)) {
dateTest = value[0]; dateTest = value[0];
dateEnd = value[1]; dateEnd = value[1];
desc = value[2]; desc = value[2];
@ -1218,11 +1218,11 @@ var datetimepickerFactory = function ($) {
options.highlightedDates = $.extend(true, [], highlightedDates); options.highlightedDates = $.extend(true, [], highlightedDates);
} }
if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) { if (_options.disabledDates && Array.isArray(_options.disabledDates) && _options.disabledDates.length) {
options.disabledDates = $.extend(true, [], _options.disabledDates); options.disabledDates = $.extend(true, [], _options.disabledDates);
} }
if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) { if (_options.disabledWeekDays && Array.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays); options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
} }
@ -1306,8 +1306,8 @@ var datetimepickerFactory = function ($) {
input input
.off('blur.xdsoft') .off('blur.xdsoft')
.on('blur.xdsoft', function () { .on('blur.xdsoft', function () {
if (options.allowBlank && (!$.trim($(this).val()).length || if (options.allowBlank && (!$(this).val().trim().length ||
(typeof options.mask === "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) { (typeof options.mask === "string" && $(this).val().trim() === options.mask.replace(/[0-9]/g, '_')))) {
$(this).val(null); $(this).val(null);
datetimepicker.data('xdsoft_datetime').empty(); datetimepicker.data('xdsoft_datetime').empty();
} else { } else {
@ -1460,11 +1460,11 @@ var datetimepickerFactory = function ($) {
); );
_this.currentTime.setMonth(month); _this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) { if (year !== _this.currentTime.getFullYear() && typeof options.onChangeYear === 'function') {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
@ -1490,7 +1490,7 @@ var datetimepickerFactory = function ($) {
) )
); );
_this.currentTime.setMonth(month); _this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) { if (options.onChangeMonth && typeof options.onChangeMonth === 'function') {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('xchange.xdsoft');
@ -1498,7 +1498,7 @@ var datetimepickerFactory = function ($) {
}; };
_this.getWeekOfYear = function (datetime) { _this.getWeekOfYear = function (datetime) {
if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) { if (options.onGetWeekOfYear && typeof options.onGetWeekOfYear === 'function') {
var week = options.onGetWeekOfYear.call(datetimepicker, datetime); var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
if (typeof week !== 'undefined') { if (typeof week !== 'undefined') {
return week; return week;
@ -1777,7 +1777,7 @@ var datetimepickerFactory = function ($) {
classes.push('xdsoft_date'); classes.push('xdsoft_date');
if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) { if (options.beforeShowDay && typeof options.beforeShowDay.call === 'function') {
customDateSettings = options.beforeShowDay.call(datetimepicker, start); customDateSettings = options.beforeShowDay.call(datetimepicker, start);
} else { } else {
customDateSettings = null; customDateSettings = null;
@ -1838,7 +1838,7 @@ var datetimepickerFactory = function ($) {
description = hDate.desc === undefined ? '' : hDate.desc; description = hDate.desc === undefined ? '' : hDate.desc;
} }
if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) { if (options.beforeShowDay && typeof options.beforeShowDay === 'function') {
classes.push(options.beforeShowDay(start)); classes.push(options.beforeShowDay(start));
} }
@ -1904,7 +1904,7 @@ var datetimepickerFactory = function ($) {
line_time = function line_time(h, m) { line_time = function line_time(h, m) {
var now = _xdsoft_datetime.now(), current_time, var now = _xdsoft_datetime.now(), current_time,
isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length; isALlowTimesInit = options.allowTimes && Array.isArray(options.allowTimes) && options.allowTimes.length;
now.setHours(h); now.setHours(h);
h = parseInt(now.getHours(), 10); h = parseInt(now.getHours(), 10);
now.setMinutes(m); now.setMinutes(m);
@ -1935,7 +1935,7 @@ var datetimepickerFactory = function ($) {
time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>'; time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>';
}; };
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) { if (!options.allowTimes || !Array.isArray(options.allowTimes) || !options.allowTimes.length) {
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) { for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
for (j = 0; j < 60; j += options.step) { for (j = 0; j < 60; j += options.step) {
var currentMinutesOfDay = i * 60 + j; var currentMinutesOfDay = i * 60 + j;
@ -2021,7 +2021,7 @@ var datetimepickerFactory = function ($) {
input.val(_xdsoft_datetime.str()); input.val(_xdsoft_datetime.str());
if (options.onSelectDate && $.isFunction(options.onSelectDate)) { if (options.onSelectDate && typeof options.onSelectDate === 'function') {
options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent); options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
} }
@ -2061,7 +2061,7 @@ var datetimepickerFactory = function ($) {
datetimepicker.data('input').val(_xdsoft_datetime.str()); datetimepicker.data('input').val(_xdsoft_datetime.str());
if (options.onSelectTime && $.isFunction(options.onSelectTime)) { if (options.onSelectTime && typeof options.onSelectTime === 'function') {
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent); options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
} }
datetimepicker.data('changed', true); datetimepicker.data('changed', true);
@ -2113,7 +2113,7 @@ var datetimepickerFactory = function ($) {
datetimepicker datetimepicker
.on('changedatetime.xdsoft', function (event) { .on('changedatetime.xdsoft', function (event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) { if (options.onChangeDateTime && typeof options.onChangeDateTime === 'function') {
var $input = datetimepicker.data('input'); var $input = datetimepicker.data('input');
options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event); options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value; delete options.value;
@ -2121,7 +2121,7 @@ var datetimepickerFactory = function ($) {
} }
}) })
.on('generate.xdsoft', function () { .on('generate.xdsoft', function () {
if (options.onGenerate && $.isFunction(options.onGenerate)) { if (options.onGenerate && typeof options.onGenerate === 'function') {
options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input')); options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
} }
if (triggerAfterOpen) { if (triggerAfterOpen) {
@ -2271,7 +2271,7 @@ var datetimepickerFactory = function ($) {
datetimepicker datetimepicker
.on('open.xdsoft', function (event) { .on('open.xdsoft', function (event) {
var onShow = true; var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) { if (options.onShow && typeof options.onShow === 'function') {
onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event); onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
} }
if (onShow !== false) { if (onShow !== false) {
@ -2295,7 +2295,7 @@ var datetimepickerFactory = function ($) {
.find('.xdsoft_month,.xdsoft_year') .find('.xdsoft_month,.xdsoft_year')
.find('.xdsoft_select') .find('.xdsoft_select')
.hide(); .hide();
if (options.onClose && $.isFunction(options.onClose)) { if (options.onClose && typeof options.onClose === 'function') {
onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event); onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
} }
if (onClose !== false && !options.opened && !options.inline) { if (onClose !== false && !options.opened && !options.inline) {
@ -2411,7 +2411,7 @@ var datetimepickerFactory = function ($) {
} }
} }
if ($.type(options.mask) === 'string') { if (typeof options.mask === 'string') {
if (!isValidValue(options.mask, input.val())) { if (!isValidValue(options.mask, input.val())) {
input.val(options.mask.replace(/[0-9]/g, '_')); input.val(options.mask.replace(/[0-9]/g, '_'));
setCaretPos(input[0], 0); setCaretPos(input[0], 0);
@ -2441,7 +2441,7 @@ var datetimepickerFactory = function ($) {
if (isValidValue(options.mask, val)) { if (isValidValue(options.mask, val)) {
this.value = val; this.value = val;
setCaretPos(this, pos); setCaretPos(this, pos);
} else if ($.trim(val) === '') { } else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_'); this.value = options.mask.replace(/[0-9]/g, '_');
} else { } else {
input.trigger('error_input.xdsoft'); input.trigger('error_input.xdsoft');
@ -2521,7 +2521,7 @@ var datetimepickerFactory = function ($) {
val = valueBeforeCursor + insertChar + valueAfterNextChar val = valueBeforeCursor + insertChar + valueAfterNextChar
} }
if ($.trim(val) === '') { if (val.trim() === '') {
// if empty, set to default // if empty, set to default
val = defaultBlank val = defaultBlank
} else { } else {
@ -2542,7 +2542,7 @@ var datetimepickerFactory = function ($) {
if (isValidValue(options.mask, val)) { if (isValidValue(options.mask, val)) {
this.value = val; this.value = val;
setCaretPos(this, pos); setCaretPos(this, pos);
} else if ($.trim(val) === '') { } else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_'); this.value = options.mask.replace(/[0-9]/g, '_');
} else { } else {
input.trigger('error_input.xdsoft'); input.trigger('error_input.xdsoft');
@ -2644,7 +2644,7 @@ var datetimepickerFactory = function ($) {
this.each(function () { this.each(function () {
var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input; var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
if (datetimepicker) { if (datetimepicker) {
if ($.type(opt) === 'string') { if (typeof opt === 'string') {
switch (opt) { switch (opt) {
case 'show': case 'show':
$(this).select().focus(); $(this).select().focus();
@ -2671,7 +2671,7 @@ var datetimepickerFactory = function ($) {
$input.trigger('blur.xdsoft'); $input.trigger('blur.xdsoft');
break; break;
default: default:
if (datetimepicker[opt] && $.isFunction(datetimepicker[opt])) { if (datetimepicker[opt] && typeof datetimepicker[opt] === 'function') {
result = datetimepicker[opt](opt2); result = datetimepicker[opt](opt2);
} }
} }
@ -2681,7 +2681,7 @@ var datetimepickerFactory = function ($) {
} }
return 0; return 0;
} }
if ($.type(opt) !== 'string') { if (typeof opt !== 'string') {
if (!options.lazyInit || options.open || options.inline) { if (!options.lazyInit || options.open || options.inline) {
createDateTimePicker($(this)); createDateTimePicker($(this));
} else { } else {

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "jquery-datetimepicker", "name": "jquery-datetimepicker",
"version": "2.5.21", "version": "2.5.22",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "jquery-datetimepicker", "name": "jquery-datetimepicker",
"version": "2.5.21", "version": "2.5.22",
"description": "jQuery Plugin DateTimePicker it is DatePicker and TimePicker in one", "description": "jQuery Plugin DateTimePicker it is DatePicker and TimePicker in one",
"main": "build/jquery.datetimepicker.full.min.js", "main": "build/jquery.datetimepicker.full.min.js",
"scripts": { "scripts": {

3159
yarn.lock Normal file

File diff suppressed because it is too large Load Diff