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