datatables.net-datetime 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/datatables.net-datetime.1.5.0.nupkg +0 -0
- package/dist/dataTables.dateTime.js +381 -375
- package/dist/dataTables.dateTime.min.js +2 -2
- package/dist/dataTables.dateTime.min.mjs +2 -2
- package/dist/dataTables.dateTime.mjs +380 -374
- package/docs/api/DateTime.use().xml +0 -2
- package/docs/api/destroy().xml +0 -2
- package/docs/api/display().xml +1 -1
- package/docs/api/errorMsg().xml +2 -6
- package/docs/api/hide().xml +0 -4
- package/docs/api/max().xml +1 -3
- package/docs/api/min().xml +1 -3
- package/docs/api/owns().xml +2 -4
- package/docs/api/val().xml +2 -6
- package/docs/api/valFormat().xml +2 -6
- package/docs/option/buttons.clear.xml +0 -2
- package/docs/option/buttons.today.xml +0 -2
- package/docs/option/buttons.xml +0 -2
- package/docs/option/disableDays.xml +3 -3
- package/docs/option/format.xml +1 -3
- package/docs/option/hoursAvailable.xml +2 -2
- package/docs/option/i18n.amPm.xml +1 -1
- package/docs/option/i18n.clear.xml +1 -3
- package/docs/option/i18n.hours.xml +1 -1
- package/docs/option/i18n.minutes.xml +1 -1
- package/docs/option/i18n.months.xml +15 -2
- package/docs/option/i18n.next.xml +2 -2
- package/docs/option/i18n.previous.xml +2 -2
- package/docs/option/i18n.seconds.xml +1 -1
- package/docs/option/i18n.today.xml +1 -3
- package/docs/option/i18n.unknown.xml +1 -1
- package/docs/option/i18n.weekdays.xml +1 -1
- package/docs/option/i18n.xml +3 -5
- package/docs/option/locale.xml +0 -2
- package/docs/option/maxDate.xml +0 -4
- package/docs/option/minDate.xml +0 -4
- package/docs/option/minutesAvailable.xml +2 -2
- package/docs/option/onChange.xml +0 -2
- package/docs/option/secondsAvailable.xml +2 -2
- package/docs/option/showWeekNumber.xml +2 -2
- package/docs/option/yearRange.xml +2 -2
- package/examples/initialisation/datetime.xml +2 -2
- package/examples/initialisation/moment.xml +2 -2
- package/examples/integration/form.xml +20 -2
- package/js/dataTables.dateTime.js +380 -374
- package/nuget.nuspec +1 -1
- package/package.json +1 -1
- package/test/api/dateTime.display().js +47 -0
- package/test/options/dateTime.buttons.js +71 -0
- package/test/options/dateTime.hoursAvailable.js +38 -0
- package/test/options/dateTime.locale.js +31 -0
- package/test/options/dateTime.minutesAvailable.js +46 -0
- package/test/options/dateTime.secondsAvailable.js +46 -0
- package/datatables.net-datetime.1.4.0.nupkg +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.5.
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.5.2
|
|
2
2
|
*
|
|
3
3
|
* © SpryMedia Ltd, all rights reserved.
|
|
4
4
|
* License: MIT datatables.net/license/mit
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
// Browser
|
|
42
42
|
factory( jQuery, window, document );
|
|
43
43
|
}
|
|
44
|
-
}(function( $, window, document
|
|
44
|
+
}(function( $, window, document ) {
|
|
45
45
|
'use strict';
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @summary DateTime picker for DataTables.net
|
|
51
|
-
* @version 1.5.
|
|
51
|
+
* @version 1.5.2
|
|
52
52
|
* @file dataTables.dateTime.js
|
|
53
53
|
* @author SpryMedia Ltd
|
|
54
54
|
* @contact www.datatables.net/contact
|
|
@@ -76,7 +76,7 @@ var dateLib;
|
|
|
76
76
|
* where `input` is the HTML input element to use and `opts` is an object of
|
|
77
77
|
* options based on the `DateTime.defaults` object.
|
|
78
78
|
*/
|
|
79
|
-
var DateTime = function (
|
|
79
|
+
var DateTime = function (input, opts) {
|
|
80
80
|
// Check if called with a window or jQuery object for DOM less applications
|
|
81
81
|
// This is for backwards compatibility with CommonJS loader
|
|
82
82
|
if (DateTime.factory(input, opts)) {
|
|
@@ -95,12 +95,11 @@ var DateTime = function ( input, opts ) {
|
|
|
95
95
|
: null;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
this.c = $.extend(
|
|
98
|
+
this.c = $.extend(true, {}, DateTime.defaults, opts);
|
|
99
99
|
var classPrefix = this.c.classPrefix;
|
|
100
|
-
var i18n = this.c.i18n;
|
|
101
100
|
|
|
102
101
|
// Only IS8601 dates are supported without moment, dayjs or luxon
|
|
103
|
-
if (
|
|
102
|
+
if (!dateLib && this.c.format !== 'YYYY-MM-DD') {
|
|
104
103
|
throw "DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";
|
|
105
104
|
}
|
|
106
105
|
|
|
@@ -114,52 +113,52 @@ var DateTime = function ( input, opts ) {
|
|
|
114
113
|
|
|
115
114
|
// DOM structure
|
|
116
115
|
var structure = $(
|
|
117
|
-
'<div class="'+classPrefix+'">'+
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
116
|
+
'<div class="' + classPrefix + '">' +
|
|
117
|
+
'<div class="' + classPrefix + '-date">' +
|
|
118
|
+
'<div class="' + classPrefix + '-title">' +
|
|
119
|
+
'<div class="' + classPrefix + '-iconLeft">' +
|
|
120
|
+
'<button type="button"></button>' +
|
|
121
|
+
'</div>' +
|
|
122
|
+
'<div class="' + classPrefix + '-iconRight">' +
|
|
123
|
+
'<button type="button"></button>' +
|
|
124
|
+
'</div>' +
|
|
125
|
+
'<div class="' + classPrefix + '-label">' +
|
|
126
|
+
'<span></span>' +
|
|
127
|
+
'<select class="' + classPrefix + '-month"></select>' +
|
|
128
|
+
'</div>' +
|
|
129
|
+
'<div class="' + classPrefix + '-label">' +
|
|
130
|
+
'<span></span>' +
|
|
131
|
+
'<select class="' + classPrefix + '-year"></select>' +
|
|
132
|
+
'</div>' +
|
|
133
|
+
'</div>' +
|
|
134
|
+
'<div class="' + classPrefix + '-buttons">' +
|
|
135
|
+
'<a class="' + classPrefix + '-clear"></a>' +
|
|
136
|
+
'<a class="' + classPrefix + '-today"></a>' +
|
|
137
|
+
'</div>' +
|
|
138
|
+
'<div class="' + classPrefix + '-calendar"></div>' +
|
|
139
|
+
'</div>' +
|
|
140
|
+
'<div class="' + classPrefix + '-time">' +
|
|
141
|
+
'<div class="' + classPrefix + '-hours"></div>' +
|
|
142
|
+
'<div class="' + classPrefix + '-minutes"></div>' +
|
|
143
|
+
'<div class="' + classPrefix + '-seconds"></div>' +
|
|
144
|
+
'</div>' +
|
|
145
|
+
'<div class="' + classPrefix + '-error"></div>' +
|
|
147
146
|
'</div>'
|
|
148
147
|
);
|
|
149
148
|
|
|
150
149
|
this.dom = {
|
|
151
150
|
container: structure,
|
|
152
|
-
date:
|
|
153
|
-
title:
|
|
154
|
-
calendar:
|
|
155
|
-
time:
|
|
156
|
-
error:
|
|
157
|
-
buttons:
|
|
158
|
-
clear:
|
|
159
|
-
today:
|
|
160
|
-
previous:
|
|
161
|
-
next:
|
|
162
|
-
input:
|
|
151
|
+
date: structure.find('.' + classPrefix + '-date'),
|
|
152
|
+
title: structure.find('.' + classPrefix + '-title'),
|
|
153
|
+
calendar: structure.find('.' + classPrefix + '-calendar'),
|
|
154
|
+
time: structure.find('.' + classPrefix + '-time'),
|
|
155
|
+
error: structure.find('.' + classPrefix + '-error'),
|
|
156
|
+
buttons: structure.find('.' + classPrefix + '-buttons'),
|
|
157
|
+
clear: structure.find('.' + classPrefix + '-clear'),
|
|
158
|
+
today: structure.find('.' + classPrefix + '-today'),
|
|
159
|
+
previous: structure.find('.' + classPrefix + '-iconLeft'),
|
|
160
|
+
next: structure.find('.' + classPrefix + '-iconRight'),
|
|
161
|
+
input: $(input)
|
|
163
162
|
};
|
|
164
163
|
|
|
165
164
|
this.s = {
|
|
@@ -176,37 +175,37 @@ var DateTime = function ( input, opts ) {
|
|
|
176
175
|
secondsRange: null,
|
|
177
176
|
|
|
178
177
|
/** @type {String} Unique namespace string for this instance */
|
|
179
|
-
namespace: 'dateime-'+(DateTime._instance++),
|
|
178
|
+
namespace: 'dateime-' + (DateTime._instance++),
|
|
180
179
|
|
|
181
180
|
/** @type {Object} Parts of the picker that should be shown */
|
|
182
181
|
parts: {
|
|
183
|
-
date:
|
|
184
|
-
time:
|
|
185
|
-
seconds: this.c.format.indexOf(
|
|
186
|
-
hours12: this.c.format.match(
|
|
182
|
+
date: this.c.format.match(/[YMD]|L(?!T)|l/) !== null,
|
|
183
|
+
time: this.c.format.match(/[Hhm]|LT|LTS/) !== null,
|
|
184
|
+
seconds: this.c.format.indexOf('s') !== -1,
|
|
185
|
+
hours12: this.c.format.match(/[haA]/) !== null
|
|
187
186
|
}
|
|
188
187
|
};
|
|
189
188
|
|
|
190
189
|
this.dom.container
|
|
191
|
-
.append(
|
|
192
|
-
.append(
|
|
193
|
-
.append(
|
|
190
|
+
.append(this.dom.date)
|
|
191
|
+
.append(this.dom.time)
|
|
192
|
+
.append(this.dom.error);
|
|
194
193
|
|
|
195
194
|
this.dom.date
|
|
196
|
-
.append(
|
|
197
|
-
.append(
|
|
198
|
-
.append(
|
|
195
|
+
.append(this.dom.title)
|
|
196
|
+
.append(this.dom.buttons)
|
|
197
|
+
.append(this.dom.calendar);
|
|
199
198
|
|
|
200
199
|
this.dom.input.addClass('dt-datetime');
|
|
201
200
|
|
|
202
201
|
this._constructor();
|
|
203
202
|
};
|
|
204
203
|
|
|
205
|
-
$.extend(
|
|
204
|
+
$.extend(DateTime.prototype, {
|
|
206
205
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
207
206
|
* Public
|
|
208
207
|
*/
|
|
209
|
-
|
|
208
|
+
|
|
210
209
|
/**
|
|
211
210
|
* Destroy the control
|
|
212
211
|
*/
|
|
@@ -241,11 +240,11 @@ $.extend( DateTime.prototype, {
|
|
|
241
240
|
};
|
|
242
241
|
},
|
|
243
242
|
|
|
244
|
-
errorMsg: function (
|
|
243
|
+
errorMsg: function (msg) {
|
|
245
244
|
var error = this.dom.error;
|
|
246
245
|
|
|
247
|
-
if (
|
|
248
|
-
error.html(
|
|
246
|
+
if (msg) {
|
|
247
|
+
error.html(msg);
|
|
249
248
|
}
|
|
250
249
|
else {
|
|
251
250
|
error.empty();
|
|
@@ -260,7 +259,7 @@ $.extend( DateTime.prototype, {
|
|
|
260
259
|
return this;
|
|
261
260
|
},
|
|
262
261
|
|
|
263
|
-
max: function (
|
|
262
|
+
max: function (date) {
|
|
264
263
|
this.c.maxDate = typeof date === 'string'
|
|
265
264
|
? new Date(date)
|
|
266
265
|
: date;
|
|
@@ -271,7 +270,7 @@ $.extend( DateTime.prototype, {
|
|
|
271
270
|
return this;
|
|
272
271
|
},
|
|
273
272
|
|
|
274
|
-
min: function (
|
|
273
|
+
min: function (date) {
|
|
275
274
|
this.c.minDate = typeof date === 'string'
|
|
276
275
|
? new Date(date)
|
|
277
276
|
: date;
|
|
@@ -288,8 +287,8 @@ $.extend( DateTime.prototype, {
|
|
|
288
287
|
* @param {node} node Element to check
|
|
289
288
|
* @return {boolean} true if owned by this control, false otherwise
|
|
290
289
|
*/
|
|
291
|
-
owns: function (
|
|
292
|
-
return $(node).parents().filter(
|
|
290
|
+
owns: function (node) {
|
|
291
|
+
return $(node).parents().filter(this.dom.container).length > 0;
|
|
293
292
|
},
|
|
294
293
|
|
|
295
294
|
/**
|
|
@@ -299,44 +298,44 @@ $.extend( DateTime.prototype, {
|
|
|
299
298
|
* @param {boolean} [write=true] Flag to indicate if the formatted value
|
|
300
299
|
* should be written into the input element
|
|
301
300
|
*/
|
|
302
|
-
val: function (
|
|
303
|
-
if (
|
|
301
|
+
val: function (set, write) {
|
|
302
|
+
if (set === undefined) {
|
|
304
303
|
return this.s.d;
|
|
305
304
|
}
|
|
306
305
|
|
|
307
|
-
if (
|
|
308
|
-
this.s.d = this._dateToUtc(
|
|
306
|
+
if (set instanceof Date) {
|
|
307
|
+
this.s.d = this._dateToUtc(set);
|
|
309
308
|
}
|
|
310
|
-
else if (
|
|
309
|
+
else if (set === null || set === '') {
|
|
311
310
|
this.s.d = null;
|
|
312
311
|
}
|
|
313
|
-
else if (
|
|
312
|
+
else if (set === '--now') {
|
|
314
313
|
this.s.d = this._dateToUtc(new Date());
|
|
315
314
|
}
|
|
316
|
-
else if (
|
|
315
|
+
else if (typeof set === 'string') {
|
|
317
316
|
this.s.d = this._dateToUtc(
|
|
318
317
|
this._convert(set, this.c.format, null)
|
|
319
318
|
);
|
|
320
319
|
}
|
|
321
320
|
|
|
322
|
-
if (
|
|
323
|
-
if (
|
|
321
|
+
if (write || write === undefined) {
|
|
322
|
+
if (this.s.d) {
|
|
324
323
|
this._writeOutput();
|
|
325
324
|
}
|
|
326
325
|
else {
|
|
327
326
|
// The input value was not valid...
|
|
328
|
-
this.dom.input.val(
|
|
327
|
+
this.dom.input.val(set);
|
|
329
328
|
}
|
|
330
329
|
}
|
|
331
330
|
|
|
332
331
|
// Need something to display
|
|
333
332
|
this.s.display = this.s.d
|
|
334
|
-
? new Date(
|
|
333
|
+
? new Date(this.s.d.toString())
|
|
335
334
|
: new Date();
|
|
336
335
|
|
|
337
336
|
// Set the day of the month to be 1 so changing between months doesn't
|
|
338
|
-
|
|
339
|
-
this.s.display.setUTCDate(
|
|
337
|
+
// run into issues when going from day 31 to 28 (for example)
|
|
338
|
+
this.s.display.setUTCDate(1);
|
|
340
339
|
|
|
341
340
|
// Update the display elements for the new value
|
|
342
341
|
this._setTitle();
|
|
@@ -354,7 +353,7 @@ $.extend( DateTime.prototype, {
|
|
|
354
353
|
* @returns
|
|
355
354
|
*/
|
|
356
355
|
valFormat: function (format, val) {
|
|
357
|
-
if (!
|
|
356
|
+
if (!val) {
|
|
358
357
|
return this._convert(this.val(), null, format);
|
|
359
358
|
}
|
|
360
359
|
|
|
@@ -369,7 +368,7 @@ $.extend( DateTime.prototype, {
|
|
|
369
368
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
370
369
|
* Constructor
|
|
371
370
|
*/
|
|
372
|
-
|
|
371
|
+
|
|
373
372
|
/**
|
|
374
373
|
* Build the control and assign initial event handlers
|
|
375
374
|
*
|
|
@@ -384,30 +383,30 @@ $.extend( DateTime.prototype, {
|
|
|
384
383
|
var curr = that.dom.input.val();
|
|
385
384
|
|
|
386
385
|
if (curr !== last) {
|
|
387
|
-
that.c.onChange.call(
|
|
386
|
+
that.c.onChange.call(that, curr, that.s.d, that.dom.input);
|
|
388
387
|
last = curr;
|
|
389
388
|
}
|
|
390
389
|
};
|
|
391
390
|
|
|
392
|
-
if (
|
|
393
|
-
this.dom.date.css(
|
|
391
|
+
if (!this.s.parts.date) {
|
|
392
|
+
this.dom.date.css('display', 'none');
|
|
394
393
|
}
|
|
395
394
|
|
|
396
|
-
if (
|
|
397
|
-
this.dom.time.css(
|
|
395
|
+
if (!this.s.parts.time) {
|
|
396
|
+
this.dom.time.css('display', 'none');
|
|
398
397
|
}
|
|
399
398
|
|
|
400
|
-
if (
|
|
401
|
-
this.dom.time.children('div.'+classPrefix+'-seconds').remove();
|
|
399
|
+
if (!this.s.parts.seconds) {
|
|
400
|
+
this.dom.time.children('div.' + classPrefix + '-seconds').remove();
|
|
402
401
|
this.dom.time.children('span').eq(1).remove();
|
|
403
402
|
}
|
|
404
403
|
|
|
405
|
-
if (
|
|
406
|
-
this.dom.clear.css(
|
|
404
|
+
if (!this.c.buttons.clear) {
|
|
405
|
+
this.dom.clear.css('display', 'none');
|
|
407
406
|
}
|
|
408
407
|
|
|
409
|
-
if (
|
|
410
|
-
this.dom.today.css(
|
|
408
|
+
if (!this.c.buttons.today) {
|
|
409
|
+
this.dom.today.css('display', 'none');
|
|
411
410
|
}
|
|
412
411
|
|
|
413
412
|
// Render the options
|
|
@@ -426,13 +425,13 @@ $.extend( DateTime.prototype, {
|
|
|
426
425
|
this.dom.container.addClass('inline');
|
|
427
426
|
this.c.attachTo = 'input';
|
|
428
427
|
|
|
429
|
-
this.val(
|
|
428
|
+
this.val(this.dom.input.val(), false);
|
|
430
429
|
this._show();
|
|
431
430
|
}
|
|
432
431
|
|
|
433
432
|
// Set the initial value
|
|
434
433
|
if (last) {
|
|
435
|
-
this.val(
|
|
434
|
+
this.val(last, false);
|
|
436
435
|
}
|
|
437
436
|
|
|
438
437
|
// Trigger the display of the widget when clicking or focusing on the
|
|
@@ -441,47 +440,56 @@ $.extend( DateTime.prototype, {
|
|
|
441
440
|
.attr('autocomplete', 'off')
|
|
442
441
|
.on('focus.datetime click.datetime', function () {
|
|
443
442
|
// If already visible - don't do anything
|
|
444
|
-
if (
|
|
443
|
+
if (that.dom.container.is(':visible') || that.dom.input.is(':disabled')) {
|
|
445
444
|
return;
|
|
446
445
|
}
|
|
447
446
|
|
|
448
447
|
// In case the value has changed by text
|
|
449
|
-
that.val(
|
|
448
|
+
that.val(that.dom.input.val(), false);
|
|
450
449
|
|
|
451
450
|
that._show();
|
|
452
|
-
}
|
|
451
|
+
})
|
|
453
452
|
.on('keyup.datetime', function () {
|
|
454
453
|
// Update the calendar's displayed value as the user types
|
|
455
|
-
if (
|
|
456
|
-
that.val(
|
|
454
|
+
if (that.dom.container.is(':visible')) {
|
|
455
|
+
that.val(that.dom.input.val(), false);
|
|
457
456
|
}
|
|
458
|
-
}
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// Want to prevent the focus bubbling up the document to account for
|
|
460
|
+
// focus capture in modals (e.g. Editor and Bootstrap). They can see
|
|
461
|
+
// the focus as outside the modal and thus immediately blur focus on
|
|
462
|
+
// the picker. Need to use a native addEL since jQuery changes the
|
|
463
|
+
// focusin to focus for some reason! focusin bubbles, focus does not.
|
|
464
|
+
this.dom.container[0].addEventListener('focusin', function (e) {
|
|
465
|
+
e.stopPropagation();
|
|
466
|
+
});
|
|
459
467
|
|
|
460
468
|
// Main event handlers for input in the widget
|
|
461
469
|
this.dom.container
|
|
462
|
-
.on(
|
|
470
|
+
.on('change', 'select', function () {
|
|
463
471
|
var select = $(this);
|
|
464
472
|
var val = select.val();
|
|
465
473
|
|
|
466
|
-
if (
|
|
474
|
+
if (select.hasClass(classPrefix + '-month')) {
|
|
467
475
|
// Month select
|
|
468
|
-
that._correctMonth(
|
|
476
|
+
that._correctMonth(that.s.display, val);
|
|
469
477
|
that._setTitle();
|
|
470
478
|
that._setCalander();
|
|
471
479
|
}
|
|
472
|
-
else if (
|
|
480
|
+
else if (select.hasClass(classPrefix + '-year')) {
|
|
473
481
|
// Year select
|
|
474
|
-
that.s.display.setUTCFullYear(
|
|
482
|
+
that.s.display.setUTCFullYear(val);
|
|
475
483
|
that._setTitle();
|
|
476
484
|
that._setCalander();
|
|
477
485
|
}
|
|
478
|
-
else if (
|
|
486
|
+
else if (select.hasClass(classPrefix + '-hours') || select.hasClass(classPrefix + '-ampm')) {
|
|
479
487
|
// Hours - need to take account of AM/PM input if present
|
|
480
|
-
if (
|
|
481
|
-
var hours = $(that.dom.container).find('.'+classPrefix+'-hours').val() * 1;
|
|
482
|
-
var pm = $(that.dom.container).find('.'+classPrefix+'-ampm').val() === 'pm';
|
|
488
|
+
if (that.s.parts.hours12) {
|
|
489
|
+
var hours = $(that.dom.container).find('.' + classPrefix + '-hours').val() * 1;
|
|
490
|
+
var pm = $(that.dom.container).find('.' + classPrefix + '-ampm').val() === 'pm';
|
|
483
491
|
|
|
484
|
-
that.s.d.setUTCHours(
|
|
492
|
+
that.s.d.setUTCHours(hours === 12 && !pm ?
|
|
485
493
|
0 :
|
|
486
494
|
pm && hours !== 12 ?
|
|
487
495
|
hours + 12 :
|
|
@@ -489,35 +497,35 @@ $.extend( DateTime.prototype, {
|
|
|
489
497
|
);
|
|
490
498
|
}
|
|
491
499
|
else {
|
|
492
|
-
that.s.d.setUTCHours(
|
|
500
|
+
that.s.d.setUTCHours(val);
|
|
493
501
|
}
|
|
494
502
|
|
|
495
503
|
that._setTime();
|
|
496
|
-
that._writeOutput(
|
|
504
|
+
that._writeOutput(true);
|
|
497
505
|
|
|
498
506
|
onChange();
|
|
499
507
|
}
|
|
500
|
-
else if (
|
|
508
|
+
else if (select.hasClass(classPrefix + '-minutes')) {
|
|
501
509
|
// Minutes select
|
|
502
|
-
that.s.d.setUTCMinutes(
|
|
510
|
+
that.s.d.setUTCMinutes(val);
|
|
503
511
|
that._setTime();
|
|
504
|
-
that._writeOutput(
|
|
512
|
+
that._writeOutput(true);
|
|
505
513
|
|
|
506
514
|
onChange();
|
|
507
515
|
}
|
|
508
|
-
else if (
|
|
516
|
+
else if (select.hasClass(classPrefix + '-seconds')) {
|
|
509
517
|
// Seconds select
|
|
510
|
-
that.s.d.setSeconds(
|
|
518
|
+
that.s.d.setSeconds(val);
|
|
511
519
|
that._setTime();
|
|
512
|
-
that._writeOutput(
|
|
520
|
+
that._writeOutput(true);
|
|
513
521
|
|
|
514
522
|
onChange();
|
|
515
523
|
}
|
|
516
524
|
|
|
517
525
|
that.dom.input.focus();
|
|
518
526
|
that._position();
|
|
519
|
-
}
|
|
520
|
-
.on(
|
|
527
|
+
})
|
|
528
|
+
.on('click', function (e) {
|
|
521
529
|
var d = that.s.d;
|
|
522
530
|
var nodeName = e.target.nodeName.toLowerCase();
|
|
523
531
|
var target = nodeName === 'span' ?
|
|
@@ -526,16 +534,16 @@ $.extend( DateTime.prototype, {
|
|
|
526
534
|
|
|
527
535
|
nodeName = target.nodeName.toLowerCase();
|
|
528
536
|
|
|
529
|
-
if (
|
|
537
|
+
if (nodeName === 'select') {
|
|
530
538
|
return;
|
|
531
539
|
}
|
|
532
540
|
|
|
533
541
|
e.stopPropagation();
|
|
534
542
|
|
|
535
|
-
if (
|
|
543
|
+
if (nodeName === 'a') {
|
|
536
544
|
e.preventDefault();
|
|
537
545
|
|
|
538
|
-
if ($(target).hasClass(classPrefix+'-clear')) {
|
|
546
|
+
if ($(target).hasClass(classPrefix + '-clear')) {
|
|
539
547
|
// Clear the value and don't change the display
|
|
540
548
|
that.s.d = null;
|
|
541
549
|
that.dom.input.val('');
|
|
@@ -545,7 +553,7 @@ $.extend( DateTime.prototype, {
|
|
|
545
553
|
|
|
546
554
|
onChange();
|
|
547
555
|
}
|
|
548
|
-
else if ($(target).hasClass(classPrefix+'-today')) {
|
|
556
|
+
else if ($(target).hasClass(classPrefix + '-today')) {
|
|
549
557
|
// Don't change the value, but jump to the month
|
|
550
558
|
// containing today
|
|
551
559
|
that.s.display = new Date();
|
|
@@ -554,39 +562,39 @@ $.extend( DateTime.prototype, {
|
|
|
554
562
|
that._setCalander();
|
|
555
563
|
}
|
|
556
564
|
}
|
|
557
|
-
if (
|
|
565
|
+
if (nodeName === 'button') {
|
|
558
566
|
var button = $(target);
|
|
559
567
|
var parent = button.parent();
|
|
560
568
|
|
|
561
|
-
if (
|
|
569
|
+
if (parent.hasClass('disabled') && !parent.hasClass('range')) {
|
|
562
570
|
button.blur();
|
|
563
571
|
return;
|
|
564
572
|
}
|
|
565
573
|
|
|
566
|
-
if (
|
|
574
|
+
if (parent.hasClass(classPrefix + '-iconLeft')) {
|
|
567
575
|
// Previous month
|
|
568
|
-
that.s.display.setUTCMonth(
|
|
576
|
+
that.s.display.setUTCMonth(that.s.display.getUTCMonth() - 1);
|
|
569
577
|
that._setTitle();
|
|
570
578
|
that._setCalander();
|
|
571
579
|
|
|
572
580
|
that.dom.input.focus();
|
|
573
581
|
}
|
|
574
|
-
else if (
|
|
582
|
+
else if (parent.hasClass(classPrefix + '-iconRight')) {
|
|
575
583
|
// Next month
|
|
576
|
-
that._correctMonth(
|
|
584
|
+
that._correctMonth(that.s.display, that.s.display.getUTCMonth() + 1);
|
|
577
585
|
that._setTitle();
|
|
578
586
|
that._setCalander();
|
|
579
587
|
|
|
580
588
|
that.dom.input.focus();
|
|
581
589
|
}
|
|
582
|
-
else if (
|
|
590
|
+
else if (button.parents('.' + classPrefix + '-time').length) {
|
|
583
591
|
var val = button.data('value');
|
|
584
592
|
var unit = button.data('unit');
|
|
585
593
|
|
|
586
594
|
d = that._needValue();
|
|
587
595
|
|
|
588
|
-
if (
|
|
589
|
-
if (
|
|
596
|
+
if (unit === 'minutes') {
|
|
597
|
+
if (parent.hasClass('disabled') && parent.hasClass('range')) {
|
|
590
598
|
that.s.minutesRange = val;
|
|
591
599
|
that._setTime();
|
|
592
600
|
return;
|
|
@@ -596,8 +604,8 @@ $.extend( DateTime.prototype, {
|
|
|
596
604
|
}
|
|
597
605
|
}
|
|
598
606
|
|
|
599
|
-
if (
|
|
600
|
-
if (
|
|
607
|
+
if (unit === 'seconds') {
|
|
608
|
+
if (parent.hasClass('disabled') && parent.hasClass('range')) {
|
|
601
609
|
that.s.secondsRange = val;
|
|
602
610
|
that._setTime();
|
|
603
611
|
return;
|
|
@@ -608,16 +616,16 @@ $.extend( DateTime.prototype, {
|
|
|
608
616
|
}
|
|
609
617
|
|
|
610
618
|
// Specific to hours for 12h clock
|
|
611
|
-
if (
|
|
612
|
-
if (
|
|
619
|
+
if (val === 'am') {
|
|
620
|
+
if (d.getUTCHours() >= 12) {
|
|
613
621
|
val = d.getUTCHours() - 12;
|
|
614
622
|
}
|
|
615
623
|
else {
|
|
616
624
|
return;
|
|
617
625
|
}
|
|
618
626
|
}
|
|
619
|
-
else if (
|
|
620
|
-
if (
|
|
627
|
+
else if (val === 'pm') {
|
|
628
|
+
if (d.getUTCHours() < 12) {
|
|
621
629
|
val = d.getUTCHours() + 12;
|
|
622
630
|
}
|
|
623
631
|
else {
|
|
@@ -631,10 +639,10 @@ $.extend( DateTime.prototype, {
|
|
|
631
639
|
'setUTCMinutes' :
|
|
632
640
|
'setSeconds';
|
|
633
641
|
|
|
634
|
-
d[set](
|
|
642
|
+
d[set](val);
|
|
635
643
|
that._setCalander();
|
|
636
644
|
that._setTime();
|
|
637
|
-
that._writeOutput(
|
|
645
|
+
that._writeOutput(true);
|
|
638
646
|
onChange();
|
|
639
647
|
}
|
|
640
648
|
else {
|
|
@@ -646,23 +654,23 @@ $.extend( DateTime.prototype, {
|
|
|
646
654
|
// new day will exist in the old month, But 1 always
|
|
647
655
|
// does, so we can change the month without worry of a
|
|
648
656
|
// recalculation being done automatically by `Date`
|
|
649
|
-
d.setUTCDate(
|
|
650
|
-
d.setUTCFullYear(
|
|
651
|
-
d.setUTCMonth(
|
|
652
|
-
d.setUTCDate(
|
|
657
|
+
d.setUTCDate(1);
|
|
658
|
+
d.setUTCFullYear(button.data('year'));
|
|
659
|
+
d.setUTCMonth(button.data('month'));
|
|
660
|
+
d.setUTCDate(button.data('day'));
|
|
653
661
|
|
|
654
|
-
that._writeOutput(
|
|
662
|
+
that._writeOutput(true);
|
|
655
663
|
|
|
656
664
|
// Don't hide if there is a time picker, since we want to
|
|
657
665
|
// be able to select a time as well.
|
|
658
|
-
if (
|
|
666
|
+
if (!that.s.parts.time) {
|
|
659
667
|
// This is annoying but IE has some kind of async
|
|
660
668
|
// behaviour with focus and the focus from the above
|
|
661
669
|
// write would occur after this hide - resulting in the
|
|
662
670
|
// calendar opening immediately
|
|
663
|
-
setTimeout(
|
|
671
|
+
setTimeout(function () {
|
|
664
672
|
that._hide();
|
|
665
|
-
}, 10
|
|
673
|
+
}, 10);
|
|
666
674
|
}
|
|
667
675
|
else {
|
|
668
676
|
that._setCalander();
|
|
@@ -677,7 +685,7 @@ $.extend( DateTime.prototype, {
|
|
|
677
685
|
// input element
|
|
678
686
|
that.dom.input.focus();
|
|
679
687
|
}
|
|
680
|
-
}
|
|
688
|
+
});
|
|
681
689
|
},
|
|
682
690
|
|
|
683
691
|
|
|
@@ -693,7 +701,7 @@ $.extend( DateTime.prototype, {
|
|
|
693
701
|
* @param {Date} b Date 2
|
|
694
702
|
* @private
|
|
695
703
|
*/
|
|
696
|
-
_compareDates: function(
|
|
704
|
+
_compareDates: function (a, b) {
|
|
697
705
|
// Can't use toDateString as that converts to local time
|
|
698
706
|
// luxon uses different method names so need to be able to call them
|
|
699
707
|
return this._isLuxon()
|
|
@@ -709,29 +717,29 @@ $.extend( DateTime.prototype, {
|
|
|
709
717
|
* @param {string|null} to Format to convert to. If null a `Date` will be returned
|
|
710
718
|
* @returns {string|Date} Converted value
|
|
711
719
|
*/
|
|
712
|
-
_convert: function(val, from, to) {
|
|
713
|
-
if (!
|
|
720
|
+
_convert: function (val, from, to) {
|
|
721
|
+
if (!val) {
|
|
714
722
|
return val;
|
|
715
723
|
}
|
|
716
724
|
|
|
717
|
-
if (!
|
|
725
|
+
if (!dateLib) {
|
|
718
726
|
// Note that in here from and to can either be null or YYYY-MM-DD
|
|
719
727
|
// They cannot be anything else
|
|
720
|
-
if ((!
|
|
728
|
+
if ((!from && !to) || (from && to)) {
|
|
721
729
|
// No conversion
|
|
722
730
|
return val;
|
|
723
731
|
}
|
|
724
|
-
else if (!
|
|
732
|
+
else if (!from) {
|
|
725
733
|
// Date in, string back
|
|
726
|
-
return val.getUTCFullYear() +'-'+
|
|
727
|
-
this._pad(val.getUTCMonth() + 1) +'-'+
|
|
734
|
+
return val.getUTCFullYear() + '-' +
|
|
735
|
+
this._pad(val.getUTCMonth() + 1) + '-' +
|
|
728
736
|
this._pad(val.getUTCDate());
|
|
729
737
|
}
|
|
730
738
|
else { // (! to)
|
|
731
739
|
// String in, date back
|
|
732
|
-
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/
|
|
740
|
+
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/);
|
|
733
741
|
return match ?
|
|
734
|
-
new Date(
|
|
742
|
+
new Date(match[1], match[2] - 1, match[3]) :
|
|
735
743
|
null;
|
|
736
744
|
}
|
|
737
745
|
}
|
|
@@ -741,7 +749,7 @@ $.extend( DateTime.prototype, {
|
|
|
741
749
|
? dateLib.DateTime.fromJSDate(val).toUTC()
|
|
742
750
|
: dateLib.DateTime.fromFormat(val, from);
|
|
743
751
|
|
|
744
|
-
if (!
|
|
752
|
+
if (!dtLux.isValid) {
|
|
745
753
|
return null;
|
|
746
754
|
}
|
|
747
755
|
|
|
@@ -752,10 +760,10 @@ $.extend( DateTime.prototype, {
|
|
|
752
760
|
else {
|
|
753
761
|
// Moment / DayJS
|
|
754
762
|
var dtMo = val instanceof Date
|
|
755
|
-
? dateLib.utc(
|
|
756
|
-
: dateLib(
|
|
757
|
-
|
|
758
|
-
if (!
|
|
763
|
+
? dateLib.utc(val, undefined, this.c.locale, this.c.strict)
|
|
764
|
+
: dateLib(val, from, this.c.locale, this.c.strict);
|
|
765
|
+
|
|
766
|
+
if (!dtMo.isValid()) {
|
|
759
767
|
return null;
|
|
760
768
|
}
|
|
761
769
|
|
|
@@ -775,15 +783,15 @@ $.extend( DateTime.prototype, {
|
|
|
775
783
|
* @param {integer} month Month to set
|
|
776
784
|
* @private
|
|
777
785
|
*/
|
|
778
|
-
_correctMonth: function (
|
|
779
|
-
var days = this._daysInMonth(
|
|
786
|
+
_correctMonth: function (date, month) {
|
|
787
|
+
var days = this._daysInMonth(date.getUTCFullYear(), month);
|
|
780
788
|
var correctDays = date.getUTCDate() > days;
|
|
781
789
|
|
|
782
|
-
date.setUTCMonth(
|
|
790
|
+
date.setUTCMonth(month);
|
|
783
791
|
|
|
784
|
-
if (
|
|
785
|
-
date.setUTCDate(
|
|
786
|
-
date.setUTCMonth(
|
|
792
|
+
if (correctDays) {
|
|
793
|
+
date.setUTCDate(days);
|
|
794
|
+
date.setUTCMonth(month);
|
|
787
795
|
}
|
|
788
796
|
},
|
|
789
797
|
|
|
@@ -795,7 +803,7 @@ $.extend( DateTime.prototype, {
|
|
|
795
803
|
* @param {integer} month Month (starting at 0)
|
|
796
804
|
* @private
|
|
797
805
|
*/
|
|
798
|
-
_daysInMonth: function (
|
|
806
|
+
_daysInMonth: function (year, month) {
|
|
799
807
|
//
|
|
800
808
|
var isLeap = ((year % 4) === 0 && ((year % 100) !== 0 || (year % 400) === 0));
|
|
801
809
|
var months = [31, (isLeap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
@@ -811,15 +819,15 @@ $.extend( DateTime.prototype, {
|
|
|
811
819
|
* @param {Date} s Date to "convert"
|
|
812
820
|
* @return {Date} Shifted date
|
|
813
821
|
*/
|
|
814
|
-
_dateToUtc: function (
|
|
815
|
-
if (!
|
|
822
|
+
_dateToUtc: function (s) {
|
|
823
|
+
if (!s) {
|
|
816
824
|
return s;
|
|
817
825
|
}
|
|
818
826
|
|
|
819
|
-
return new Date(
|
|
827
|
+
return new Date(Date.UTC(
|
|
820
828
|
s.getFullYear(), s.getMonth(), s.getDate(),
|
|
821
829
|
s.getHours(), s.getMinutes(), s.getSeconds()
|
|
822
|
-
)
|
|
830
|
+
));
|
|
823
831
|
},
|
|
824
832
|
|
|
825
833
|
/**
|
|
@@ -828,13 +836,13 @@ $.extend( DateTime.prototype, {
|
|
|
828
836
|
* @param {Date} d Date to "convert"
|
|
829
837
|
* @return {string} ISO formatted date
|
|
830
838
|
*/
|
|
831
|
-
_dateToUtcString: function (
|
|
839
|
+
_dateToUtcString: function (d) {
|
|
832
840
|
// luxon uses different method names so need to be able to call them
|
|
833
841
|
return this._isLuxon()
|
|
834
842
|
? dateLib.DateTime.fromJSDate(d).toUTC().toISODate()
|
|
835
|
-
: d.getUTCFullYear()+'-'+
|
|
836
|
-
|
|
837
|
-
|
|
843
|
+
: d.getUTCFullYear() + '-' +
|
|
844
|
+
this._pad(d.getUTCMonth() + 1) + '-' +
|
|
845
|
+
this._pad(d.getUTCDate());
|
|
838
846
|
},
|
|
839
847
|
|
|
840
848
|
/**
|
|
@@ -843,7 +851,7 @@ $.extend( DateTime.prototype, {
|
|
|
843
851
|
* @private
|
|
844
852
|
*/
|
|
845
853
|
_hide: function (destroy) {
|
|
846
|
-
if (!
|
|
854
|
+
if (!destroy && this.dom.input.attr('type') === 'hidden') {
|
|
847
855
|
return;
|
|
848
856
|
}
|
|
849
857
|
|
|
@@ -851,12 +859,12 @@ $.extend( DateTime.prototype, {
|
|
|
851
859
|
|
|
852
860
|
this.dom.container.detach();
|
|
853
861
|
|
|
854
|
-
$(window).off(
|
|
855
|
-
$(document).off(
|
|
856
|
-
$('div.dataTables_scrollBody').off(
|
|
857
|
-
$('div.DTE_Body_Content').off(
|
|
858
|
-
$('body').off(
|
|
859
|
-
$(this.dom.input[0].offsetParent).off('.'+namespace);
|
|
862
|
+
$(window).off('.' + namespace);
|
|
863
|
+
$(document).off('keydown.' + namespace);
|
|
864
|
+
$('div.dataTables_scrollBody').off('scroll.' + namespace);
|
|
865
|
+
$('div.DTE_Body_Content').off('scroll.' + namespace);
|
|
866
|
+
$('body').off('click.' + namespace);
|
|
867
|
+
$(this.dom.input[0].offsetParent).off('.' + namespace);
|
|
860
868
|
},
|
|
861
869
|
|
|
862
870
|
/**
|
|
@@ -866,7 +874,7 @@ $.extend( DateTime.prototype, {
|
|
|
866
874
|
* @return {integer} 12 hour value
|
|
867
875
|
* @private
|
|
868
876
|
*/
|
|
869
|
-
_hours24To12: function (
|
|
877
|
+
_hours24To12: function (val) {
|
|
870
878
|
return val === 0 ?
|
|
871
879
|
12 :
|
|
872
880
|
val > 12 ?
|
|
@@ -882,31 +890,30 @@ $.extend( DateTime.prototype, {
|
|
|
882
890
|
* @param {object} day Day object from the `_htmlMonth` method
|
|
883
891
|
* @return {string} HTML cell
|
|
884
892
|
*/
|
|
885
|
-
_htmlDay: function(
|
|
886
|
-
|
|
887
|
-
if ( day.empty ) {
|
|
893
|
+
_htmlDay: function (day) {
|
|
894
|
+
if (day.empty) {
|
|
888
895
|
return '<td class="empty"></td>';
|
|
889
896
|
}
|
|
890
897
|
|
|
891
|
-
var classes = [
|
|
898
|
+
var classes = ['selectable'];
|
|
892
899
|
var classPrefix = this.c.classPrefix;
|
|
893
900
|
|
|
894
|
-
if (
|
|
895
|
-
classes.push(
|
|
901
|
+
if (day.disabled) {
|
|
902
|
+
classes.push('disabled');
|
|
896
903
|
}
|
|
897
904
|
|
|
898
|
-
if (
|
|
899
|
-
classes.push(
|
|
905
|
+
if (day.today) {
|
|
906
|
+
classes.push('now');
|
|
900
907
|
}
|
|
901
908
|
|
|
902
|
-
if (
|
|
903
|
-
classes.push(
|
|
909
|
+
if (day.selected) {
|
|
910
|
+
classes.push('selected');
|
|
904
911
|
}
|
|
905
912
|
|
|
906
913
|
return '<td data-day="' + day.day + '" class="' + classes.join(' ') + '">' +
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
914
|
+
'<button class="' + classPrefix + '-button ' + classPrefix + '-day" type="button" ' + 'data-year="' + day.year + '" data-month="' + day.month + '" data-day="' + day.day + '">' +
|
|
915
|
+
'<span>' + day.day + '</span>' +
|
|
916
|
+
'</button>' +
|
|
910
917
|
'</td>';
|
|
911
918
|
},
|
|
912
919
|
|
|
@@ -923,14 +930,14 @@ $.extend( DateTime.prototype, {
|
|
|
923
930
|
* @return {string} Calendar month HTML
|
|
924
931
|
* @private
|
|
925
932
|
*/
|
|
926
|
-
_htmlMonth: function (
|
|
927
|
-
var now
|
|
928
|
-
days
|
|
929
|
-
before = new Date(
|
|
930
|
-
data
|
|
931
|
-
row
|
|
932
|
-
|
|
933
|
-
if (
|
|
933
|
+
_htmlMonth: function (year, month) {
|
|
934
|
+
var now = this._dateToUtc(new Date()),
|
|
935
|
+
days = this._daysInMonth(year, month),
|
|
936
|
+
before = new Date(Date.UTC(year, month, 1)).getUTCDay(),
|
|
937
|
+
data = [],
|
|
938
|
+
row = [];
|
|
939
|
+
|
|
940
|
+
if (this.c.firstDay > 0) {
|
|
934
941
|
before -= this.c.firstDay;
|
|
935
942
|
|
|
936
943
|
if (before < 0) {
|
|
@@ -941,7 +948,7 @@ $.extend( DateTime.prototype, {
|
|
|
941
948
|
var cells = days + before,
|
|
942
949
|
after = cells;
|
|
943
950
|
|
|
944
|
-
while (
|
|
951
|
+
while (after > 7) {
|
|
945
952
|
after -= 7;
|
|
946
953
|
}
|
|
947
954
|
|
|
@@ -950,85 +957,85 @@ $.extend( DateTime.prototype, {
|
|
|
950
957
|
var minDate = this.c.minDate;
|
|
951
958
|
var maxDate = this.c.maxDate;
|
|
952
959
|
|
|
953
|
-
if (
|
|
960
|
+
if (minDate) {
|
|
954
961
|
minDate.setUTCHours(0);
|
|
955
962
|
minDate.setUTCMinutes(0);
|
|
956
963
|
minDate.setSeconds(0);
|
|
957
964
|
}
|
|
958
965
|
|
|
959
|
-
if (
|
|
966
|
+
if (maxDate) {
|
|
960
967
|
maxDate.setUTCHours(23);
|
|
961
968
|
maxDate.setUTCMinutes(59);
|
|
962
969
|
maxDate.setSeconds(59);
|
|
963
970
|
}
|
|
964
971
|
|
|
965
|
-
for (
|
|
966
|
-
var day
|
|
972
|
+
for (var i = 0, r = 0; i < cells; i++) {
|
|
973
|
+
var day = new Date(Date.UTC(year, month, 1 + (i - before))),
|
|
967
974
|
selected = this.s.d ? this._compareDates(day, this.s.d) : false,
|
|
968
|
-
today
|
|
969
|
-
empty
|
|
975
|
+
today = this._compareDates(day, now),
|
|
976
|
+
empty = i < before || i >= (days + before),
|
|
970
977
|
disabled = (minDate && day < minDate) ||
|
|
971
|
-
|
|
978
|
+
(maxDate && day > maxDate);
|
|
972
979
|
|
|
973
980
|
var disableDays = this.c.disableDays;
|
|
974
|
-
if (
|
|
981
|
+
if (Array.isArray(disableDays) && $.inArray(day.getUTCDay(), disableDays) !== -1) {
|
|
975
982
|
disabled = true;
|
|
976
983
|
}
|
|
977
|
-
else if (
|
|
984
|
+
else if (typeof disableDays === 'function' && disableDays(day) === true) {
|
|
978
985
|
disabled = true;
|
|
979
986
|
}
|
|
980
987
|
|
|
981
988
|
var dayConfig = {
|
|
982
|
-
day:
|
|
983
|
-
month:
|
|
984
|
-
year:
|
|
989
|
+
day: 1 + (i - before),
|
|
990
|
+
month: month,
|
|
991
|
+
year: year,
|
|
985
992
|
selected: selected,
|
|
986
|
-
today:
|
|
993
|
+
today: today,
|
|
987
994
|
disabled: disabled,
|
|
988
|
-
empty:
|
|
995
|
+
empty: empty
|
|
989
996
|
};
|
|
990
997
|
|
|
991
|
-
row.push(
|
|
998
|
+
row.push(this._htmlDay(dayConfig));
|
|
992
999
|
|
|
993
|
-
if (
|
|
994
|
-
if (
|
|
995
|
-
row.unshift(
|
|
1000
|
+
if (++r === 7) {
|
|
1001
|
+
if (this.c.showWeekNumber) {
|
|
1002
|
+
row.unshift(this._htmlWeekOfYear(i - before, month, year));
|
|
996
1003
|
}
|
|
997
1004
|
|
|
998
|
-
data.push(
|
|
1005
|
+
data.push('<tr>' + row.join('') + '</tr>');
|
|
999
1006
|
row = [];
|
|
1000
1007
|
r = 0;
|
|
1001
1008
|
}
|
|
1002
1009
|
}
|
|
1003
1010
|
|
|
1004
1011
|
var classPrefix = this.c.classPrefix;
|
|
1005
|
-
var className = classPrefix+'-table';
|
|
1006
|
-
if (
|
|
1012
|
+
var className = classPrefix + '-table';
|
|
1013
|
+
if (this.c.showWeekNumber) {
|
|
1007
1014
|
className += ' weekNumber';
|
|
1008
1015
|
}
|
|
1009
1016
|
|
|
1010
1017
|
// Show / hide month icons based on min/max
|
|
1011
|
-
if (
|
|
1012
|
-
var underMin = minDate >= new Date(
|
|
1018
|
+
if (minDate) {
|
|
1019
|
+
var underMin = minDate >= new Date(Date.UTC(year, month, 1, 0, 0, 0));
|
|
1013
1020
|
|
|
1014
|
-
this.dom.title.find('div.'+classPrefix+'-iconLeft')
|
|
1015
|
-
.css(
|
|
1021
|
+
this.dom.title.find('div.' + classPrefix + '-iconLeft')
|
|
1022
|
+
.css('display', underMin ? 'none' : 'block');
|
|
1016
1023
|
}
|
|
1017
1024
|
|
|
1018
|
-
if (
|
|
1019
|
-
var overMax = maxDate < new Date(
|
|
1025
|
+
if (maxDate) {
|
|
1026
|
+
var overMax = maxDate < new Date(Date.UTC(year, month + 1, 1, 0, 0, 0));
|
|
1020
1027
|
|
|
1021
|
-
this.dom.title.find('div.'+classPrefix+'-iconRight')
|
|
1022
|
-
.css(
|
|
1028
|
+
this.dom.title.find('div.' + classPrefix + '-iconRight')
|
|
1029
|
+
.css('display', overMax ? 'none' : 'block');
|
|
1023
1030
|
}
|
|
1024
1031
|
|
|
1025
|
-
return '<table class="'+className+'">' +
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
+
return '<table class="' + className + '">' +
|
|
1033
|
+
'<thead>' +
|
|
1034
|
+
this._htmlMonthHead() +
|
|
1035
|
+
'</thead>' +
|
|
1036
|
+
'<tbody>' +
|
|
1037
|
+
data.join('') +
|
|
1038
|
+
'</tbody>' +
|
|
1032
1039
|
'</table>';
|
|
1033
1040
|
},
|
|
1034
1041
|
|
|
@@ -1044,7 +1051,7 @@ $.extend( DateTime.prototype, {
|
|
|
1044
1051
|
var i18n = this.c.i18n;
|
|
1045
1052
|
|
|
1046
1053
|
// Take account of the first day shift
|
|
1047
|
-
var dayName = function (
|
|
1054
|
+
var dayName = function (day) {
|
|
1048
1055
|
day += firstDay;
|
|
1049
1056
|
|
|
1050
1057
|
while (day >= 7) {
|
|
@@ -1053,14 +1060,14 @@ $.extend( DateTime.prototype, {
|
|
|
1053
1060
|
|
|
1054
1061
|
return i18n.weekdays[day];
|
|
1055
1062
|
};
|
|
1056
|
-
|
|
1063
|
+
|
|
1057
1064
|
// Empty cell in the header
|
|
1058
|
-
if (
|
|
1059
|
-
a.push(
|
|
1065
|
+
if (this.c.showWeekNumber) {
|
|
1066
|
+
a.push('<th></th>');
|
|
1060
1067
|
}
|
|
1061
1068
|
|
|
1062
|
-
for (
|
|
1063
|
-
a.push(
|
|
1069
|
+
for (var i = 0; i < 7; i++) {
|
|
1070
|
+
a.push('<th>' + dayName(i) + '</th>');
|
|
1064
1071
|
}
|
|
1065
1072
|
|
|
1066
1073
|
return a.join('');
|
|
@@ -1078,16 +1085,16 @@ $.extend( DateTime.prototype, {
|
|
|
1078
1085
|
* @return {string}
|
|
1079
1086
|
* @private
|
|
1080
1087
|
*/
|
|
1081
|
-
_htmlWeekOfYear: function (
|
|
1082
|
-
var date = new Date(
|
|
1088
|
+
_htmlWeekOfYear: function (d, m, y) {
|
|
1089
|
+
var date = new Date(y, m, d, 0, 0, 0, 0);
|
|
1083
1090
|
|
|
1084
1091
|
// First week of the year always has 4th January in it
|
|
1085
|
-
date.setDate(
|
|
1092
|
+
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
|
|
1086
1093
|
|
|
1087
|
-
var oneJan = new Date(
|
|
1088
|
-
var weekNum = Math.ceil(
|
|
1094
|
+
var oneJan = new Date(y, 0, 1);
|
|
1095
|
+
var weekNum = Math.ceil((((date - oneJan) / 86400000) + 1) / 7);
|
|
1089
1096
|
|
|
1090
|
-
return '<td class="'+this.c.classPrefix+'-week">' + weekNum + '</td>';
|
|
1097
|
+
return '<td class="' + this.c.classPrefix + '-week">' + weekNum + '</td>';
|
|
1091
1098
|
},
|
|
1092
1099
|
|
|
1093
1100
|
/**
|
|
@@ -1108,10 +1115,10 @@ $.extend( DateTime.prototype, {
|
|
|
1108
1115
|
* @private
|
|
1109
1116
|
*/
|
|
1110
1117
|
_needValue: function () {
|
|
1111
|
-
if (
|
|
1112
|
-
this.s.d = this._dateToUtc(
|
|
1118
|
+
if (!this.s.d) {
|
|
1119
|
+
this.s.d = this._dateToUtc(new Date());
|
|
1113
1120
|
|
|
1114
|
-
if (!
|
|
1121
|
+
if (!this.s.parts.time) {
|
|
1115
1122
|
this.s.d.setUTCHours(0);
|
|
1116
1123
|
this.s.d.setUTCMinutes(0);
|
|
1117
1124
|
this.s.d.setSeconds(0);
|
|
@@ -1131,16 +1138,16 @@ $.extend( DateTime.prototype, {
|
|
|
1131
1138
|
* length as the values parameter.
|
|
1132
1139
|
* @private
|
|
1133
1140
|
*/
|
|
1134
|
-
_options: function (
|
|
1135
|
-
if (
|
|
1141
|
+
_options: function (selector, values, labels) {
|
|
1142
|
+
if (!labels) {
|
|
1136
1143
|
labels = values;
|
|
1137
1144
|
}
|
|
1138
1145
|
|
|
1139
|
-
var select = this.dom.container.find('select.'+this.c.classPrefix+'-'+selector);
|
|
1146
|
+
var select = this.dom.container.find('select.' + this.c.classPrefix + '-' + selector);
|
|
1140
1147
|
select.empty();
|
|
1141
1148
|
|
|
1142
|
-
for (
|
|
1143
|
-
select.append(
|
|
1149
|
+
for (var i = 0, ien = values.length; i < ien; i++) {
|
|
1150
|
+
select.append('<option value="' + values[i] + '">' + labels[i] + '</option>');
|
|
1144
1151
|
}
|
|
1145
1152
|
},
|
|
1146
1153
|
|
|
@@ -1152,14 +1159,14 @@ $.extend( DateTime.prototype, {
|
|
|
1152
1159
|
* @param {*} val Value to set
|
|
1153
1160
|
* @private
|
|
1154
1161
|
*/
|
|
1155
|
-
_optionSet: function (
|
|
1156
|
-
var select = this.dom.container.find('select.'+this.c.classPrefix+'-'+selector);
|
|
1162
|
+
_optionSet: function (selector, val) {
|
|
1163
|
+
var select = this.dom.container.find('select.' + this.c.classPrefix + '-' + selector);
|
|
1157
1164
|
var span = select.parent().children('span');
|
|
1158
1165
|
|
|
1159
|
-
select.val(
|
|
1166
|
+
select.val(val);
|
|
1160
1167
|
|
|
1161
1168
|
var selected = select.find('option:selected');
|
|
1162
|
-
span.html(
|
|
1169
|
+
span.html(selected.length !== 0 ?
|
|
1163
1170
|
selected.text() :
|
|
1164
1171
|
this.c.i18n.unknown
|
|
1165
1172
|
);
|
|
@@ -1175,18 +1182,17 @@ $.extend( DateTime.prototype, {
|
|
|
1175
1182
|
* @param {integer} range Override range
|
|
1176
1183
|
* @private
|
|
1177
1184
|
*/
|
|
1178
|
-
_optionsTime: function (
|
|
1185
|
+
_optionsTime: function (unit, count, val, allowed, range) {
|
|
1179
1186
|
var classPrefix = this.c.classPrefix;
|
|
1180
|
-
var container = this.dom.container.find('div.'+classPrefix+'-'+unit);
|
|
1187
|
+
var container = this.dom.container.find('div.' + classPrefix + '-' + unit);
|
|
1181
1188
|
var i, j;
|
|
1182
1189
|
var render = count === 12 ?
|
|
1183
1190
|
function (i) { return i; } :
|
|
1184
1191
|
this._pad;
|
|
1185
|
-
var
|
|
1186
|
-
var className = classPrefix+'-table';
|
|
1192
|
+
var className = classPrefix + '-table';
|
|
1187
1193
|
var i18n = this.c.i18n;
|
|
1188
1194
|
|
|
1189
|
-
if (
|
|
1195
|
+
if (!container.length) {
|
|
1190
1196
|
return;
|
|
1191
1197
|
}
|
|
1192
1198
|
|
|
@@ -1194,8 +1200,8 @@ $.extend( DateTime.prototype, {
|
|
|
1194
1200
|
var span = 10;
|
|
1195
1201
|
var button = function (value, label, className) {
|
|
1196
1202
|
// Shift the value for PM
|
|
1197
|
-
if (
|
|
1198
|
-
if (val >= 12
|
|
1203
|
+
if (count === 12 && typeof value === 'number') {
|
|
1204
|
+
if (val >= 12) {
|
|
1199
1205
|
value += 12;
|
|
1200
1206
|
}
|
|
1201
1207
|
|
|
@@ -1210,27 +1216,27 @@ $.extend( DateTime.prototype, {
|
|
|
1210
1216
|
var selected = val === value || (value === 'am' && val < 12) || (value === 'pm' && val >= 12) ?
|
|
1211
1217
|
'selected' :
|
|
1212
1218
|
'';
|
|
1213
|
-
|
|
1219
|
+
|
|
1214
1220
|
if (typeof value === 'number' && allowed && $.inArray(value, allowed) === -1) {
|
|
1215
1221
|
selected += ' disabled';
|
|
1216
1222
|
}
|
|
1217
1223
|
|
|
1218
|
-
if (
|
|
1219
|
-
selected += ' '+className;
|
|
1224
|
+
if (className) {
|
|
1225
|
+
selected += ' ' + className;
|
|
1220
1226
|
}
|
|
1221
1227
|
|
|
1222
|
-
return '<td class="selectable '+selected+'">' +
|
|
1223
|
-
'<button class="'+classPrefix+'-button '+classPrefix+'-day" type="button" data-unit="'+unit+'" data-value="'+value+ '">' +
|
|
1224
|
-
|
|
1228
|
+
return '<td class="selectable ' + selected + '">' +
|
|
1229
|
+
'<button class="' + classPrefix + '-button ' + classPrefix + '-day" type="button" data-unit="' + unit + '" data-value="' + value + '">' +
|
|
1230
|
+
'<span>' + label + '</span>' +
|
|
1225
1231
|
'</button>' +
|
|
1226
|
-
|
|
1232
|
+
'</td>';
|
|
1227
1233
|
}
|
|
1228
1234
|
|
|
1229
|
-
if (
|
|
1235
|
+
if (count === 12) {
|
|
1230
1236
|
// Hours with AM/PM
|
|
1231
1237
|
a += '<tr>';
|
|
1232
|
-
|
|
1233
|
-
for (
|
|
1238
|
+
|
|
1239
|
+
for (i = 1; i <= 6; i++) {
|
|
1234
1240
|
a += button(i, render(i));
|
|
1235
1241
|
}
|
|
1236
1242
|
a += button('am', i18n.amPm[0]);
|
|
@@ -1238,7 +1244,7 @@ $.extend( DateTime.prototype, {
|
|
|
1238
1244
|
a += '</tr>';
|
|
1239
1245
|
a += '<tr>';
|
|
1240
1246
|
|
|
1241
|
-
for (
|
|
1247
|
+
for (i = 7; i <= 12; i++) {
|
|
1242
1248
|
a += button(i, render(i));
|
|
1243
1249
|
}
|
|
1244
1250
|
a += button('pm', i18n.amPm[1]);
|
|
@@ -1246,12 +1252,12 @@ $.extend( DateTime.prototype, {
|
|
|
1246
1252
|
|
|
1247
1253
|
span = 7;
|
|
1248
1254
|
}
|
|
1249
|
-
else if (
|
|
1255
|
+
else if (count === 24) {
|
|
1250
1256
|
// Hours - 24
|
|
1251
1257
|
var c = 0;
|
|
1252
|
-
for (j=0
|
|
1258
|
+
for (j = 0; j < 4; j++) {
|
|
1253
1259
|
a += '<tr>';
|
|
1254
|
-
for (
|
|
1260
|
+
for (i = 0; i < 6; i++) {
|
|
1255
1261
|
a += button(c, render(c));
|
|
1256
1262
|
c++;
|
|
1257
1263
|
}
|
|
@@ -1263,22 +1269,22 @@ $.extend( DateTime.prototype, {
|
|
|
1263
1269
|
else {
|
|
1264
1270
|
// Minutes and seconds
|
|
1265
1271
|
a += '<tr>';
|
|
1266
|
-
for (j=0
|
|
1272
|
+
for (j = 0; j < 60; j += 10) {
|
|
1267
1273
|
a += button(j, render(j), 'range');
|
|
1268
1274
|
}
|
|
1269
1275
|
a += '</tr>';
|
|
1270
|
-
|
|
1276
|
+
|
|
1271
1277
|
// Slight hack to allow for the different number of columns
|
|
1272
|
-
a += '</tbody></thead><table class="'+className+' '+className+'-nospace"><tbody>';
|
|
1278
|
+
a += '</tbody></thead><table class="' + className + ' ' + className + '-nospace"><tbody>';
|
|
1273
1279
|
|
|
1274
1280
|
var start = range !== null
|
|
1275
1281
|
? range
|
|
1276
1282
|
: val === -1
|
|
1277
1283
|
? 0
|
|
1278
|
-
: Math.floor(
|
|
1284
|
+
: Math.floor(val / 10) * 10;
|
|
1279
1285
|
|
|
1280
1286
|
a += '<tr>';
|
|
1281
|
-
for (j=start+1
|
|
1287
|
+
for (j = start + 1; j < start + 10; j++) {
|
|
1282
1288
|
a += button(j, render(j));
|
|
1283
1289
|
}
|
|
1284
1290
|
a += '</tr>';
|
|
@@ -1289,13 +1295,13 @@ $.extend( DateTime.prototype, {
|
|
|
1289
1295
|
container
|
|
1290
1296
|
.empty()
|
|
1291
1297
|
.append(
|
|
1292
|
-
'<table class="'+className+'">'+
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1298
|
+
'<table class="' + className + '">' +
|
|
1299
|
+
'<thead><tr><th colspan="' + span + '">' +
|
|
1300
|
+
i18n[unit] +
|
|
1301
|
+
'</th></tr></thead>' +
|
|
1302
|
+
'<tbody>' +
|
|
1303
|
+
a +
|
|
1304
|
+
'</tbody>' +
|
|
1299
1305
|
'</table>'
|
|
1300
1306
|
);
|
|
1301
1307
|
},
|
|
@@ -1317,8 +1323,8 @@ $.extend( DateTime.prototype, {
|
|
|
1317
1323
|
var i = minYear !== null ? minYear : new Date().getFullYear() - this.c.yearRange;
|
|
1318
1324
|
var j = maxYear !== null ? maxYear : new Date().getFullYear() + this.c.yearRange;
|
|
1319
1325
|
|
|
1320
|
-
this._options(
|
|
1321
|
-
this._options(
|
|
1326
|
+
this._options('month', this._range(0, 11), i18n.months);
|
|
1327
|
+
this._options('year', this._range(i, j));
|
|
1322
1328
|
|
|
1323
1329
|
// Set the language strings in case any have changed
|
|
1324
1330
|
this.dom.today.text(i18n.today).text(i18n.today);
|
|
@@ -1340,8 +1346,8 @@ $.extend( DateTime.prototype, {
|
|
|
1340
1346
|
* @return {string|integer} Padded value
|
|
1341
1347
|
* @private
|
|
1342
1348
|
*/
|
|
1343
|
-
_pad: function (
|
|
1344
|
-
return i<10 ? '0'+i : i;
|
|
1349
|
+
_pad: function (i) {
|
|
1350
|
+
return i < 10 ? '0' + i : i;
|
|
1345
1351
|
},
|
|
1346
1352
|
|
|
1347
1353
|
/**
|
|
@@ -1354,32 +1360,32 @@ $.extend( DateTime.prototype, {
|
|
|
1354
1360
|
var inputHeight = this.dom.input.outerHeight();
|
|
1355
1361
|
|
|
1356
1362
|
if (container.hasClass('inline')) {
|
|
1357
|
-
container.insertAfter(
|
|
1363
|
+
container.insertAfter(this.dom.input);
|
|
1358
1364
|
return;
|
|
1359
1365
|
}
|
|
1360
1366
|
|
|
1361
|
-
if (
|
|
1367
|
+
if (this.s.parts.date && this.s.parts.time && $(window).width() > 550) {
|
|
1362
1368
|
container.addClass('horizontal');
|
|
1363
1369
|
}
|
|
1364
1370
|
else {
|
|
1365
1371
|
container.removeClass('horizontal');
|
|
1366
1372
|
}
|
|
1367
1373
|
|
|
1368
|
-
if(this.c.attachTo === 'input') {
|
|
1374
|
+
if (this.c.attachTo === 'input') {
|
|
1369
1375
|
container
|
|
1370
|
-
.css(
|
|
1376
|
+
.css({
|
|
1371
1377
|
top: offset.top + inputHeight,
|
|
1372
1378
|
left: offset.left
|
|
1373
|
-
}
|
|
1374
|
-
.insertAfter(
|
|
1379
|
+
})
|
|
1380
|
+
.insertAfter(this.dom.input);
|
|
1375
1381
|
}
|
|
1376
1382
|
else {
|
|
1377
1383
|
container
|
|
1378
|
-
.css(
|
|
1384
|
+
.css({
|
|
1379
1385
|
top: offset.top + inputHeight,
|
|
1380
1386
|
left: offset.left
|
|
1381
|
-
}
|
|
1382
|
-
.appendTo(
|
|
1387
|
+
})
|
|
1388
|
+
.appendTo('body');
|
|
1383
1389
|
}
|
|
1384
1390
|
|
|
1385
1391
|
var calHeight = container.outerHeight();
|
|
@@ -1387,14 +1393,14 @@ $.extend( DateTime.prototype, {
|
|
|
1387
1393
|
var scrollTop = $(window).scrollTop();
|
|
1388
1394
|
|
|
1389
1395
|
// Correct to the bottom
|
|
1390
|
-
if (
|
|
1396
|
+
if (offset.top + inputHeight + calHeight - scrollTop > $(window).height()) {
|
|
1391
1397
|
var newTop = offset.top - calHeight;
|
|
1392
1398
|
|
|
1393
|
-
container.css(
|
|
1399
|
+
container.css('top', newTop < 0 ? 0 : newTop);
|
|
1394
1400
|
}
|
|
1395
1401
|
|
|
1396
1402
|
// Correct to the right
|
|
1397
|
-
if (
|
|
1403
|
+
if (calWidth + offset.left > $(window).width()) {
|
|
1398
1404
|
var newLeft = $(window).width() - calWidth;
|
|
1399
1405
|
|
|
1400
1406
|
// Account for elements which are inside a position absolute element
|
|
@@ -1402,7 +1408,7 @@ $.extend( DateTime.prototype, {
|
|
|
1402
1408
|
newLeft -= $(container).offsetParent().offset().left;
|
|
1403
1409
|
}
|
|
1404
1410
|
|
|
1405
|
-
container.css(
|
|
1411
|
+
container.css('left', newLeft < 0 ? 0 : newLeft);
|
|
1406
1412
|
}
|
|
1407
1413
|
},
|
|
1408
1414
|
|
|
@@ -1415,15 +1421,15 @@ $.extend( DateTime.prototype, {
|
|
|
1415
1421
|
* @return {array} Created array
|
|
1416
1422
|
* @private
|
|
1417
1423
|
*/
|
|
1418
|
-
_range: function (
|
|
1424
|
+
_range: function (start, end, inc) {
|
|
1419
1425
|
var a = [];
|
|
1420
1426
|
|
|
1421
|
-
if (
|
|
1427
|
+
if (!inc) {
|
|
1422
1428
|
inc = 1;
|
|
1423
1429
|
}
|
|
1424
1430
|
|
|
1425
|
-
for (
|
|
1426
|
-
a.push(
|
|
1431
|
+
for (var i = start; i <= end; i += inc) {
|
|
1432
|
+
a.push(i);
|
|
1427
1433
|
}
|
|
1428
1434
|
|
|
1429
1435
|
return a;
|
|
@@ -1436,13 +1442,13 @@ $.extend( DateTime.prototype, {
|
|
|
1436
1442
|
* @private
|
|
1437
1443
|
*/
|
|
1438
1444
|
_setCalander: function () {
|
|
1439
|
-
if (
|
|
1445
|
+
if (this.s.display) {
|
|
1440
1446
|
this.dom.calendar
|
|
1441
1447
|
.empty()
|
|
1442
|
-
.append(
|
|
1448
|
+
.append(this._htmlMonth(
|
|
1443
1449
|
this.s.display.getUTCFullYear(),
|
|
1444
1450
|
this.s.display.getUTCMonth()
|
|
1445
|
-
)
|
|
1451
|
+
));
|
|
1446
1452
|
}
|
|
1447
1453
|
},
|
|
1448
1454
|
|
|
@@ -1452,8 +1458,8 @@ $.extend( DateTime.prototype, {
|
|
|
1452
1458
|
* @private
|
|
1453
1459
|
*/
|
|
1454
1460
|
_setTitle: function () {
|
|
1455
|
-
this._optionSet(
|
|
1456
|
-
this._optionSet(
|
|
1461
|
+
this._optionSet('month', this.s.display.getUTCMonth());
|
|
1462
|
+
this._optionSet('year', this.s.display.getUTCFullYear());
|
|
1457
1463
|
},
|
|
1458
1464
|
|
|
1459
1465
|
/**
|
|
@@ -1464,7 +1470,7 @@ $.extend( DateTime.prototype, {
|
|
|
1464
1470
|
_setTime: function () {
|
|
1465
1471
|
var that = this;
|
|
1466
1472
|
var d = this.s.d;
|
|
1467
|
-
|
|
1473
|
+
|
|
1468
1474
|
// luxon uses different method names so need to be able to call them. This happens a few time later in this method too
|
|
1469
1475
|
var luxDT = null
|
|
1470
1476
|
if (this._isLuxon()) {
|
|
@@ -1477,13 +1483,13 @@ $.extend( DateTime.prototype, {
|
|
|
1477
1483
|
? d.getUTCHours()
|
|
1478
1484
|
: -1;
|
|
1479
1485
|
|
|
1480
|
-
var allowed = function (
|
|
1481
|
-
return that.c[prop+'Available'] ?
|
|
1482
|
-
that.c[prop+'Available'] :
|
|
1483
|
-
that._range(
|
|
1486
|
+
var allowed = function (prop) { // Backwards compt with `Increment` option
|
|
1487
|
+
return that.c[prop + 'Available'] ?
|
|
1488
|
+
that.c[prop + 'Available'] :
|
|
1489
|
+
that._range(0, 59, that.c[prop + 'Increment']);
|
|
1484
1490
|
}
|
|
1485
1491
|
|
|
1486
|
-
this._optionsTime(
|
|
1492
|
+
this._optionsTime('hours', this.s.parts.hours12 ? 12 : 24, hours, this.c.hoursAvailable)
|
|
1487
1493
|
this._optionsTime(
|
|
1488
1494
|
'minutes',
|
|
1489
1495
|
60,
|
|
@@ -1521,50 +1527,50 @@ $.extend( DateTime.prototype, {
|
|
|
1521
1527
|
this._position();
|
|
1522
1528
|
|
|
1523
1529
|
// Need to reposition on scroll
|
|
1524
|
-
$(window).on(
|
|
1530
|
+
$(window).on('scroll.' + namespace + ' resize.' + namespace, function () {
|
|
1525
1531
|
that._position();
|
|
1526
|
-
}
|
|
1532
|
+
});
|
|
1527
1533
|
|
|
1528
|
-
$('div.DTE_Body_Content').on(
|
|
1534
|
+
$('div.DTE_Body_Content').on('scroll.' + namespace, function () {
|
|
1529
1535
|
that._position();
|
|
1530
|
-
}
|
|
1536
|
+
});
|
|
1531
1537
|
|
|
1532
|
-
$('div.dataTables_scrollBody').on(
|
|
1538
|
+
$('div.dataTables_scrollBody').on('scroll.' + namespace, function () {
|
|
1533
1539
|
that._position();
|
|
1534
|
-
}
|
|
1540
|
+
});
|
|
1535
1541
|
|
|
1536
1542
|
var offsetParent = this.dom.input[0].offsetParent;
|
|
1537
1543
|
|
|
1538
|
-
if (
|
|
1539
|
-
$(offsetParent).on(
|
|
1544
|
+
if (offsetParent !== document.body) {
|
|
1545
|
+
$(offsetParent).on('scroll.' + namespace, function () {
|
|
1540
1546
|
that._position();
|
|
1541
|
-
}
|
|
1547
|
+
});
|
|
1542
1548
|
}
|
|
1543
1549
|
|
|
1544
1550
|
// On tab focus will move to a different field (no keyboard navigation
|
|
1545
1551
|
// in the date picker - this might need to be changed).
|
|
1546
|
-
$(document).on(
|
|
1552
|
+
$(document).on('keydown.' + namespace, function (e) {
|
|
1547
1553
|
if (
|
|
1548
|
-
e.keyCode === 9
|
|
1554
|
+
e.keyCode === 9 || // tab
|
|
1549
1555
|
e.keyCode === 27 || // esc
|
|
1550
1556
|
e.keyCode === 13 // return
|
|
1551
1557
|
) {
|
|
1552
1558
|
that._hide();
|
|
1553
1559
|
}
|
|
1554
|
-
}
|
|
1560
|
+
});
|
|
1555
1561
|
|
|
1556
1562
|
// Hide if clicking outside of the widget - but in a different click
|
|
1557
1563
|
// event from the one that was used to trigger the show (bubble and
|
|
1558
1564
|
// inline)
|
|
1559
|
-
setTimeout(
|
|
1560
|
-
$('body').on(
|
|
1565
|
+
setTimeout(function () {
|
|
1566
|
+
$('body').on('click.' + namespace, function (e) {
|
|
1561
1567
|
var parents = $(e.target).parents();
|
|
1562
1568
|
|
|
1563
|
-
if (
|
|
1569
|
+
if (!parents.filter(that.dom.container).length && e.target !== that.dom.input[0]) {
|
|
1564
1570
|
that._hide();
|
|
1565
1571
|
}
|
|
1566
|
-
}
|
|
1567
|
-
}, 10
|
|
1572
|
+
});
|
|
1573
|
+
}, 10);
|
|
1568
1574
|
},
|
|
1569
1575
|
|
|
1570
1576
|
/**
|
|
@@ -1573,7 +1579,7 @@ $.extend( DateTime.prototype, {
|
|
|
1573
1579
|
*
|
|
1574
1580
|
* @private
|
|
1575
1581
|
*/
|
|
1576
|
-
_writeOutput: function (
|
|
1582
|
+
_writeOutput: function (focus) {
|
|
1577
1583
|
var date = this.s.d;
|
|
1578
1584
|
var out = '';
|
|
1579
1585
|
var input = this.dom.input;
|
|
@@ -1582,22 +1588,22 @@ $.extend( DateTime.prototype, {
|
|
|
1582
1588
|
out = this._convert(date, null, this.c.format);
|
|
1583
1589
|
}
|
|
1584
1590
|
|
|
1585
|
-
input.val(
|
|
1591
|
+
input.val(out);
|
|
1586
1592
|
|
|
1587
1593
|
// Create a DOM synthetic event. Can't use $().trigger() as
|
|
1588
1594
|
// that doesn't actually trigger non-jQuery event listeners
|
|
1589
|
-
var event = new Event('change', {bubbles: true});
|
|
1595
|
+
var event = new Event('change', { bubbles: true });
|
|
1590
1596
|
input[0].dispatchEvent(event);
|
|
1591
|
-
|
|
1592
|
-
if (
|
|
1597
|
+
|
|
1598
|
+
if (input.attr('type') === 'hidden') {
|
|
1593
1599
|
this.val(out, false);
|
|
1594
1600
|
}
|
|
1595
1601
|
|
|
1596
|
-
if (
|
|
1602
|
+
if (focus) {
|
|
1597
1603
|
input.focus();
|
|
1598
1604
|
}
|
|
1599
1605
|
}
|
|
1600
|
-
}
|
|
1606
|
+
});
|
|
1601
1607
|
|
|
1602
1608
|
/**
|
|
1603
1609
|
* Use a specificmoment compatible date library
|
|
@@ -1646,17 +1652,17 @@ DateTime.defaults = {
|
|
|
1646
1652
|
hoursAvailable: null,
|
|
1647
1653
|
|
|
1648
1654
|
i18n: {
|
|
1649
|
-
clear:
|
|
1655
|
+
clear: 'Clear',
|
|
1650
1656
|
previous: 'Previous',
|
|
1651
|
-
next:
|
|
1652
|
-
months:
|
|
1653
|
-
weekdays: [
|
|
1654
|
-
amPm:
|
|
1655
|
-
hours:
|
|
1656
|
-
minutes:
|
|
1657
|
-
seconds:
|
|
1658
|
-
unknown:
|
|
1659
|
-
today:
|
|
1657
|
+
next: 'Next',
|
|
1658
|
+
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
1659
|
+
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
1660
|
+
amPm: ['am', 'pm'],
|
|
1661
|
+
hours: 'Hour',
|
|
1662
|
+
minutes: 'Minute',
|
|
1663
|
+
seconds: 'Second',
|
|
1664
|
+
unknown: '-',
|
|
1665
|
+
today: 'Today'
|
|
1660
1666
|
},
|
|
1661
1667
|
|
|
1662
1668
|
maxDate: null,
|
|
@@ -1671,7 +1677,7 @@ DateTime.defaults = {
|
|
|
1671
1677
|
|
|
1672
1678
|
locale: 'en',
|
|
1673
1679
|
|
|
1674
|
-
onChange: function () {},
|
|
1680
|
+
onChange: function () { },
|
|
1675
1681
|
|
|
1676
1682
|
secondsAvailable: null,
|
|
1677
1683
|
|
|
@@ -1684,7 +1690,7 @@ DateTime.defaults = {
|
|
|
1684
1690
|
yearRange: 25
|
|
1685
1691
|
};
|
|
1686
1692
|
|
|
1687
|
-
DateTime.version = '1.5.
|
|
1693
|
+
DateTime.version = '1.5.2';
|
|
1688
1694
|
|
|
1689
1695
|
/**
|
|
1690
1696
|
* CommonJS factory function pass through. Matches DataTables.
|
|
@@ -1711,7 +1717,7 @@ DateTime.factory = function (root, jq) {
|
|
|
1711
1717
|
}
|
|
1712
1718
|
|
|
1713
1719
|
// Global export - if no conflicts
|
|
1714
|
-
if (!
|
|
1720
|
+
if (!window.DateTime) {
|
|
1715
1721
|
window.DateTime = DateTime;
|
|
1716
1722
|
}
|
|
1717
1723
|
|
|
@@ -1722,7 +1728,7 @@ if (window.DataTable) {
|
|
|
1722
1728
|
|
|
1723
1729
|
// Make available via jQuery
|
|
1724
1730
|
$.fn.dtDateTime = function (options) {
|
|
1725
|
-
return this.each(function() {
|
|
1731
|
+
return this.each(function () {
|
|
1726
1732
|
new DateTime(this, options);
|
|
1727
1733
|
});
|
|
1728
1734
|
}
|