Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan authored Apr 6, 2022
2 parents ac83979 + 1440346 commit 031fe1f
Show file tree
Hide file tree
Showing 10 changed files with 3,264 additions and 104 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
node_modules
bower_components/
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: node_js
node_js:
- "8"
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
services:
- xvfb
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
[![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)



PLEASE. Help me update documentation.
PLEASE. Help me update the documentation.
[Doc.tpl](https://github.com/xdan/datetimepicker/blob/master/doc.tpl)
This file will be automatically displayed on the site

Expand All @@ -24,7 +22,7 @@ or download [zip](https://github.com/xdan/datetimepicker/releases)
# 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:
```javascript
Expand Down Expand Up @@ -66,7 +64,7 @@ Install:
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`.

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

1. `npm uninstall bower -g`
Expand All @@ -77,7 +75,7 @@ Build:
First install npm requirements: `npm install -g uglifycss concat-cli`
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.min.js** - browser minified file
- **build/jquery.datetimepicker.min.js** - amd module style minified file
89 changes: 46 additions & 43 deletions build/jquery.datetimepicker.full.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/jquery.datetimepicker.full.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion build/jquery.datetimepicker.min.js

Large diffs are not rendered by default.

86 changes: 43 additions & 43 deletions jquery.datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,11 +1122,11 @@ var datetimepickerFactory = function ($) {
$(this).parent().parent().hide();

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'));
}

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'));
}
}
Expand All @@ -1141,23 +1141,23 @@ var datetimepickerFactory = function ($) {

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);
}

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);
}

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);
}

