datatables.net-datetime 1.5.4 → 1.5.6

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.
@@ -1,4 +1,4 @@
1
- /*! DateTime picker for DataTables.net v1.5.4
1
+ /*! DateTime picker for DataTables.net v1.5.6
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.5.4
15
+ * @version 1.5.6
16
16
  * @file dataTables.dateTime.js
17
17
  * @author SpryMedia Ltd
18
18
  * @contact www.datatables.net/contact
@@ -41,7 +41,7 @@ var dateLib;
41
41
  * options based on the `DateTime.defaults` object.
42
42
  */
43
43
  var DateTime = function (input, opts) {
44
- // Check if called with a window or jQuery object for DOM less applications
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)) {
47
47
  return DateTime;
@@ -67,6 +67,10 @@ var DateTime = function (input, opts) {
67
67
  throw "DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";
68
68
  }
69
69
 
70
+ if (this._isLuxon() && this.c.format == 'YYYY-MM-DD') {
71
+ this.c.format = 'yyyy-MM-dd'
72
+ }
73
+
70
74
  // Min and max need to be `Date` objects in the config
71
75
  if (typeof this.c.minDate === 'string') {
72
76
  this.c.minDate = new Date(this.c.minDate);
@@ -143,11 +147,14 @@ var DateTime = function (input, opts) {
143
147
 
144
148
  /** @type {Object} Parts of the picker that should be shown */
145
149
  parts: {
146
- date: this.c.format.match(/[YMD]|L(?!T)|l/) !== null,
150
+ date: this.c.format.match(/[yYMDd]|L(?!T)|l/) !== null,
147
151
  time: this.c.format.match(/[Hhm]|LT|LTS/) !== null,
148
152
  seconds: this.c.format.indexOf('s') !== -1,
149
153
  hours12: this.c.format.match(/[haA]/) !== null
150
- }
154
+ },
155
+
156
+ /** Timeout when showing the control to listen for a blur */
157
+ showTo: null
151
158
  };
152
159
 
153
160
  this.dom.container
@@ -174,6 +181,7 @@ $.extend(DateTime.prototype, {
174
181
  * Destroy the control
175
182
  */
176
183
  destroy: function () {
184
+ clearTimeout(this.s.showTo);
177
185
  this._hide(true);
178
186
  this.dom.container.off().empty();
179
187
  this.dom.input
@@ -267,6 +275,8 @@ $.extend(DateTime.prototype, {
267
275
  return this.s.d;
268
276
  }
269
277
 
278
+ var oldVal = this.s.d;
279
+
270
280
  if (set instanceof Date) {
271
281
  this.s.d = this._dateToUtc(set);
272
282
  }
@@ -284,7 +294,12 @@ $.extend(DateTime.prototype, {
284
294
 
285
295
  if (write || write === undefined) {
286
296
  if (this.s.d) {
287
- this._writeOutput();
297
+ this._writeOutput(
298
+ false,
299
+ (oldVal === null && this.s.d !== null) ||
300
+ (oldVal !== null && this.s.d === null) ||
301
+ oldVal.toString() !== this.s.d.toString()
302
+ );
288
303
  }
289
304
  else {
290
305
  // The input value was not valid...
@@ -855,12 +870,12 @@ $.extend(DateTime.prototype, {
855
870
  * @return {string} HTML cell
856
871
  */
857
872
  _htmlDay: function (day) {
873
+ var classPrefix = this.c.classPrefix;
858
874
  if (day.empty) {
859
- return '<td class="empty"></td>';
875
+ return '<td class="' + classPrefix + '-empty"></td>';
860
876
  }
861
877
 
862
878
  var classes = ['selectable'];
863
- var classPrefix = this.c.classPrefix;
864
879
 
865
880
  if (day.disabled) {
866
881
  classes.push('disabled');
@@ -1523,6 +1538,29 @@ $.extend(DateTime.prototype, {
1523
1538
  }
1524
1539
  });
1525
1540
 
1541
+ clearTimeout(this.s.showTo);
1542
+
1543
+ // We can't use blur to hide, as we want to keep the picker open while
1544
+ // to let the user select from it. But if focus is moved outside of of
1545
+ // the picker, then we auto hide.
1546
+ this.dom.input.on('blur', function (e) {
1547
+ that.s.showTo = setTimeout(function () {
1548
+ let name = document.activeElement.tagName.toLowerCase();
1549
+
1550
+ if (document.activeElement === that.dom.input[0]) {
1551
+ return;
1552
+ }
1553
+
1554
+ if (that.dom.container.find(document.activeElement).length) {
1555
+ return;
1556
+ }
1557
+
1558
+ if (['input', 'select', 'button'].includes(name)) {
1559
+ that.hide();
1560
+ }
1561
+ }, 10);
1562
+ });
1563
+
1526
1564
  // Hide if clicking outside of the widget - but in a different click
1527
1565
  // event from the one that was used to trigger the show (bubble and
1528
1566
  // inline)
@@ -1543,7 +1581,7 @@ $.extend(DateTime.prototype, {
1543
1581
  *
1544
1582
  * @private
1545
1583
  */
1546
- _writeOutput: function (focus) {
1584
+ _writeOutput: function (focus, change) {
1547
1585
  var date = this.s.d;
1548
1586
  var out = '';
1549
1587
  var input = this.dom.input;
@@ -1554,10 +1592,12 @@ $.extend(DateTime.prototype, {
1554
1592
 
1555
1593
  input.val(out);
1556
1594
 
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);
1595
+ if (change === undefined || change) {
1596
+ // Create a DOM synthetic event. Can't use $().trigger() as
1597
+ // that doesn't actually trigger non-jQuery event listeners
1598
+ var event = new Event('change', { bubbles: true });
1599
+ input[0].dispatchEvent(event);
1600
+ }
1561
1601
 
1562
1602
  if (input.attr('type') === 'hidden') {
1563
1603
  this.val(out, false);
@@ -1654,7 +1694,7 @@ DateTime.defaults = {
1654
1694
  yearRange: 25
1655
1695
  };
1656
1696
 
1657
- DateTime.version = '1.5.4';
1697
+ DateTime.version = '1.5.6';
1658
1698
 
1659
1699
  /**
1660
1700
  * CommonJS factory function pass through. Matches DataTables.
@@ -35,7 +35,7 @@ interface IDateTimeOptions {
35
35
  }
36
36
 
37
37
  export class DateTime {
38
- static use(moment: any); // Moment library
38
+ static use(moment: any): void; // Moment library
39
39
 
40
40
  constructor(el: HTMLElement, opts?: IDateTimeOptions);
41
41
 
@@ -1,4 +1,4 @@
1
- /*! DateTime picker for DataTables.net v1.5.4
1
+ /*! DateTime picker for DataTables.net v1.5.6
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.5.4
9
+ * @version 1.5.6
10
10
  * @file dataTables.dateTime.js
11
11
  * @author SpryMedia Ltd
12
12
  * @contact www.datatables.net/contact
@@ -35,7 +35,7 @@ var dateLib;
35
35
  * options based on the `DateTime.defaults` object.
36
36
  */
37
37
  var DateTime = function (input, opts) {
38
- // Check if called with a window or jQuery object for DOM less applications
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)) {
41
41
  return DateTime;
@@ -61,6 +61,10 @@ var DateTime = function (input, opts) {
61
61
  throw "DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";
62
62
  }
63
63
 
64
+ if (this._isLuxon() && this.c.format == 'YYYY-MM-DD') {
65
+ this.c.format = 'yyyy-MM-dd'
66
+ }
67
+
64
68
  // Min and max need to be `Date` objects in the config
65
69
  if (typeof this.c.minDate === 'string') {
66
70
  this.c.minDate = new Date(this.c.minDate);
@@ -137,11 +141,14 @@ var DateTime = function (input, opts) {
137
141
 
138
142
  /** @type {Object} Parts of the picker that should be shown */
139
143
  parts: {
140
- date: this.c.format.match(/[YMD]|L(?!T)|l/) !== null,
144
+ date: this.c.format.match(/[yYMDd]|L(?!T)|l/) !== null,
141
145
  time: this.c.format.match(/[Hhm]|LT|LTS/) !== null,
142
146
  seconds: this.c.format.indexOf('s') !== -1,
143
147
  hours12: this.c.format.match(/[haA]/) !== null
144
- }
148
+ },
149
+
150
+ /** Timeout when showing the control to listen for a blur */
151
+ showTo: null
145
152
  };
146
153
 
147
154
  this.dom.container
@@ -168,6 +175,7 @@ $.extend(DateTime.prototype, {
168
175
  * Destroy the control
169
176
  */
170
177
  destroy: function () {
178
+ clearTimeout(this.s.showTo);
171
179
  this._hide(true);
172
180
  this.dom.container.off().empty();
173
181
  this.dom.input
@@ -261,6 +269,8 @@ $.extend(DateTime.prototype, {
261
269
  return this.s.d;
262
270
  }
263
271
 
272
+ var oldVal = this.s.d;
273
+
264
274
  if (set instanceof Date) {
265
275
  this.s.d = this._dateToUtc(set);
266
276
  }
@@ -278,7 +288,12 @@ $.extend(DateTime.prototype, {
278
288
 
279
289
  if (write || write === undefined) {
280
290
  if (this.s.d) {
281
- this._writeOutput();
291
+ this._writeOutput(
292
+ false,
293
+ (oldVal === null && this.s.d !== null) ||
294
+ (oldVal !== null && this.s.d === null) ||
295
+ oldVal.toString() !== this.s.d.toString()
296
+ );
282
297
  }
283
298
  else {
284
299
  // The input value was not valid...
@@ -849,12 +864,12 @@ $.extend(DateTime.prototype, {
849
864
  * @return {string} HTML cell
850
865
  */
851
866
  _htmlDay: function (day) {
867
+ var classPrefix = this.c.classPrefix;
852
868
  if (day.empty) {
853
- return '<td class="empty"></td>';
869
+ return '<td class="' + classPrefix + '-empty"></td>';
854
870
  }
855
871
 
856
872
  var classes = ['selectable'];
857
- var classPrefix = this.c.classPrefix;
858
873
 
859
874
  if (day.disabled) {
860
875
  classes.push('disabled');
@@ -1517,6 +1532,29 @@ $.extend(DateTime.prototype, {
1517
1532
  }
1518
1533
  });
1519
1534
 
1535
+ clearTimeout(this.s.showTo);
1536
+
1537
+ // We can't use blur to hide, as we want to keep the picker open while
1538
+ // to let the user select from it. But if focus is moved outside of of
1539
+ // the picker, then we auto hide.
1540
+ this.dom.input.on('blur', function (e) {
1541
+ that.s.showTo = setTimeout(function () {
1542
+ let name = document.activeElement.tagName.toLowerCase();
1543
+
1544
+ if (document.activeElement === that.dom.input[0]) {
1545
+ return;
1546
+ }
1547
+
1548
+ if (that.dom.container.find(document.activeElement).length) {
1549
+ return;
1550
+ }
1551
+
1552
+ if (['input', 'select', 'button'].includes(name)) {
1553
+ that.hide();
1554
+ }
1555
+ }, 10);
1556
+ });
1557
+
1520
1558
  // Hide if clicking outside of the widget - but in a different click
1521
1559
  // event from the one that was used to trigger the show (bubble and
1522
1560
  // inline)
@@ -1537,7 +1575,7 @@ $.extend(DateTime.prototype, {
1537
1575
  *
1538
1576
  * @private
1539
1577
  */
1540
- _writeOutput: function (focus) {
1578
+ _writeOutput: function (focus, change) {
1541
1579
  var date = this.s.d;
1542
1580
  var out = '';
1543
1581
  var input = this.dom.input;
@@ -1548,10 +1586,12 @@ $.extend(DateTime.prototype, {
1548
1586
 
1549
1587
  input.val(out);
1550
1588
 
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);
1589
+ if (change === undefined || change) {
1590
+ // Create a DOM synthetic event. Can't use $().trigger() as
1591
+ // that doesn't actually trigger non-jQuery event listeners
1592
+ var event = new Event('change', { bubbles: true });
1593
+ input[0].dispatchEvent(event);
1594
+ }
1555
1595
 
1556
1596
  if (input.attr('type') === 'hidden') {
1557
1597
  this.val(out, false);
@@ -1648,7 +1688,7 @@ DateTime.defaults = {
1648
1688
  yearRange: 25
1649
1689
  };
1650
1690
 
1651
- DateTime.version = '1.5.4';
1691
+ DateTime.version = '1.5.6';
1652
1692
 
1653
1693
  /**
1654
1694
  * CommonJS factory function pass through. Matches DataTables.
@@ -15,113 +15,25 @@
15
15
  "suspend" : "hybrid"
16
16
  },
17
17
  "memory" : {
18
- "minor_gc_time" : "106256",
18
+ "minor_gc_time" : "110412",
19
19
  "major_gc_time" : "0",
20
20
  "minor_gc_count" : "2",
21
21
  "major_gc_count" : "0",
22
22
  "major_gc_time_concurrent" : "0"
23
23
  },
24
24
  "threads" : [
25
- {
26
- "is_managed" : false,
27
- "offset_free_hash" : "0x0",
28
- "offset_rich_hash" : "0x0",
29
- "crashed" : false,
30
- "native_thread_id" : "0x7fd6050006c0",
31
- "thread_info_addr" : "0x7fd5fc000b70",
32
- "thread_name" : "Finalizer",
33
- "ctx" : {
34
- "IP" : "0x7fd6055c2919",
35
- "SP" : "0x7fd604fffcc0",
36
- "BP" : "0x7fd604fffcf0"
37
- },
38
- "unmanaged_frames" : [
39
- {
40
- "is_managed" : "false",
41
- "native_address" : "0x564c2c869572",
42
- "native_offset" : "0x00000"
43
- }
44
- ,
45
- {
46
- "is_managed" : "false",
47
- "native_address" : "0x564c2ca5d999",
48
- "native_offset" : "0x00000"
49
- }
50
- ,
51
- {
52
- "is_managed" : "false",
53
- "native_address" : "0x564c2ca5e995",
54
- "native_offset" : "0x00000"
55
- }
56
- ,
57
- {
58
- "is_managed" : "false",
59
- "native_address" : "0x564c2ca68087",
60
- "native_offset" : "0x00000"
61
- }
62
- ,
63
- {
64
- "is_managed" : "false",
65
- "native_address" : "0x564c2c8bcafd",
66
- "native_offset" : "0x00000"
67
- }
68
- ,
69
- {
70
- "is_managed" : "false",
71
- "native_address" : "0x7fd605570710",
72
- "native_offset" : "0x00000"
73
- }
74
- ,
75
- {
76
- "is_managed" : "false",
77
- "native_address" : "0x7fd6055c2919",
78
- "native_offset" : "0x00000"
79
- }
80
- ,
81
- {
82
- "is_managed" : "false",
83
- "native_address" : "0x7fd6055ce428",
84
- "native_offset" : "0x00000"
85
- }
86
- ,
87
- {
88
- "is_managed" : "false",
89
- "native_address" : "0x564c2caa9ed8",
90
- "native_offset" : "0x00000"
91
- }
92
- ,
93
- {
94
- "is_managed" : "false",
95
- "native_address" : "0x564c2ca6793b",
96
- "native_offset" : "0x00000"
97
- }
98
- ,
99
- {
100
- "is_managed" : "false",
101
- "native_address" : "0x7fd6055c61b7",
102
- "native_offset" : "0x00000"
103
- }
104
- ,
105
- {
106
- "is_managed" : "false",
107
- "native_address" : "0x7fd60564839c",
108
- "native_offset" : "0x00000"
109
- }
110
-
111
- ]
112
- },
113
25
  {
114
26
  "is_managed" : true,
115
27
  "offset_free_hash" : "0x8daede3e0",
116
28
  "offset_rich_hash" : "0x8daededee",
117
29
  "crashed" : true,
118
- "native_thread_id" : "0x7fd605a6a300",
119
- "thread_info_addr" : "0x564c2db0aba0",
30
+ "native_thread_id" : "0x7f4670684300",
31
+ "thread_info_addr" : "0x55e091077bc0",
120
32
  "thread_name" : "mono",
121
33
  "ctx" : {
122
- "IP" : "0x7fd6055d6d75",
123
- "SP" : "0x7ffdd5084230",
124
- "BP" : "0x7ffdd5084260"
34
+ "IP" : "0x7f46701a9d75",
35
+ "SP" : "0x7ffee99ac840",
36
+ "BP" : "0x7ffee99ac870"
125
37
  },
126
38
  "managed_frames" : [
127
39
  {
@@ -430,67 +342,67 @@
430
342
  "unmanaged_frames" : [
431
343
  {
432
344
  "is_managed" : "false",
433
- "native_address" : "0x564c2c869572",
345
+ "native_address" : "0x55e08f469572",
434
346
  "native_offset" : "0x00000"
435
347
  }
436
348
  ,
437
349
  {
438
350
  "is_managed" : "false",
439
- "native_address" : "0x564c2ca5d999",
351
+ "native_address" : "0x55e08f65d999",
440
352
  "native_offset" : "0x00000"
441
353
  }
442
354
  ,
443
355
  {
444
356
  "is_managed" : "false",
445
- "native_address" : "0x564c2ca5e995",
357
+ "native_address" : "0x55e08f65e995",
446
358
  "native_offset" : "0x00000"
447
359
  }
448
360
  ,
449
361
  {
450
362
  "is_managed" : "false",
451
- "native_address" : "0x564c2ca681cc",
363
+ "native_address" : "0x55e08f6681cc",
452
364
  "native_offset" : "0x00000"
453
365
  }
454
366
  ,
455
367
  {
456
368
  "is_managed" : "false",
457
- "native_address" : "0x564c2c8bd7e9",
369
+ "native_address" : "0x55e08f4bd7e9",
458
370
  "native_offset" : "0x00000"
459
371
  }
460
372
  ,
461
373
  {
462
374
  "is_managed" : "false",
463
- "native_address" : "0x564c2c8bda0d",
375
+ "native_address" : "0x55e08f4bda0d",
464
376
  "native_offset" : "0x00000"
465
377
  }
466
378
  ,
467
379
  {
468
380
  "is_managed" : "false",
469
- "native_address" : "0x564c2c86b88f",
381
+ "native_address" : "0x55e08f46b88f",
470
382
  "native_offset" : "0x00000"
471
383
  }
472
384
  ,
473
385
  {
474
386
  "is_managed" : "false",
475
- "native_address" : "0x564c2c8b7115",
387
+ "native_address" : "0x55e08f4b7115",
476
388
  "native_offset" : "0x00000"
477
389
  }
478
390
  ,
479
391
  {
480
392
  "is_managed" : "false",
481
- "native_address" : "0x7fd6055d6d75",
393
+ "native_address" : "0x7f46701a9d75",
482
394
  "native_offset" : "0x00000"
483
395
  }
484
396
  ,
485
397
  {
486
398
  "is_managed" : "false",
487
- "native_address" : "0x7fd605ab3964",
399
+ "native_address" : "0x7f46706a0964",
488
400
  "native_offset" : "0x00000"
489
401
  }
490
402
  ,
491
403
  {
492
404
  "is_managed" : "false",
493
- "native_address" : "0x7fd5fb01fe9d",
405
+ "native_address" : "0x7f4669e1fe9d",
494
406
  "native_offset" : "0x00000"
495
407
  }
496
408
  ,
@@ -505,6 +417,94 @@
505
417
  "il_offset" : "0x00000"
506
418
  }
507
419
 
420
+ ]
421
+ },
422
+ {
423
+ "is_managed" : false,
424
+ "offset_free_hash" : "0x0",
425
+ "offset_rich_hash" : "0x0",
426
+ "crashed" : false,
427
+ "native_thread_id" : "0x7f466fc006c0",
428
+ "thread_info_addr" : "0x7f4664000b70",
429
+ "thread_name" : "Finalizer",
430
+ "ctx" : {
431
+ "IP" : "0x7f4670195919",
432
+ "SP" : "0x7f466fbffcc0",
433
+ "BP" : "0x7f466fbffcf0"
434
+ },
435
+ "unmanaged_frames" : [
436
+ {
437
+ "is_managed" : "false",
438
+ "native_address" : "0x55e08f469572",
439
+ "native_offset" : "0x00000"
440
+ }
441
+ ,
442
+ {
443
+ "is_managed" : "false",
444
+ "native_address" : "0x55e08f65d999",
445
+ "native_offset" : "0x00000"
446
+ }
447
+ ,
448
+ {
449
+ "is_managed" : "false",
450
+ "native_address" : "0x55e08f65e995",
451
+ "native_offset" : "0x00000"
452
+ }
453
+ ,
454
+ {
455
+ "is_managed" : "false",
456
+ "native_address" : "0x55e08f668087",
457
+ "native_offset" : "0x00000"
458
+ }
459
+ ,
460
+ {
461
+ "is_managed" : "false",
462
+ "native_address" : "0x55e08f4bcafd",
463
+ "native_offset" : "0x00000"
464
+ }
465
+ ,
466
+ {
467
+ "is_managed" : "false",
468
+ "native_address" : "0x7f4670143710",
469
+ "native_offset" : "0x00000"
470
+ }
471
+ ,
472
+ {
473
+ "is_managed" : "false",
474
+ "native_address" : "0x7f4670195919",
475
+ "native_offset" : "0x00000"
476
+ }
477
+ ,
478
+ {
479
+ "is_managed" : "false",
480
+ "native_address" : "0x7f46701a1428",
481
+ "native_offset" : "0x00000"
482
+ }
483
+ ,
484
+ {
485
+ "is_managed" : "false",
486
+ "native_address" : "0x55e08f6a9ed8",
487
+ "native_offset" : "0x00000"
488
+ }
489
+ ,
490
+ {
491
+ "is_managed" : "false",
492
+ "native_address" : "0x55e08f66793b",
493
+ "native_offset" : "0x00000"
494
+ }
495
+ ,
496
+ {
497
+ "is_managed" : "false",
498
+ "native_address" : "0x7f46701991b7",
499
+ "native_offset" : "0x00000"
500
+ }
501
+ ,
502
+ {
503
+ "is_managed" : "false",
504
+ "native_address" : "0x7f467021b39c",
505
+ "native_offset" : "0x00000"
506
+ }
507
+
508
508
  ]
509
509
  }
510
510
  ]