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