if (_options.allowDateRe && Object.prototype.toString.call(_options.allowDateRe)==="[object String]") {
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) {
var splitData = $.map(value.split(','), $.trim),
exDesc,
Expand All @@ -1176,7 +1176,7 @@ var datetimepickerFactory = function ($) {
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);
$.each(_options.highlightedPeriods, function (index, value) {
var dateTest, // start date
Expand All @@ -1186,7 +1186,7 @@ var datetimepickerFactory = function ($) {
keyDate,
exDesc,
style;
if ($.isArray(value)) {
if (Array.isArray(value)) {
dateTest = value[0];
dateEnd = value[1];
desc = value[2];
Expand Down Expand Up @@ -1218,11 +1218,11 @@ var datetimepickerFactory = function ($) {
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);
}

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);
}

Expand Down Expand Up @@ -1306,8 +1306,8 @@ var datetimepickerFactory = function ($) {
input
.off('blur.xdsoft')
.on('blur.xdsoft', function () {
if (options.allowBlank && (!$.trim($(this).val()).length ||
(typeof options.mask === "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {
if (options.allowBlank && (!$(this).val().trim().length ||
(typeof options.mask === "string" && $(this).val().trim() === options.mask.replace(/[0-9]/g, '_')))) {
$(this).val(null);
datetimepicker.data('xdsoft_datetime').empty();
} else {
Expand Down Expand Up @@ -1460,11 +1460,11 @@ var datetimepickerFactory = function ($) {
);
_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'));
}

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'));
}

Expand All @@ -1490,15 +1490,15 @@ var datetimepickerFactory = function ($) {
)
);
_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'));
}
datetimepicker.trigger('xchange.xdsoft');
return month;
};

_this.getWeekOfYear = function (datetime) {
if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) {
if (options.onGetWeekOfYear && typeof options.onGetWeekOfYear === 'function') {
var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
if (typeof week !== 'undefined') {
return week;
Expand Down Expand Up @@ -1777,7 +1777,7 @@ var datetimepickerFactory = function ($) {

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);
} else {
customDateSettings = null;
Expand Down Expand Up @@ -1838,7 +1838,7 @@ var datetimepickerFactory = function ($) {
description = hDate.desc === undefined ? '' : hDate.desc;
}

if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
if (options.beforeShowDay && typeof options.beforeShowDay === 'function') {
classes.push(options.beforeShowDay(start));
}

Expand Down Expand Up @@ -1904,7 +1904,7 @@ var datetimepickerFactory = function ($) {

line_time = function line_time(h, m) {
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);
h = parseInt(now.getHours(), 10);
now.setMinutes(m);
Expand Down Expand Up @@ -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>';
};

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 (j = 0; j < 60; j += options.step) {
var currentMinutesOfDay = i * 60 + j;
Expand Down Expand Up @@ -2021,7 +2021,7 @@ var datetimepickerFactory = function ($) {

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);
}

Expand Down Expand Up @@ -2061,7 +2061,7 @@ var datetimepickerFactory = function ($) {

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);
}
datetimepicker.data('changed', true);
Expand Down Expand Up @@ -2113,15 +2113,15 @@ var datetimepickerFactory = function ($) {

datetimepicker
.on('changedatetime.xdsoft', function (event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
if (options.onChangeDateTime && typeof options.onChangeDateTime === 'function') {
var $input = datetimepicker.data('input');
options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value;
$input.trigger('change');
}
})
.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'));
}
if (triggerAfterOpen) {
Expand Down Expand Up @@ -2271,7 +2271,7 @@ var datetimepickerFactory = function ($) {
datetimepicker
.on('open.xdsoft', function (event) {
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);
}
if (onShow !== false) {
Expand All @@ -2295,7 +2295,7 @@ var datetimepickerFactory = function ($) {
.find('.xdsoft_month,.xdsoft_year')
.find('.xdsoft_select')
.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);
}
if (onClose !== false && !options.opened && !options.inline) {
Expand Down Expand Up @@ -2411,7 +2411,7 @@ var datetimepickerFactory = function ($) {
}
}

if ($.type(options.mask) === 'string') {
if (typeof options.mask === 'string') {
if (!isValidValue(options.mask, input.val())) {
input.val(options.mask.replace(/[0-9]/g, '_'));
setCaretPos(input[0], 0);
Expand All @@ -2432,16 +2432,16 @@ var datetimepickerFactory = function ($) {
val = this.value,
pos = this.selectionStart

var valueBeforeCursor = val.substr(0, pos);
var valueAfterPaste = val.substr(pos + pastedData.length);
var valueBeforeCursor = val.slice(0, pos);
var valueAfterPaste = val.slice(pos + pastedData.length);

val = valueBeforeCursor + pastedData + valueAfterPaste;
pos += pastedData.length;

if (isValidValue(options.mask, val)) {
this.value = val;
setCaretPos(this, pos);
} else if ($.trim(val) === '') {
} else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_');
} else {
input.trigger('error_input.xdsoft');
Expand Down Expand Up @@ -2478,7 +2478,7 @@ var datetimepickerFactory = function ($) {
// value char - keep incrementing position while on separator char and we still have room
// del char - keep decrementing position while on separator char and we still have room
while (true) {
var maskValueAtCurPos = options.mask.substr(pos, 1);
var maskValueAtCurPos = options.mask.slice(pos, pos+1);
var posShorterThanMaskLength = pos < options.mask.length;
var posGreaterThanZero = pos > 0;
var notNumberOrPlaceholder = /[^0-9_]/;
Expand All @@ -2504,24 +2504,24 @@ var datetimepickerFactory = function ($) {

// if we have a selection length we will wipe out entire selection and replace with default template for that range
var defaultBlank = options.mask.replace(/[0-9]/g, '_');
var defaultBlankSelectionReplacement = defaultBlank.substr(pos, selLength);
var selReplacementRemainder = defaultBlankSelectionReplacement.substr(1) // might be empty
var defaultBlankSelectionReplacement = defaultBlank.slice(pos, pos+selLength);
var selReplacementRemainder = defaultBlankSelectionReplacement.slice(1) // might be empty

var valueBeforeSel = val.substr(0, pos);
var valueBeforeSel = val.slice(0, pos);
var insertChars = digit + selReplacementRemainder;
var charsAfterSelection = val.substr(pos + selLength);
var charsAfterSelection = val.slice(pos + selLength);

val = valueBeforeSel + insertChars + charsAfterSelection

} else {
var valueBeforeCursor = val.substr(0, pos);
var valueBeforeCursor = val.slice(0, pos);
var insertChar = digit;
var valueAfterNextChar = val.substr(pos + 1);
var valueAfterNextChar = val.slice(pos + 1);

val = valueBeforeCursor + insertChar + valueAfterNextChar
}

if ($.trim(val) === '') {
if (val.trim() === '') {
// if empty, set to default
val = defaultBlank
} else {
Expand All @@ -2535,14 +2535,14 @@ var datetimepickerFactory = function ($) {
// resume cursor location
pos += (key === BACKSPACE) ? 0 : 1;
// don't stop on a separator, continue whatever direction you were going
while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
while (/[^0-9_]/.test(options.mask.slice(pos, pos+1)) && pos < options.mask.length && pos > 0) {
pos += (key === BACKSPACE) ? 0 : 1;
}

if (isValidValue(options.mask, val)) {
this.value = val;
setCaretPos(this, pos);
} else if ($.trim(val) === '') {
} else if (val.trim() === '') {
this.value = options.mask.replace(/[0-9]/g, '_');
} else {
input.trigger('error_input.xdsoft');
Expand Down Expand Up @@ -2644,7 +2644,7 @@ var datetimepickerFactory = function ($) {
this.each(function () {
var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
if (datetimepicker) {
if ($.type(opt) === 'string') {
if (typeof opt === 'string') {
switch (opt) {
case 'show':
$(this).select().focus();
Expand All @@ -2671,7 +2671,7 @@ var datetimepickerFactory = function ($) {
$input.trigger('blur.xdsoft');
break;
default:
if (datetimepicker[opt] && $.isFunction(datetimepicker[opt])) {
if (datetimepicker[opt] && typeof datetimepicker[opt] === 'function') {
result = datetimepicker[opt](opt2);
}
}
Expand All @@ -2681,7 +2681,7 @@ var datetimepickerFactory = function ($) {
}
return 0;
}
if ($.type(opt) !== 'string') {
if (typeof opt !== 'string') {
if (!options.lazyInit || options.open || options.inline) {
createDateTimePicker($(this));
} else {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 031fe1f

Please sign in to comment.