datatables.net-datetime 1.4.1 → 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/css/dataTables.dateTime.scss +123 -15
- package/datatables.net-datetime.1.5.0.nupkg +0 -0
- package/dist/dataTables.dateTime.css +92 -18
- package/dist/dataTables.dateTime.js +412 -377
- package/dist/dataTables.dateTime.min.css +1 -1
- package/dist/dataTables.dateTime.min.js +2 -2
- package/dist/dataTables.dateTime.min.mjs +2 -2
- package/dist/dataTables.dateTime.mjs +411 -376
- package/docs/api/DateTime.use().xml +0 -2
- package/docs/api/destroy().xml +0 -2
- package/docs/api/display().xml +29 -0
- 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/index.xml +1 -0
- package/examples/initialisation/buttons.xml +18 -7
- package/examples/initialisation/datetime.xml +12 -4
- package/examples/initialisation/dayjs.xml +16 -4
- package/examples/initialisation/hidden.xml +10 -4
- package/examples/initialisation/i18n.xml +48 -9
- package/examples/initialisation/index.xml +1 -0
- package/examples/initialisation/luxon.xml +13 -4
- package/examples/initialisation/moment.xml +12 -4
- package/examples/initialisation/simple.xml +10 -4
- package/examples/integration/datatables.xml +69 -34
- package/examples/integration/form.xml +56 -19
- package/js/dataTables.dateTime.js +411 -376
- package/nuget.nuspec +1 -1
- package/package.json +1 -1
- package/test/api/dateTime.destroy().js +4 -4
- package/test/api/dateTime.display().js +47 -0
- package/test/api/dateTime.hide().js +5 -5
- package/test/options/dateTime.buttons.js +71 -0
- package/test/options/dateTime.firstDay.js +2 -2
- package/test/options/dateTime.hoursAvailable.js +38 -0
- package/test/options/dateTime.init.js +4 -4
- 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
- package/examples/initialisation/jquery.xml +0 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.
|
|
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.
|
|
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,35 +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);
|
|
198
|
+
|
|
199
|
+
this.dom.input.addClass('dt-datetime');
|
|
199
200
|
|
|
200
201
|
this._constructor();
|
|
201
202
|
};
|
|
202
203
|
|
|
203
|
-
$.extend(
|
|
204
|
+
$.extend(DateTime.prototype, {
|
|
204
205
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
205
206
|
* Public
|
|
206
207
|
*/
|
|
207
|
-
|
|
208
|
+
|
|
208
209
|
/**
|
|
209
210
|
* Destroy the control
|
|
210
211
|
*/
|
|
@@ -212,15 +213,38 @@ $.extend( DateTime.prototype, {
|
|
|
212
213
|
this._hide(true);
|
|
213
214
|
this.dom.container.off().empty();
|
|
214
215
|
this.dom.input
|
|
216
|
+
.removeClass('dt-datetime')
|
|
215
217
|
.removeAttr('autocomplete')
|
|
216
218
|
.off('.datetime');
|
|
217
219
|
},
|
|
218
220
|
|
|
219
|
-
|
|
221
|
+
display: function (year, month) {
|
|
222
|
+
if (year !== undefined) {
|
|
223
|
+
this.s.display.setUTCFullYear(year);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (month !== undefined) {
|
|
227
|
+
this.s.display.setUTCMonth(month - 1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (year !== undefined || month !== undefined) {
|
|
231
|
+
this._setTitle();
|
|
232
|
+
this._setCalander();
|
|
233
|
+
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
month: this.s.display.getUTCMonth() + 1,
|
|
239
|
+
year: this.s.display.getUTCFullYear()
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
errorMsg: function (msg) {
|
|
220
244
|
var error = this.dom.error;
|
|
221
245
|
|
|
222
|
-
if (
|
|
223
|
-
error.html(
|
|
246
|
+
if (msg) {
|
|
247
|
+
error.html(msg);
|
|
224
248
|
}
|
|
225
249
|
else {
|
|
226
250
|
error.empty();
|
|
@@ -235,7 +259,7 @@ $.extend( DateTime.prototype, {
|
|
|
235
259
|
return this;
|
|
236
260
|
},
|
|
237
261
|
|
|
238
|
-
max: function (
|
|
262
|
+
max: function (date) {
|
|
239
263
|
this.c.maxDate = typeof date === 'string'
|
|
240
264
|
? new Date(date)
|
|
241
265
|
: date;
|
|
@@ -246,7 +270,7 @@ $.extend( DateTime.prototype, {
|
|
|
246
270
|
return this;
|
|
247
271
|
},
|
|
248
272
|
|
|
249
|
-
min: function (
|
|
273
|
+
min: function (date) {
|
|
250
274
|
this.c.minDate = typeof date === 'string'
|
|
251
275
|
? new Date(date)
|
|
252
276
|
: date;
|
|
@@ -263,8 +287,8 @@ $.extend( DateTime.prototype, {
|
|
|
263
287
|
* @param {node} node Element to check
|
|
264
288
|
* @return {boolean} true if owned by this control, false otherwise
|
|
265
289
|
*/
|
|
266
|
-
owns: function (
|
|
267
|
-
return $(node).parents().filter(
|
|
290
|
+
owns: function (node) {
|
|
291
|
+
return $(node).parents().filter(this.dom.container).length > 0;
|
|
268
292
|
},
|
|
269
293
|
|
|
270
294
|
/**
|
|
@@ -274,44 +298,44 @@ $.extend( DateTime.prototype, {
|
|
|
274
298
|
* @param {boolean} [write=true] Flag to indicate if the formatted value
|
|
275
299
|
* should be written into the input element
|
|
276
300
|
*/
|
|
277
|
-
val: function (
|
|
278
|
-
if (
|
|
301
|
+
val: function (set, write) {
|
|
302
|
+
if (set === undefined) {
|
|
279
303
|
return this.s.d;
|
|
280
304
|
}
|
|
281
305
|
|
|
282
|
-
if (
|
|
283
|
-
this.s.d = this._dateToUtc(
|
|
306
|
+
if (set instanceof Date) {
|
|
307
|
+
this.s.d = this._dateToUtc(set);
|
|
284
308
|
}
|
|
285
|
-
else if (
|
|
309
|
+
else if (set === null || set === '') {
|
|
286
310
|
this.s.d = null;
|
|
287
311
|
}
|
|
288
|
-
else if (
|
|
312
|
+
else if (set === '--now') {
|
|
289
313
|
this.s.d = this._dateToUtc(new Date());
|
|
290
314
|
}
|
|
291
|
-
else if (
|
|
315
|
+
else if (typeof set === 'string') {
|
|
292
316
|
this.s.d = this._dateToUtc(
|
|
293
317
|
this._convert(set, this.c.format, null)
|
|
294
318
|
);
|
|
295
319
|
}
|
|
296
320
|
|
|
297
|
-
if (
|
|
298
|
-
if (
|
|
321
|
+
if (write || write === undefined) {
|
|
322
|
+
if (this.s.d) {
|
|
299
323
|
this._writeOutput();
|
|
300
324
|
}
|
|
301
325
|
else {
|
|
302
326
|
// The input value was not valid...
|
|
303
|
-
this.dom.input.val(
|
|
327
|
+
this.dom.input.val(set);
|
|
304
328
|
}
|
|
305
329
|
}
|
|
306
330
|
|
|
307
331
|
// Need something to display
|
|
308
332
|
this.s.display = this.s.d
|
|
309
|
-
? new Date(
|
|
333
|
+
? new Date(this.s.d.toString())
|
|
310
334
|
: new Date();
|
|
311
335
|
|
|
312
336
|
// Set the day of the month to be 1 so changing between months doesn't
|
|
313
|
-
|
|
314
|
-
this.s.display.setUTCDate(
|
|
337
|
+
// run into issues when going from day 31 to 28 (for example)
|
|
338
|
+
this.s.display.setUTCDate(1);
|
|
315
339
|
|
|
316
340
|
// Update the display elements for the new value
|
|
317
341
|
this._setTitle();
|
|
@@ -329,7 +353,7 @@ $.extend( DateTime.prototype, {
|
|
|
329
353
|
* @returns
|
|
330
354
|
*/
|
|
331
355
|
valFormat: function (format, val) {
|
|
332
|
-
if (!
|
|
356
|
+
if (!val) {
|
|
333
357
|
return this._convert(this.val(), null, format);
|
|
334
358
|
}
|
|
335
359
|
|
|
@@ -344,7 +368,7 @@ $.extend( DateTime.prototype, {
|
|
|
344
368
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
345
369
|
* Constructor
|
|
346
370
|
*/
|
|
347
|
-
|
|
371
|
+
|
|
348
372
|
/**
|
|
349
373
|
* Build the control and assign initial event handlers
|
|
350
374
|
*
|
|
@@ -359,30 +383,30 @@ $.extend( DateTime.prototype, {
|
|
|
359
383
|
var curr = that.dom.input.val();
|
|
360
384
|
|
|
361
385
|
if (curr !== last) {
|
|
362
|
-
that.c.onChange.call(
|
|
386
|
+
that.c.onChange.call(that, curr, that.s.d, that.dom.input);
|
|
363
387
|
last = curr;
|
|
364
388
|
}
|
|
365
389
|
};
|
|
366
390
|
|
|
367
|
-
if (
|
|
368
|
-
this.dom.date.css(
|
|
391
|
+
if (!this.s.parts.date) {
|
|
392
|
+
this.dom.date.css('display', 'none');
|
|
369
393
|
}
|
|
370
394
|
|
|
371
|
-
if (
|
|
372
|
-
this.dom.time.css(
|
|
395
|
+
if (!this.s.parts.time) {
|
|
396
|
+
this.dom.time.css('display', 'none');
|
|
373
397
|
}
|
|
374
398
|
|
|
375
|
-
if (
|
|
376
|
-
this.dom.time.children('div.'+classPrefix+'-seconds').remove();
|
|
399
|
+
if (!this.s.parts.seconds) {
|
|
400
|
+
this.dom.time.children('div.' + classPrefix + '-seconds').remove();
|
|
377
401
|
this.dom.time.children('span').eq(1).remove();
|
|
378
402
|
}
|
|
379
403
|
|
|
380
|
-
if (
|
|
381
|
-
this.dom.clear.css(
|
|
404
|
+
if (!this.c.buttons.clear) {
|
|
405
|
+
this.dom.clear.css('display', 'none');
|
|
382
406
|
}
|
|
383
407
|
|
|
384
|
-
if (
|
|
385
|
-
this.dom.today.css(
|
|
408
|
+
if (!this.c.buttons.today) {
|
|
409
|
+
this.dom.today.css('display', 'none');
|
|
386
410
|
}
|
|
387
411
|
|
|
388
412
|
// Render the options
|
|
@@ -401,13 +425,13 @@ $.extend( DateTime.prototype, {
|
|
|
401
425
|
this.dom.container.addClass('inline');
|
|
402
426
|
this.c.attachTo = 'input';
|
|
403
427
|
|
|
404
|
-
this.val(
|
|
428
|
+
this.val(this.dom.input.val(), false);
|
|
405
429
|
this._show();
|
|
406
430
|
}
|
|
407
431
|
|
|
408
432
|
// Set the initial value
|
|
409
433
|
if (last) {
|
|
410
|
-
this.val(
|
|
434
|
+
this.val(last, false);
|
|
411
435
|
}
|
|
412
436
|
|
|
413
437
|
// Trigger the display of the widget when clicking or focusing on the
|
|
@@ -416,47 +440,56 @@ $.extend( DateTime.prototype, {
|
|
|
416
440
|
.attr('autocomplete', 'off')
|
|
417
441
|
.on('focus.datetime click.datetime', function () {
|
|
418
442
|
// If already visible - don't do anything
|
|
419
|
-
if (
|
|
443
|
+
if (that.dom.container.is(':visible') || that.dom.input.is(':disabled')) {
|
|
420
444
|
return;
|
|
421
445
|
}
|
|
422
446
|
|
|
423
447
|
// In case the value has changed by text
|
|
424
|
-
that.val(
|
|
448
|
+
that.val(that.dom.input.val(), false);
|
|
425
449
|
|
|
426
450
|
that._show();
|
|
427
|
-
}
|
|
451
|
+
})
|
|
428
452
|
.on('keyup.datetime', function () {
|
|
429
453
|
// Update the calendar's displayed value as the user types
|
|
430
|
-
if (
|
|
431
|
-
that.val(
|
|
454
|
+
if (that.dom.container.is(':visible')) {
|
|
455
|
+
that.val(that.dom.input.val(), false);
|
|
432
456
|
}
|
|
433
|
-
}
|
|
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
|
+
});
|
|
434
467
|
|
|
435
468
|
// Main event handlers for input in the widget
|
|
436
469
|
this.dom.container
|
|
437
|
-
.on(
|
|
470
|
+
.on('change', 'select', function () {
|
|
438
471
|
var select = $(this);
|
|
439
472
|
var val = select.val();
|
|
440
473
|
|
|
441
|
-
if (
|
|
474
|
+
if (select.hasClass(classPrefix + '-month')) {
|
|
442
475
|
// Month select
|
|
443
|
-
that._correctMonth(
|
|
476
|
+
that._correctMonth(that.s.display, val);
|
|
444
477
|
that._setTitle();
|
|
445
478
|
that._setCalander();
|
|
446
479
|
}
|
|
447
|
-
else if (
|
|
480
|
+
else if (select.hasClass(classPrefix + '-year')) {
|
|
448
481
|
// Year select
|
|
449
|
-
that.s.display.setUTCFullYear(
|
|
482
|
+
that.s.display.setUTCFullYear(val);
|
|
450
483
|
that._setTitle();
|
|
451
484
|
that._setCalander();
|
|
452
485
|
}
|
|
453
|
-
else if (
|
|
486
|
+
else if (select.hasClass(classPrefix + '-hours') || select.hasClass(classPrefix + '-ampm')) {
|
|
454
487
|
// Hours - need to take account of AM/PM input if present
|
|
455
|
-
if (
|
|
456
|
-
var hours = $(that.dom.container).find('.'+classPrefix+'-hours').val() * 1;
|
|
457
|
-
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';
|
|
458
491
|
|
|
459
|
-
that.s.d.setUTCHours(
|
|
492
|
+
that.s.d.setUTCHours(hours === 12 && !pm ?
|
|
460
493
|
0 :
|
|
461
494
|
pm && hours !== 12 ?
|
|
462
495
|
hours + 12 :
|
|
@@ -464,35 +497,35 @@ $.extend( DateTime.prototype, {
|
|
|
464
497
|
);
|
|
465
498
|
}
|
|
466
499
|
else {
|
|
467
|
-
that.s.d.setUTCHours(
|
|
500
|
+
that.s.d.setUTCHours(val);
|
|
468
501
|
}
|
|
469
502
|
|
|
470
503
|
that._setTime();
|
|
471
|
-
that._writeOutput(
|
|
504
|
+
that._writeOutput(true);
|
|
472
505
|
|
|
473
506
|
onChange();
|
|
474
507
|
}
|
|
475
|
-
else if (
|
|
508
|
+
else if (select.hasClass(classPrefix + '-minutes')) {
|
|
476
509
|
// Minutes select
|
|
477
|
-
that.s.d.setUTCMinutes(
|
|
510
|
+
that.s.d.setUTCMinutes(val);
|
|
478
511
|
that._setTime();
|
|
479
|
-
that._writeOutput(
|
|
512
|
+
that._writeOutput(true);
|
|
480
513
|
|
|
481
514
|
onChange();
|
|
482
515
|
}
|
|
483
|
-
else if (
|
|
516
|
+
else if (select.hasClass(classPrefix + '-seconds')) {
|
|
484
517
|
// Seconds select
|
|
485
|
-
that.s.d.setSeconds(
|
|
518
|
+
that.s.d.setSeconds(val);
|
|
486
519
|
that._setTime();
|
|
487
|
-
that._writeOutput(
|
|
520
|
+
that._writeOutput(true);
|
|
488
521
|
|
|
489
522
|
onChange();
|
|
490
523
|
}
|
|
491
524
|
|
|
492
525
|
that.dom.input.focus();
|
|
493
526
|
that._position();
|
|
494
|
-
}
|
|
495
|
-
.on(
|
|
527
|
+
})
|
|
528
|
+
.on('click', function (e) {
|
|
496
529
|
var d = that.s.d;
|
|
497
530
|
var nodeName = e.target.nodeName.toLowerCase();
|
|
498
531
|
var target = nodeName === 'span' ?
|
|
@@ -501,16 +534,16 @@ $.extend( DateTime.prototype, {
|
|
|
501
534
|
|
|
502
535
|
nodeName = target.nodeName.toLowerCase();
|
|
503
536
|
|
|
504
|
-
if (
|
|
537
|
+
if (nodeName === 'select') {
|
|
505
538
|
return;
|
|
506
539
|
}
|
|
507
540
|
|
|
508
541
|
e.stopPropagation();
|
|
509
542
|
|
|
510
|
-
if (
|
|
543
|
+
if (nodeName === 'a') {
|
|
511
544
|
e.preventDefault();
|
|
512
545
|
|
|
513
|
-
if ($(target).hasClass(classPrefix+'-clear')) {
|
|
546
|
+
if ($(target).hasClass(classPrefix + '-clear')) {
|
|
514
547
|
// Clear the value and don't change the display
|
|
515
548
|
that.s.d = null;
|
|
516
549
|
that.dom.input.val('');
|
|
@@ -520,7 +553,7 @@ $.extend( DateTime.prototype, {
|
|
|
520
553
|
|
|
521
554
|
onChange();
|
|
522
555
|
}
|
|
523
|
-
else if ($(target).hasClass(classPrefix+'-today')) {
|
|
556
|
+
else if ($(target).hasClass(classPrefix + '-today')) {
|
|
524
557
|
// Don't change the value, but jump to the month
|
|
525
558
|
// containing today
|
|
526
559
|
that.s.display = new Date();
|
|
@@ -529,39 +562,39 @@ $.extend( DateTime.prototype, {
|
|
|
529
562
|
that._setCalander();
|
|
530
563
|
}
|
|
531
564
|
}
|
|
532
|
-
if (
|
|
565
|
+
if (nodeName === 'button') {
|
|
533
566
|
var button = $(target);
|
|
534
567
|
var parent = button.parent();
|
|
535
568
|
|
|
536
|
-
if (
|
|
569
|
+
if (parent.hasClass('disabled') && !parent.hasClass('range')) {
|
|
537
570
|
button.blur();
|
|
538
571
|
return;
|
|
539
572
|
}
|
|
540
573
|
|
|
541
|
-
if (
|
|
574
|
+
if (parent.hasClass(classPrefix + '-iconLeft')) {
|
|
542
575
|
// Previous month
|
|
543
|
-
that.s.display.setUTCMonth(
|
|
576
|
+
that.s.display.setUTCMonth(that.s.display.getUTCMonth() - 1);
|
|
544
577
|
that._setTitle();
|
|
545
578
|
that._setCalander();
|
|
546
579
|
|
|
547
580
|
that.dom.input.focus();
|
|
548
581
|
}
|
|
549
|
-
else if (
|
|
582
|
+
else if (parent.hasClass(classPrefix + '-iconRight')) {
|
|
550
583
|
// Next month
|
|
551
|
-
that._correctMonth(
|
|
584
|
+
that._correctMonth(that.s.display, that.s.display.getUTCMonth() + 1);
|
|
552
585
|
that._setTitle();
|
|
553
586
|
that._setCalander();
|
|
554
587
|
|
|
555
588
|
that.dom.input.focus();
|
|
556
589
|
}
|
|
557
|
-
else if (
|
|
590
|
+
else if (button.parents('.' + classPrefix + '-time').length) {
|
|
558
591
|
var val = button.data('value');
|
|
559
592
|
var unit = button.data('unit');
|
|
560
593
|
|
|
561
594
|
d = that._needValue();
|
|
562
595
|
|
|
563
|
-
if (
|
|
564
|
-
if (
|
|
596
|
+
if (unit === 'minutes') {
|
|
597
|
+
if (parent.hasClass('disabled') && parent.hasClass('range')) {
|
|
565
598
|
that.s.minutesRange = val;
|
|
566
599
|
that._setTime();
|
|
567
600
|
return;
|
|
@@ -571,8 +604,8 @@ $.extend( DateTime.prototype, {
|
|
|
571
604
|
}
|
|
572
605
|
}
|
|
573
606
|
|
|
574
|
-
if (
|
|
575
|
-
if (
|
|
607
|
+
if (unit === 'seconds') {
|
|
608
|
+
if (parent.hasClass('disabled') && parent.hasClass('range')) {
|
|
576
609
|
that.s.secondsRange = val;
|
|
577
610
|
that._setTime();
|
|
578
611
|
return;
|
|
@@ -583,16 +616,16 @@ $.extend( DateTime.prototype, {
|
|
|
583
616
|
}
|
|
584
617
|
|
|
585
618
|
// Specific to hours for 12h clock
|
|
586
|
-
if (
|
|
587
|
-
if (
|
|
619
|
+
if (val === 'am') {
|
|
620
|
+
if (d.getUTCHours() >= 12) {
|
|
588
621
|
val = d.getUTCHours() - 12;
|
|
589
622
|
}
|
|
590
623
|
else {
|
|
591
624
|
return;
|
|
592
625
|
}
|
|
593
626
|
}
|
|
594
|
-
else if (
|
|
595
|
-
if (
|
|
627
|
+
else if (val === 'pm') {
|
|
628
|
+
if (d.getUTCHours() < 12) {
|
|
596
629
|
val = d.getUTCHours() + 12;
|
|
597
630
|
}
|
|
598
631
|
else {
|
|
@@ -606,10 +639,10 @@ $.extend( DateTime.prototype, {
|
|
|
606
639
|
'setUTCMinutes' :
|
|
607
640
|
'setSeconds';
|
|
608
641
|
|
|
609
|
-
d[set](
|
|
642
|
+
d[set](val);
|
|
610
643
|
that._setCalander();
|
|
611
644
|
that._setTime();
|
|
612
|
-
that._writeOutput(
|
|
645
|
+
that._writeOutput(true);
|
|
613
646
|
onChange();
|
|
614
647
|
}
|
|
615
648
|
else {
|
|
@@ -621,23 +654,23 @@ $.extend( DateTime.prototype, {
|
|
|
621
654
|
// new day will exist in the old month, But 1 always
|
|
622
655
|
// does, so we can change the month without worry of a
|
|
623
656
|
// recalculation being done automatically by `Date`
|
|
624
|
-
d.setUTCDate(
|
|
625
|
-
d.setUTCFullYear(
|
|
626
|
-
d.setUTCMonth(
|
|
627
|
-
d.setUTCDate(
|
|
657
|
+
d.setUTCDate(1);
|
|
658
|
+
d.setUTCFullYear(button.data('year'));
|
|
659
|
+
d.setUTCMonth(button.data('month'));
|
|
660
|
+
d.setUTCDate(button.data('day'));
|
|
628
661
|
|
|
629
|
-
that._writeOutput(
|
|
662
|
+
that._writeOutput(true);
|
|
630
663
|
|
|
631
664
|
// Don't hide if there is a time picker, since we want to
|
|
632
665
|
// be able to select a time as well.
|
|
633
|
-
if (
|
|
666
|
+
if (!that.s.parts.time) {
|
|
634
667
|
// This is annoying but IE has some kind of async
|
|
635
668
|
// behaviour with focus and the focus from the above
|
|
636
669
|
// write would occur after this hide - resulting in the
|
|
637
670
|
// calendar opening immediately
|
|
638
|
-
setTimeout(
|
|
671
|
+
setTimeout(function () {
|
|
639
672
|
that._hide();
|
|
640
|
-
}, 10
|
|
673
|
+
}, 10);
|
|
641
674
|
}
|
|
642
675
|
else {
|
|
643
676
|
that._setCalander();
|
|
@@ -652,7 +685,7 @@ $.extend( DateTime.prototype, {
|
|
|
652
685
|
// input element
|
|
653
686
|
that.dom.input.focus();
|
|
654
687
|
}
|
|
655
|
-
}
|
|
688
|
+
});
|
|
656
689
|
},
|
|
657
690
|
|
|
658
691
|
|
|
@@ -668,7 +701,7 @@ $.extend( DateTime.prototype, {
|
|
|
668
701
|
* @param {Date} b Date 2
|
|
669
702
|
* @private
|
|
670
703
|
*/
|
|
671
|
-
_compareDates: function(
|
|
704
|
+
_compareDates: function (a, b) {
|
|
672
705
|
// Can't use toDateString as that converts to local time
|
|
673
706
|
// luxon uses different method names so need to be able to call them
|
|
674
707
|
return this._isLuxon()
|
|
@@ -684,29 +717,29 @@ $.extend( DateTime.prototype, {
|
|
|
684
717
|
* @param {string|null} to Format to convert to. If null a `Date` will be returned
|
|
685
718
|
* @returns {string|Date} Converted value
|
|
686
719
|
*/
|
|
687
|
-
_convert: function(val, from, to) {
|
|
688
|
-
if (!
|
|
720
|
+
_convert: function (val, from, to) {
|
|
721
|
+
if (!val) {
|
|
689
722
|
return val;
|
|
690
723
|
}
|
|
691
724
|
|
|
692
|
-
if (!
|
|
725
|
+
if (!dateLib) {
|
|
693
726
|
// Note that in here from and to can either be null or YYYY-MM-DD
|
|
694
727
|
// They cannot be anything else
|
|
695
|
-
if ((!
|
|
728
|
+
if ((!from && !to) || (from && to)) {
|
|
696
729
|
// No conversion
|
|
697
730
|
return val;
|
|
698
731
|
}
|
|
699
|
-
else if (!
|
|
732
|
+
else if (!from) {
|
|
700
733
|
// Date in, string back
|
|
701
|
-
return val.getUTCFullYear() +'-'+
|
|
702
|
-
this._pad(val.getUTCMonth() + 1) +'-'+
|
|
734
|
+
return val.getUTCFullYear() + '-' +
|
|
735
|
+
this._pad(val.getUTCMonth() + 1) + '-' +
|
|
703
736
|
this._pad(val.getUTCDate());
|
|
704
737
|
}
|
|
705
738
|
else { // (! to)
|
|
706
739
|
// String in, date back
|
|
707
|
-
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/
|
|
740
|
+
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/);
|
|
708
741
|
return match ?
|
|
709
|
-
new Date(
|
|
742
|
+
new Date(match[1], match[2] - 1, match[3]) :
|
|
710
743
|
null;
|
|
711
744
|
}
|
|
712
745
|
}
|
|
@@ -716,7 +749,7 @@ $.extend( DateTime.prototype, {
|
|
|
716
749
|
? dateLib.DateTime.fromJSDate(val).toUTC()
|
|
717
750
|
: dateLib.DateTime.fromFormat(val, from);
|
|
718
751
|
|
|
719
|
-
if (!
|
|
752
|
+
if (!dtLux.isValid) {
|
|
720
753
|
return null;
|
|
721
754
|
}
|
|
722
755
|
|
|
@@ -727,10 +760,10 @@ $.extend( DateTime.prototype, {
|
|
|
727
760
|
else {
|
|
728
761
|
// Moment / DayJS
|
|
729
762
|
var dtMo = val instanceof Date
|
|
730
|
-
? dateLib.utc(
|
|
731
|
-
: dateLib(
|
|
732
|
-
|
|
733
|
-
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()) {
|
|
734
767
|
return null;
|
|
735
768
|
}
|
|
736
769
|
|
|
@@ -750,15 +783,15 @@ $.extend( DateTime.prototype, {
|
|
|
750
783
|
* @param {integer} month Month to set
|
|
751
784
|
* @private
|
|
752
785
|
*/
|
|
753
|
-
_correctMonth: function (
|
|
754
|
-
var days = this._daysInMonth(
|
|
786
|
+
_correctMonth: function (date, month) {
|
|
787
|
+
var days = this._daysInMonth(date.getUTCFullYear(), month);
|
|
755
788
|
var correctDays = date.getUTCDate() > days;
|
|
756
789
|
|
|
757
|
-
date.setUTCMonth(
|
|
790
|
+
date.setUTCMonth(month);
|
|
758
791
|
|
|
759
|
-
if (
|
|
760
|
-
date.setUTCDate(
|
|
761
|
-
date.setUTCMonth(
|
|
792
|
+
if (correctDays) {
|
|
793
|
+
date.setUTCDate(days);
|
|
794
|
+
date.setUTCMonth(month);
|
|
762
795
|
}
|
|
763
796
|
},
|
|
764
797
|
|
|
@@ -770,7 +803,7 @@ $.extend( DateTime.prototype, {
|
|
|
770
803
|
* @param {integer} month Month (starting at 0)
|
|
771
804
|
* @private
|
|
772
805
|
*/
|
|
773
|
-
_daysInMonth: function (
|
|
806
|
+
_daysInMonth: function (year, month) {
|
|
774
807
|
//
|
|
775
808
|
var isLeap = ((year % 4) === 0 && ((year % 100) !== 0 || (year % 400) === 0));
|
|
776
809
|
var months = [31, (isLeap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
@@ -786,15 +819,15 @@ $.extend( DateTime.prototype, {
|
|
|
786
819
|
* @param {Date} s Date to "convert"
|
|
787
820
|
* @return {Date} Shifted date
|
|
788
821
|
*/
|
|
789
|
-
_dateToUtc: function (
|
|
790
|
-
if (!
|
|
822
|
+
_dateToUtc: function (s) {
|
|
823
|
+
if (!s) {
|
|
791
824
|
return s;
|
|
792
825
|
}
|
|
793
826
|
|
|
794
|
-
return new Date(
|
|
827
|
+
return new Date(Date.UTC(
|
|
795
828
|
s.getFullYear(), s.getMonth(), s.getDate(),
|
|
796
829
|
s.getHours(), s.getMinutes(), s.getSeconds()
|
|
797
|
-
)
|
|
830
|
+
));
|
|
798
831
|
},
|
|
799
832
|
|
|
800
833
|
/**
|
|
@@ -803,13 +836,13 @@ $.extend( DateTime.prototype, {
|
|
|
803
836
|
* @param {Date} d Date to "convert"
|
|
804
837
|
* @return {string} ISO formatted date
|
|
805
838
|
*/
|
|
806
|
-
_dateToUtcString: function (
|
|
839
|
+
_dateToUtcString: function (d) {
|
|
807
840
|
// luxon uses different method names so need to be able to call them
|
|
808
841
|
return this._isLuxon()
|
|
809
842
|
? dateLib.DateTime.fromJSDate(d).toUTC().toISODate()
|
|
810
|
-
: d.getUTCFullYear()+'-'+
|
|
811
|
-
|
|
812
|
-
|
|
843
|
+
: d.getUTCFullYear() + '-' +
|
|
844
|
+
this._pad(d.getUTCMonth() + 1) + '-' +
|
|
845
|
+
this._pad(d.getUTCDate());
|
|
813
846
|
},
|
|
814
847
|
|
|
815
848
|
/**
|
|
@@ -818,7 +851,7 @@ $.extend( DateTime.prototype, {
|
|
|
818
851
|
* @private
|
|
819
852
|
*/
|
|
820
853
|
_hide: function (destroy) {
|
|
821
|
-
if (!
|
|
854
|
+
if (!destroy && this.dom.input.attr('type') === 'hidden') {
|
|
822
855
|
return;
|
|
823
856
|
}
|
|
824
857
|
|
|
@@ -826,12 +859,12 @@ $.extend( DateTime.prototype, {
|
|
|
826
859
|
|
|
827
860
|
this.dom.container.detach();
|
|
828
861
|
|
|
829
|
-
$(window).off(
|
|
830
|
-
$(document).off(
|
|
831
|
-
$('div.dataTables_scrollBody').off(
|
|
832
|
-
$('div.DTE_Body_Content').off(
|
|
833
|
-
$('body').off(
|
|
834
|
-
$(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);
|
|
835
868
|
},
|
|
836
869
|
|
|
837
870
|
/**
|
|
@@ -841,7 +874,7 @@ $.extend( DateTime.prototype, {
|
|
|
841
874
|
* @return {integer} 12 hour value
|
|
842
875
|
* @private
|
|
843
876
|
*/
|
|
844
|
-
_hours24To12: function (
|
|
877
|
+
_hours24To12: function (val) {
|
|
845
878
|
return val === 0 ?
|
|
846
879
|
12 :
|
|
847
880
|
val > 12 ?
|
|
@@ -857,31 +890,30 @@ $.extend( DateTime.prototype, {
|
|
|
857
890
|
* @param {object} day Day object from the `_htmlMonth` method
|
|
858
891
|
* @return {string} HTML cell
|
|
859
892
|
*/
|
|
860
|
-
_htmlDay: function(
|
|
861
|
-
|
|
862
|
-
if ( day.empty ) {
|
|
893
|
+
_htmlDay: function (day) {
|
|
894
|
+
if (day.empty) {
|
|
863
895
|
return '<td class="empty"></td>';
|
|
864
896
|
}
|
|
865
897
|
|
|
866
|
-
var classes = [
|
|
898
|
+
var classes = ['selectable'];
|
|
867
899
|
var classPrefix = this.c.classPrefix;
|
|
868
900
|
|
|
869
|
-
if (
|
|
870
|
-
classes.push(
|
|
901
|
+
if (day.disabled) {
|
|
902
|
+
classes.push('disabled');
|
|
871
903
|
}
|
|
872
904
|
|
|
873
|
-
if (
|
|
874
|
-
classes.push(
|
|
905
|
+
if (day.today) {
|
|
906
|
+
classes.push('now');
|
|
875
907
|
}
|
|
876
908
|
|
|
877
|
-
if (
|
|
878
|
-
classes.push(
|
|
909
|
+
if (day.selected) {
|
|
910
|
+
classes.push('selected');
|
|
879
911
|
}
|
|
880
912
|
|
|
881
913
|
return '<td data-day="' + day.day + '" class="' + classes.join(' ') + '">' +
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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>' +
|
|
885
917
|
'</td>';
|
|
886
918
|
},
|
|
887
919
|
|
|
@@ -898,14 +930,14 @@ $.extend( DateTime.prototype, {
|
|
|
898
930
|
* @return {string} Calendar month HTML
|
|
899
931
|
* @private
|
|
900
932
|
*/
|
|
901
|
-
_htmlMonth: function (
|
|
902
|
-
var now
|
|
903
|
-
days
|
|
904
|
-
before = new Date(
|
|
905
|
-
data
|
|
906
|
-
row
|
|
907
|
-
|
|
908
|
-
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) {
|
|
909
941
|
before -= this.c.firstDay;
|
|
910
942
|
|
|
911
943
|
if (before < 0) {
|
|
@@ -916,7 +948,7 @@ $.extend( DateTime.prototype, {
|
|
|
916
948
|
var cells = days + before,
|
|
917
949
|
after = cells;
|
|
918
950
|
|
|
919
|
-
while (
|
|
951
|
+
while (after > 7) {
|
|
920
952
|
after -= 7;
|
|
921
953
|
}
|
|
922
954
|
|
|
@@ -925,85 +957,85 @@ $.extend( DateTime.prototype, {
|
|
|
925
957
|
var minDate = this.c.minDate;
|
|
926
958
|
var maxDate = this.c.maxDate;
|
|
927
959
|
|
|
928
|
-
if (
|
|
960
|
+
if (minDate) {
|
|
929
961
|
minDate.setUTCHours(0);
|
|
930
962
|
minDate.setUTCMinutes(0);
|
|
931
963
|
minDate.setSeconds(0);
|
|
932
964
|
}
|
|
933
965
|
|
|
934
|
-
if (
|
|
966
|
+
if (maxDate) {
|
|
935
967
|
maxDate.setUTCHours(23);
|
|
936
968
|
maxDate.setUTCMinutes(59);
|
|
937
969
|
maxDate.setSeconds(59);
|
|
938
970
|
}
|
|
939
971
|
|
|
940
|
-
for (
|
|
941
|
-
var day
|
|
972
|
+
for (var i = 0, r = 0; i < cells; i++) {
|
|
973
|
+
var day = new Date(Date.UTC(year, month, 1 + (i - before))),
|
|
942
974
|
selected = this.s.d ? this._compareDates(day, this.s.d) : false,
|
|
943
|
-
today
|
|
944
|
-
empty
|
|
975
|
+
today = this._compareDates(day, now),
|
|
976
|
+
empty = i < before || i >= (days + before),
|
|
945
977
|
disabled = (minDate && day < minDate) ||
|
|
946
|
-
|
|
978
|
+
(maxDate && day > maxDate);
|
|
947
979
|
|
|
948
980
|
var disableDays = this.c.disableDays;
|
|
949
|
-
if (
|
|
981
|
+
if (Array.isArray(disableDays) && $.inArray(day.getUTCDay(), disableDays) !== -1) {
|
|
950
982
|
disabled = true;
|
|
951
983
|
}
|
|
952
|
-
else if (
|
|
984
|
+
else if (typeof disableDays === 'function' && disableDays(day) === true) {
|
|
953
985
|
disabled = true;
|
|
954
986
|
}
|
|
955
987
|
|
|
956
988
|
var dayConfig = {
|
|
957
|
-
day:
|
|
958
|
-
month:
|
|
959
|
-
year:
|
|
989
|
+
day: 1 + (i - before),
|
|
990
|
+
month: month,
|
|
991
|
+
year: year,
|
|
960
992
|
selected: selected,
|
|
961
|
-
today:
|
|
993
|
+
today: today,
|
|
962
994
|
disabled: disabled,
|
|
963
|
-
empty:
|
|
995
|
+
empty: empty
|
|
964
996
|
};
|
|
965
997
|
|
|
966
|
-
row.push(
|
|
998
|
+
row.push(this._htmlDay(dayConfig));
|
|
967
999
|
|
|
968
|
-
if (
|
|
969
|
-
if (
|
|
970
|
-
row.unshift(
|
|
1000
|
+
if (++r === 7) {
|
|
1001
|
+
if (this.c.showWeekNumber) {
|
|
1002
|
+
row.unshift(this._htmlWeekOfYear(i - before, month, year));
|
|
971
1003
|
}
|
|
972
1004
|
|
|
973
|
-
data.push(
|
|
1005
|
+
data.push('<tr>' + row.join('') + '</tr>');
|
|
974
1006
|
row = [];
|
|
975
1007
|
r = 0;
|
|
976
1008
|
}
|
|
977
1009
|
}
|
|
978
1010
|
|
|
979
1011
|
var classPrefix = this.c.classPrefix;
|
|
980
|
-
var className = classPrefix+'-table';
|
|
981
|
-
if (
|
|
1012
|
+
var className = classPrefix + '-table';
|
|
1013
|
+
if (this.c.showWeekNumber) {
|
|
982
1014
|
className += ' weekNumber';
|
|
983
1015
|
}
|
|
984
1016
|
|
|
985
1017
|
// Show / hide month icons based on min/max
|
|
986
|
-
if (
|
|
987
|
-
var underMin = minDate >= new Date(
|
|
1018
|
+
if (minDate) {
|
|
1019
|
+
var underMin = minDate >= new Date(Date.UTC(year, month, 1, 0, 0, 0));
|
|
988
1020
|
|
|
989
|
-
this.dom.title.find('div.'+classPrefix+'-iconLeft')
|
|
990
|
-
.css(
|
|
1021
|
+
this.dom.title.find('div.' + classPrefix + '-iconLeft')
|
|
1022
|
+
.css('display', underMin ? 'none' : 'block');
|
|
991
1023
|
}
|
|
992
1024
|
|
|
993
|
-
if (
|
|
994
|
-
var overMax = maxDate < new Date(
|
|
1025
|
+
if (maxDate) {
|
|
1026
|
+
var overMax = maxDate < new Date(Date.UTC(year, month + 1, 1, 0, 0, 0));
|
|
995
1027
|
|
|
996
|
-
this.dom.title.find('div.'+classPrefix+'-iconRight')
|
|
997
|
-
.css(
|
|
1028
|
+
this.dom.title.find('div.' + classPrefix + '-iconRight')
|
|
1029
|
+
.css('display', overMax ? 'none' : 'block');
|
|
998
1030
|
}
|
|
999
1031
|
|
|
1000
|
-
return '<table class="'+className+'">' +
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1032
|
+
return '<table class="' + className + '">' +
|
|
1033
|
+
'<thead>' +
|
|
1034
|
+
this._htmlMonthHead() +
|
|
1035
|
+
'</thead>' +
|
|
1036
|
+
'<tbody>' +
|
|
1037
|
+
data.join('') +
|
|
1038
|
+
'</tbody>' +
|
|
1007
1039
|
'</table>';
|
|
1008
1040
|
},
|
|
1009
1041
|
|
|
@@ -1019,7 +1051,7 @@ $.extend( DateTime.prototype, {
|
|
|
1019
1051
|
var i18n = this.c.i18n;
|
|
1020
1052
|
|
|
1021
1053
|
// Take account of the first day shift
|
|
1022
|
-
var dayName = function (
|
|
1054
|
+
var dayName = function (day) {
|
|
1023
1055
|
day += firstDay;
|
|
1024
1056
|
|
|
1025
1057
|
while (day >= 7) {
|
|
@@ -1028,14 +1060,14 @@ $.extend( DateTime.prototype, {
|
|
|
1028
1060
|
|
|
1029
1061
|
return i18n.weekdays[day];
|
|
1030
1062
|
};
|
|
1031
|
-
|
|
1063
|
+
|
|
1032
1064
|
// Empty cell in the header
|
|
1033
|
-
if (
|
|
1034
|
-
a.push(
|
|
1065
|
+
if (this.c.showWeekNumber) {
|
|
1066
|
+
a.push('<th></th>');
|
|
1035
1067
|
}
|
|
1036
1068
|
|
|
1037
|
-
for (
|
|
1038
|
-
a.push(
|
|
1069
|
+
for (var i = 0; i < 7; i++) {
|
|
1070
|
+
a.push('<th>' + dayName(i) + '</th>');
|
|
1039
1071
|
}
|
|
1040
1072
|
|
|
1041
1073
|
return a.join('');
|
|
@@ -1053,16 +1085,16 @@ $.extend( DateTime.prototype, {
|
|
|
1053
1085
|
* @return {string}
|
|
1054
1086
|
* @private
|
|
1055
1087
|
*/
|
|
1056
|
-
_htmlWeekOfYear: function (
|
|
1057
|
-
var date = new Date(
|
|
1088
|
+
_htmlWeekOfYear: function (d, m, y) {
|
|
1089
|
+
var date = new Date(y, m, d, 0, 0, 0, 0);
|
|
1058
1090
|
|
|
1059
1091
|
// First week of the year always has 4th January in it
|
|
1060
|
-
date.setDate(
|
|
1092
|
+
date.setDate(date.getDate() + 4 - (date.getDay() || 7));
|
|
1061
1093
|
|
|
1062
|
-
var oneJan = new Date(
|
|
1063
|
-
var weekNum = Math.ceil(
|
|
1094
|
+
var oneJan = new Date(y, 0, 1);
|
|
1095
|
+
var weekNum = Math.ceil((((date - oneJan) / 86400000) + 1) / 7);
|
|
1064
1096
|
|
|
1065
|
-
return '<td class="'+this.c.classPrefix+'-week">' + weekNum + '</td>';
|
|
1097
|
+
return '<td class="' + this.c.classPrefix + '-week">' + weekNum + '</td>';
|
|
1066
1098
|
},
|
|
1067
1099
|
|
|
1068
1100
|
/**
|
|
@@ -1083,10 +1115,10 @@ $.extend( DateTime.prototype, {
|
|
|
1083
1115
|
* @private
|
|
1084
1116
|
*/
|
|
1085
1117
|
_needValue: function () {
|
|
1086
|
-
if (
|
|
1087
|
-
this.s.d = this._dateToUtc(
|
|
1118
|
+
if (!this.s.d) {
|
|
1119
|
+
this.s.d = this._dateToUtc(new Date());
|
|
1088
1120
|
|
|
1089
|
-
if (!
|
|
1121
|
+
if (!this.s.parts.time) {
|
|
1090
1122
|
this.s.d.setUTCHours(0);
|
|
1091
1123
|
this.s.d.setUTCMinutes(0);
|
|
1092
1124
|
this.s.d.setSeconds(0);
|
|
@@ -1106,16 +1138,16 @@ $.extend( DateTime.prototype, {
|
|
|
1106
1138
|
* length as the values parameter.
|
|
1107
1139
|
* @private
|
|
1108
1140
|
*/
|
|
1109
|
-
_options: function (
|
|
1110
|
-
if (
|
|
1141
|
+
_options: function (selector, values, labels) {
|
|
1142
|
+
if (!labels) {
|
|
1111
1143
|
labels = values;
|
|
1112
1144
|
}
|
|
1113
1145
|
|
|
1114
|
-
var select = this.dom.container.find('select.'+this.c.classPrefix+'-'+selector);
|
|
1146
|
+
var select = this.dom.container.find('select.' + this.c.classPrefix + '-' + selector);
|
|
1115
1147
|
select.empty();
|
|
1116
1148
|
|
|
1117
|
-
for (
|
|
1118
|
-
select.append(
|
|
1149
|
+
for (var i = 0, ien = values.length; i < ien; i++) {
|
|
1150
|
+
select.append('<option value="' + values[i] + '">' + labels[i] + '</option>');
|
|
1119
1151
|
}
|
|
1120
1152
|
},
|
|
1121
1153
|
|
|
@@ -1127,14 +1159,14 @@ $.extend( DateTime.prototype, {
|
|
|
1127
1159
|
* @param {*} val Value to set
|
|
1128
1160
|
* @private
|
|
1129
1161
|
*/
|
|
1130
|
-
_optionSet: function (
|
|
1131
|
-
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);
|
|
1132
1164
|
var span = select.parent().children('span');
|
|
1133
1165
|
|
|
1134
|
-
select.val(
|
|
1166
|
+
select.val(val);
|
|
1135
1167
|
|
|
1136
1168
|
var selected = select.find('option:selected');
|
|
1137
|
-
span.html(
|
|
1169
|
+
span.html(selected.length !== 0 ?
|
|
1138
1170
|
selected.text() :
|
|
1139
1171
|
this.c.i18n.unknown
|
|
1140
1172
|
);
|
|
@@ -1150,18 +1182,17 @@ $.extend( DateTime.prototype, {
|
|
|
1150
1182
|
* @param {integer} range Override range
|
|
1151
1183
|
* @private
|
|
1152
1184
|
*/
|
|
1153
|
-
_optionsTime: function (
|
|
1185
|
+
_optionsTime: function (unit, count, val, allowed, range) {
|
|
1154
1186
|
var classPrefix = this.c.classPrefix;
|
|
1155
|
-
var container = this.dom.container.find('div.'+classPrefix+'-'+unit);
|
|
1187
|
+
var container = this.dom.container.find('div.' + classPrefix + '-' + unit);
|
|
1156
1188
|
var i, j;
|
|
1157
1189
|
var render = count === 12 ?
|
|
1158
1190
|
function (i) { return i; } :
|
|
1159
1191
|
this._pad;
|
|
1160
|
-
var
|
|
1161
|
-
var className = classPrefix+'-table';
|
|
1192
|
+
var className = classPrefix + '-table';
|
|
1162
1193
|
var i18n = this.c.i18n;
|
|
1163
1194
|
|
|
1164
|
-
if (
|
|
1195
|
+
if (!container.length) {
|
|
1165
1196
|
return;
|
|
1166
1197
|
}
|
|
1167
1198
|
|
|
@@ -1169,8 +1200,8 @@ $.extend( DateTime.prototype, {
|
|
|
1169
1200
|
var span = 10;
|
|
1170
1201
|
var button = function (value, label, className) {
|
|
1171
1202
|
// Shift the value for PM
|
|
1172
|
-
if (
|
|
1173
|
-
if (val >= 12
|
|
1203
|
+
if (count === 12 && typeof value === 'number') {
|
|
1204
|
+
if (val >= 12) {
|
|
1174
1205
|
value += 12;
|
|
1175
1206
|
}
|
|
1176
1207
|
|
|
@@ -1185,27 +1216,27 @@ $.extend( DateTime.prototype, {
|
|
|
1185
1216
|
var selected = val === value || (value === 'am' && val < 12) || (value === 'pm' && val >= 12) ?
|
|
1186
1217
|
'selected' :
|
|
1187
1218
|
'';
|
|
1188
|
-
|
|
1219
|
+
|
|
1189
1220
|
if (typeof value === 'number' && allowed && $.inArray(value, allowed) === -1) {
|
|
1190
1221
|
selected += ' disabled';
|
|
1191
1222
|
}
|
|
1192
1223
|
|
|
1193
|
-
if (
|
|
1194
|
-
selected += ' '+className;
|
|
1224
|
+
if (className) {
|
|
1225
|
+
selected += ' ' + className;
|
|
1195
1226
|
}
|
|
1196
1227
|
|
|
1197
|
-
return '<td class="selectable '+selected+'">' +
|
|
1198
|
-
'<button class="'+classPrefix+'-button '+classPrefix+'-day" type="button" data-unit="'+unit+'" data-value="'+value+ '">' +
|
|
1199
|
-
|
|
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>' +
|
|
1200
1231
|
'</button>' +
|
|
1201
|
-
|
|
1232
|
+
'</td>';
|
|
1202
1233
|
}
|
|
1203
1234
|
|
|
1204
|
-
if (
|
|
1235
|
+
if (count === 12) {
|
|
1205
1236
|
// Hours with AM/PM
|
|
1206
1237
|
a += '<tr>';
|
|
1207
|
-
|
|
1208
|
-
for (
|
|
1238
|
+
|
|
1239
|
+
for (i = 1; i <= 6; i++) {
|
|
1209
1240
|
a += button(i, render(i));
|
|
1210
1241
|
}
|
|
1211
1242
|
a += button('am', i18n.amPm[0]);
|
|
@@ -1213,7 +1244,7 @@ $.extend( DateTime.prototype, {
|
|
|
1213
1244
|
a += '</tr>';
|
|
1214
1245
|
a += '<tr>';
|
|
1215
1246
|
|
|
1216
|
-
for (
|
|
1247
|
+
for (i = 7; i <= 12; i++) {
|
|
1217
1248
|
a += button(i, render(i));
|
|
1218
1249
|
}
|
|
1219
1250
|
a += button('pm', i18n.amPm[1]);
|
|
@@ -1221,12 +1252,12 @@ $.extend( DateTime.prototype, {
|
|
|
1221
1252
|
|
|
1222
1253
|
span = 7;
|
|
1223
1254
|
}
|
|
1224
|
-
else if (
|
|
1255
|
+
else if (count === 24) {
|
|
1225
1256
|
// Hours - 24
|
|
1226
1257
|
var c = 0;
|
|
1227
|
-
for (j=0
|
|
1258
|
+
for (j = 0; j < 4; j++) {
|
|
1228
1259
|
a += '<tr>';
|
|
1229
|
-
for (
|
|
1260
|
+
for (i = 0; i < 6; i++) {
|
|
1230
1261
|
a += button(c, render(c));
|
|
1231
1262
|
c++;
|
|
1232
1263
|
}
|
|
@@ -1238,22 +1269,22 @@ $.extend( DateTime.prototype, {
|
|
|
1238
1269
|
else {
|
|
1239
1270
|
// Minutes and seconds
|
|
1240
1271
|
a += '<tr>';
|
|
1241
|
-
for (j=0
|
|
1272
|
+
for (j = 0; j < 60; j += 10) {
|
|
1242
1273
|
a += button(j, render(j), 'range');
|
|
1243
1274
|
}
|
|
1244
1275
|
a += '</tr>';
|
|
1245
|
-
|
|
1276
|
+
|
|
1246
1277
|
// Slight hack to allow for the different number of columns
|
|
1247
|
-
a += '</tbody></thead><table class="'+className+' '+className+'-nospace"><tbody>';
|
|
1278
|
+
a += '</tbody></thead><table class="' + className + ' ' + className + '-nospace"><tbody>';
|
|
1248
1279
|
|
|
1249
1280
|
var start = range !== null
|
|
1250
1281
|
? range
|
|
1251
1282
|
: val === -1
|
|
1252
1283
|
? 0
|
|
1253
|
-
: Math.floor(
|
|
1284
|
+
: Math.floor(val / 10) * 10;
|
|
1254
1285
|
|
|
1255
1286
|
a += '<tr>';
|
|
1256
|
-
for (j=start+1
|
|
1287
|
+
for (j = start + 1; j < start + 10; j++) {
|
|
1257
1288
|
a += button(j, render(j));
|
|
1258
1289
|
}
|
|
1259
1290
|
a += '</tr>';
|
|
@@ -1264,13 +1295,13 @@ $.extend( DateTime.prototype, {
|
|
|
1264
1295
|
container
|
|
1265
1296
|
.empty()
|
|
1266
1297
|
.append(
|
|
1267
|
-
'<table class="'+className+'">'+
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1298
|
+
'<table class="' + className + '">' +
|
|
1299
|
+
'<thead><tr><th colspan="' + span + '">' +
|
|
1300
|
+
i18n[unit] +
|
|
1301
|
+
'</th></tr></thead>' +
|
|
1302
|
+
'<tbody>' +
|
|
1303
|
+
a +
|
|
1304
|
+
'</tbody>' +
|
|
1274
1305
|
'</table>'
|
|
1275
1306
|
);
|
|
1276
1307
|
},
|
|
@@ -1292,8 +1323,8 @@ $.extend( DateTime.prototype, {
|
|
|
1292
1323
|
var i = minYear !== null ? minYear : new Date().getFullYear() - this.c.yearRange;
|
|
1293
1324
|
var j = maxYear !== null ? maxYear : new Date().getFullYear() + this.c.yearRange;
|
|
1294
1325
|
|
|
1295
|
-
this._options(
|
|
1296
|
-
this._options(
|
|
1326
|
+
this._options('month', this._range(0, 11), i18n.months);
|
|
1327
|
+
this._options('year', this._range(i, j));
|
|
1297
1328
|
|
|
1298
1329
|
// Set the language strings in case any have changed
|
|
1299
1330
|
this.dom.today.text(i18n.today).text(i18n.today);
|
|
@@ -1315,8 +1346,8 @@ $.extend( DateTime.prototype, {
|
|
|
1315
1346
|
* @return {string|integer} Padded value
|
|
1316
1347
|
* @private
|
|
1317
1348
|
*/
|
|
1318
|
-
_pad: function (
|
|
1319
|
-
return i<10 ? '0'+i : i;
|
|
1349
|
+
_pad: function (i) {
|
|
1350
|
+
return i < 10 ? '0' + i : i;
|
|
1320
1351
|
},
|
|
1321
1352
|
|
|
1322
1353
|
/**
|
|
@@ -1329,32 +1360,32 @@ $.extend( DateTime.prototype, {
|
|
|
1329
1360
|
var inputHeight = this.dom.input.outerHeight();
|
|
1330
1361
|
|
|
1331
1362
|
if (container.hasClass('inline')) {
|
|
1332
|
-
container.insertAfter(
|
|
1363
|
+
container.insertAfter(this.dom.input);
|
|
1333
1364
|
return;
|
|
1334
1365
|
}
|
|
1335
1366
|
|
|
1336
|
-
if (
|
|
1367
|
+
if (this.s.parts.date && this.s.parts.time && $(window).width() > 550) {
|
|
1337
1368
|
container.addClass('horizontal');
|
|
1338
1369
|
}
|
|
1339
1370
|
else {
|
|
1340
1371
|
container.removeClass('horizontal');
|
|
1341
1372
|
}
|
|
1342
1373
|
|
|
1343
|
-
if(this.c.attachTo === 'input') {
|
|
1374
|
+
if (this.c.attachTo === 'input') {
|
|
1344
1375
|
container
|
|
1345
|
-
.css(
|
|
1376
|
+
.css({
|
|
1346
1377
|
top: offset.top + inputHeight,
|
|
1347
1378
|
left: offset.left
|
|
1348
|
-
}
|
|
1349
|
-
.insertAfter(
|
|
1379
|
+
})
|
|
1380
|
+
.insertAfter(this.dom.input);
|
|
1350
1381
|
}
|
|
1351
1382
|
else {
|
|
1352
1383
|
container
|
|
1353
|
-
.css(
|
|
1384
|
+
.css({
|
|
1354
1385
|
top: offset.top + inputHeight,
|
|
1355
1386
|
left: offset.left
|
|
1356
|
-
}
|
|
1357
|
-
.appendTo(
|
|
1387
|
+
})
|
|
1388
|
+
.appendTo('body');
|
|
1358
1389
|
}
|
|
1359
1390
|
|
|
1360
1391
|
var calHeight = container.outerHeight();
|
|
@@ -1362,14 +1393,14 @@ $.extend( DateTime.prototype, {
|
|
|
1362
1393
|
var scrollTop = $(window).scrollTop();
|
|
1363
1394
|
|
|
1364
1395
|
// Correct to the bottom
|
|
1365
|
-
if (
|
|
1396
|
+
if (offset.top + inputHeight + calHeight - scrollTop > $(window).height()) {
|
|
1366
1397
|
var newTop = offset.top - calHeight;
|
|
1367
1398
|
|
|
1368
|
-
container.css(
|
|
1399
|
+
container.css('top', newTop < 0 ? 0 : newTop);
|
|
1369
1400
|
}
|
|
1370
1401
|
|
|
1371
1402
|
// Correct to the right
|
|
1372
|
-
if (
|
|
1403
|
+
if (calWidth + offset.left > $(window).width()) {
|
|
1373
1404
|
var newLeft = $(window).width() - calWidth;
|
|
1374
1405
|
|
|
1375
1406
|
// Account for elements which are inside a position absolute element
|
|
@@ -1377,7 +1408,7 @@ $.extend( DateTime.prototype, {
|
|
|
1377
1408
|
newLeft -= $(container).offsetParent().offset().left;
|
|
1378
1409
|
}
|
|
1379
1410
|
|
|
1380
|
-
container.css(
|
|
1411
|
+
container.css('left', newLeft < 0 ? 0 : newLeft);
|
|
1381
1412
|
}
|
|
1382
1413
|
},
|
|
1383
1414
|
|
|
@@ -1390,15 +1421,15 @@ $.extend( DateTime.prototype, {
|
|
|
1390
1421
|
* @return {array} Created array
|
|
1391
1422
|
* @private
|
|
1392
1423
|
*/
|
|
1393
|
-
_range: function (
|
|
1424
|
+
_range: function (start, end, inc) {
|
|
1394
1425
|
var a = [];
|
|
1395
1426
|
|
|
1396
|
-
if (
|
|
1427
|
+
if (!inc) {
|
|
1397
1428
|
inc = 1;
|
|
1398
1429
|
}
|
|
1399
1430
|
|
|
1400
|
-
for (
|
|
1401
|
-
a.push(
|
|
1431
|
+
for (var i = start; i <= end; i += inc) {
|
|
1432
|
+
a.push(i);
|
|
1402
1433
|
}
|
|
1403
1434
|
|
|
1404
1435
|
return a;
|
|
@@ -1411,13 +1442,13 @@ $.extend( DateTime.prototype, {
|
|
|
1411
1442
|
* @private
|
|
1412
1443
|
*/
|
|
1413
1444
|
_setCalander: function () {
|
|
1414
|
-
if (
|
|
1445
|
+
if (this.s.display) {
|
|
1415
1446
|
this.dom.calendar
|
|
1416
1447
|
.empty()
|
|
1417
|
-
.append(
|
|
1448
|
+
.append(this._htmlMonth(
|
|
1418
1449
|
this.s.display.getUTCFullYear(),
|
|
1419
1450
|
this.s.display.getUTCMonth()
|
|
1420
|
-
)
|
|
1451
|
+
));
|
|
1421
1452
|
}
|
|
1422
1453
|
},
|
|
1423
1454
|
|
|
@@ -1427,8 +1458,8 @@ $.extend( DateTime.prototype, {
|
|
|
1427
1458
|
* @private
|
|
1428
1459
|
*/
|
|
1429
1460
|
_setTitle: function () {
|
|
1430
|
-
this._optionSet(
|
|
1431
|
-
this._optionSet(
|
|
1461
|
+
this._optionSet('month', this.s.display.getUTCMonth());
|
|
1462
|
+
this._optionSet('year', this.s.display.getUTCFullYear());
|
|
1432
1463
|
},
|
|
1433
1464
|
|
|
1434
1465
|
/**
|
|
@@ -1439,7 +1470,7 @@ $.extend( DateTime.prototype, {
|
|
|
1439
1470
|
_setTime: function () {
|
|
1440
1471
|
var that = this;
|
|
1441
1472
|
var d = this.s.d;
|
|
1442
|
-
|
|
1473
|
+
|
|
1443
1474
|
// luxon uses different method names so need to be able to call them. This happens a few time later in this method too
|
|
1444
1475
|
var luxDT = null
|
|
1445
1476
|
if (this._isLuxon()) {
|
|
@@ -1452,13 +1483,13 @@ $.extend( DateTime.prototype, {
|
|
|
1452
1483
|
? d.getUTCHours()
|
|
1453
1484
|
: -1;
|
|
1454
1485
|
|
|
1455
|
-
var allowed = function (
|
|
1456
|
-
return that.c[prop+'Available'] ?
|
|
1457
|
-
that.c[prop+'Available'] :
|
|
1458
|
-
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']);
|
|
1459
1490
|
}
|
|
1460
1491
|
|
|
1461
|
-
this._optionsTime(
|
|
1492
|
+
this._optionsTime('hours', this.s.parts.hours12 ? 12 : 24, hours, this.c.hoursAvailable)
|
|
1462
1493
|
this._optionsTime(
|
|
1463
1494
|
'minutes',
|
|
1464
1495
|
60,
|
|
@@ -1496,50 +1527,50 @@ $.extend( DateTime.prototype, {
|
|
|
1496
1527
|
this._position();
|
|
1497
1528
|
|
|
1498
1529
|
// Need to reposition on scroll
|
|
1499
|
-
$(window).on(
|
|
1530
|
+
$(window).on('scroll.' + namespace + ' resize.' + namespace, function () {
|
|
1500
1531
|
that._position();
|
|
1501
|
-
}
|
|
1532
|
+
});
|
|
1502
1533
|
|
|
1503
|
-
$('div.DTE_Body_Content').on(
|
|
1534
|
+
$('div.DTE_Body_Content').on('scroll.' + namespace, function () {
|
|
1504
1535
|
that._position();
|
|
1505
|
-
}
|
|
1536
|
+
});
|
|
1506
1537
|
|
|
1507
|
-
$('div.dataTables_scrollBody').on(
|
|
1538
|
+
$('div.dataTables_scrollBody').on('scroll.' + namespace, function () {
|
|
1508
1539
|
that._position();
|
|
1509
|
-
}
|
|
1540
|
+
});
|
|
1510
1541
|
|
|
1511
1542
|
var offsetParent = this.dom.input[0].offsetParent;
|
|
1512
1543
|
|
|
1513
|
-
if (
|
|
1514
|
-
$(offsetParent).on(
|
|
1544
|
+
if (offsetParent !== document.body) {
|
|
1545
|
+
$(offsetParent).on('scroll.' + namespace, function () {
|
|
1515
1546
|
that._position();
|
|
1516
|
-
}
|
|
1547
|
+
});
|
|
1517
1548
|
}
|
|
1518
1549
|
|
|
1519
1550
|
// On tab focus will move to a different field (no keyboard navigation
|
|
1520
1551
|
// in the date picker - this might need to be changed).
|
|
1521
|
-
$(document).on(
|
|
1552
|
+
$(document).on('keydown.' + namespace, function (e) {
|
|
1522
1553
|
if (
|
|
1523
|
-
e.keyCode === 9
|
|
1554
|
+
e.keyCode === 9 || // tab
|
|
1524
1555
|
e.keyCode === 27 || // esc
|
|
1525
1556
|
e.keyCode === 13 // return
|
|
1526
1557
|
) {
|
|
1527
1558
|
that._hide();
|
|
1528
1559
|
}
|
|
1529
|
-
}
|
|
1560
|
+
});
|
|
1530
1561
|
|
|
1531
1562
|
// Hide if clicking outside of the widget - but in a different click
|
|
1532
1563
|
// event from the one that was used to trigger the show (bubble and
|
|
1533
1564
|
// inline)
|
|
1534
|
-
setTimeout(
|
|
1535
|
-
$('body').on(
|
|
1565
|
+
setTimeout(function () {
|
|
1566
|
+
$('body').on('click.' + namespace, function (e) {
|
|
1536
1567
|
var parents = $(e.target).parents();
|
|
1537
1568
|
|
|
1538
|
-
if (
|
|
1569
|
+
if (!parents.filter(that.dom.container).length && e.target !== that.dom.input[0]) {
|
|
1539
1570
|
that._hide();
|
|
1540
1571
|
}
|
|
1541
|
-
}
|
|
1542
|
-
}, 10
|
|
1572
|
+
});
|
|
1573
|
+
}, 10);
|
|
1543
1574
|
},
|
|
1544
1575
|
|
|
1545
1576
|
/**
|
|
@@ -1548,27 +1579,31 @@ $.extend( DateTime.prototype, {
|
|
|
1548
1579
|
*
|
|
1549
1580
|
* @private
|
|
1550
1581
|
*/
|
|
1551
|
-
_writeOutput: function (
|
|
1582
|
+
_writeOutput: function (focus) {
|
|
1552
1583
|
var date = this.s.d;
|
|
1553
1584
|
var out = '';
|
|
1585
|
+
var input = this.dom.input;
|
|
1554
1586
|
|
|
1555
1587
|
if (date) {
|
|
1556
1588
|
out = this._convert(date, null, this.c.format);
|
|
1557
1589
|
}
|
|
1558
1590
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1591
|
+
input.val(out);
|
|
1592
|
+
|
|
1593
|
+
// Create a DOM synthetic event. Can't use $().trigger() as
|
|
1594
|
+
// that doesn't actually trigger non-jQuery event listeners
|
|
1595
|
+
var event = new Event('change', { bubbles: true });
|
|
1596
|
+
input[0].dispatchEvent(event);
|
|
1597
|
+
|
|
1598
|
+
if (input.attr('type') === 'hidden') {
|
|
1564
1599
|
this.val(out, false);
|
|
1565
1600
|
}
|
|
1566
1601
|
|
|
1567
|
-
if (
|
|
1568
|
-
|
|
1602
|
+
if (focus) {
|
|
1603
|
+
input.focus();
|
|
1569
1604
|
}
|
|
1570
1605
|
}
|
|
1571
|
-
}
|
|
1606
|
+
});
|
|
1572
1607
|
|
|
1573
1608
|
/**
|
|
1574
1609
|
* Use a specificmoment compatible date library
|
|
@@ -1617,17 +1652,17 @@ DateTime.defaults = {
|
|
|
1617
1652
|
hoursAvailable: null,
|
|
1618
1653
|
|
|
1619
1654
|
i18n: {
|
|
1620
|
-
clear:
|
|
1655
|
+
clear: 'Clear',
|
|
1621
1656
|
previous: 'Previous',
|
|
1622
|
-
next:
|
|
1623
|
-
months:
|
|
1624
|
-
weekdays: [
|
|
1625
|
-
amPm:
|
|
1626
|
-
hours:
|
|
1627
|
-
minutes:
|
|
1628
|
-
seconds:
|
|
1629
|
-
unknown:
|
|
1630
|
-
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'
|
|
1631
1666
|
},
|
|
1632
1667
|
|
|
1633
1668
|
maxDate: null,
|
|
@@ -1642,7 +1677,7 @@ DateTime.defaults = {
|
|
|
1642
1677
|
|
|
1643
1678
|
locale: 'en',
|
|
1644
1679
|
|
|
1645
|
-
onChange: function () {},
|
|
1680
|
+
onChange: function () { },
|
|
1646
1681
|
|
|
1647
1682
|
secondsAvailable: null,
|
|
1648
1683
|
|
|
@@ -1655,7 +1690,7 @@ DateTime.defaults = {
|
|
|
1655
1690
|
yearRange: 25
|
|
1656
1691
|
};
|
|
1657
1692
|
|
|
1658
|
-
DateTime.version = '1.
|
|
1693
|
+
DateTime.version = '1.5.2';
|
|
1659
1694
|
|
|
1660
1695
|
/**
|
|
1661
1696
|
* CommonJS factory function pass through. Matches DataTables.
|
|
@@ -1682,7 +1717,7 @@ DateTime.factory = function (root, jq) {
|
|
|
1682
1717
|
}
|
|
1683
1718
|
|
|
1684
1719
|
// Global export - if no conflicts
|
|
1685
|
-
if (!
|
|
1720
|
+
if (!window.DateTime) {
|
|
1686
1721
|
window.DateTime = DateTime;
|
|
1687
1722
|
}
|
|
1688
1723
|
|
|
@@ -1693,7 +1728,7 @@ if (window.DataTable) {
|
|
|
1693
1728
|
|
|
1694
1729
|
// Make available via jQuery
|
|
1695
1730
|
$.fn.dtDateTime = function (options) {
|
|
1696
|
-
return this.each(function() {
|
|
1731
|
+
return this.each(function () {
|
|
1697
1732
|
new DateTime(this, options);
|
|
1698
1733
|
});
|
|
1699
1734
|
}
|