datatables.net-datetime 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dataTables.dateTime.js +135 -53
- package/dist/dataTables.dateTime.min.js +2 -2
- package/dist/dataTables.dateTime.min.mjs +2 -2
- package/dist/dataTables.dateTime.mjs +135 -52
- package/docs/api/valFormat().xml +52 -0
- package/examples/initialisation/luxon.xml +1 -1
- package/js/dataTables.dateTime.d.ts +2 -0
- package/js/dataTables.dateTime.js +135 -52
- package/nuget.nuspec +1 -1
- package/package.json +1 -1
- package/test/api/dateTime.val().js +6 -6
- package/test/api/dateTime.valFormat()-luxon.js +83 -0
- package/test/api/dateTime.valFormat().js +83 -0
- package/test/options/dateTime.disableDays.js +1 -1
- package/test/options/dateTime.format.js +5 -9
- package/datatables.net-datetime.1.1.2.nupkg +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.1
|
|
2
2
|
*
|
|
3
3
|
* © SpryMedia Ltd, all rights reserved.
|
|
4
4
|
* License: MIT datatables.net/license/mit
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
require('jquery')( root );
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
return factory( $, root, root.document );
|
|
31
30
|
};
|
|
32
31
|
}
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* @summary DateTime picker for DataTables.net
|
|
44
|
-
* @version 1.
|
|
43
|
+
* @version 1.3.1
|
|
45
44
|
* @file dataTables.dateTime.js
|
|
46
45
|
* @author SpryMedia Ltd
|
|
47
46
|
* @contact www.datatables.net/contact
|
|
@@ -99,25 +98,16 @@ var DateTime = function ( input, opts ) {
|
|
|
99
98
|
this.c.maxDate = new Date(this.c.maxDate);
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
var timeBlock = function ( type ) {
|
|
103
|
-
return '<div class="'+classPrefix+'-timeblock">'+
|
|
104
|
-
'</div>';
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var gap = function () {
|
|
108
|
-
return '<span>:</span>';
|
|
109
|
-
};
|
|
110
|
-
|
|
111
101
|
// DOM structure
|
|
112
102
|
var structure = $(
|
|
113
103
|
'<div class="'+classPrefix+'">'+
|
|
114
104
|
'<div class="'+classPrefix+'-date">'+
|
|
115
105
|
'<div class="'+classPrefix+'-title">'+
|
|
116
106
|
'<div class="'+classPrefix+'-iconLeft">'+
|
|
117
|
-
'<button type="button"
|
|
107
|
+
'<button type="button"></button>'+
|
|
118
108
|
'</div>'+
|
|
119
109
|
'<div class="'+classPrefix+'-iconRight">'+
|
|
120
|
-
'<button type="button"
|
|
110
|
+
'<button type="button"></button>'+
|
|
121
111
|
'</div>'+
|
|
122
112
|
'<div class="'+classPrefix+'-label">'+
|
|
123
113
|
'<span></span>'+
|
|
@@ -129,8 +119,8 @@ var DateTime = function ( input, opts ) {
|
|
|
129
119
|
'</div>'+
|
|
130
120
|
'</div>'+
|
|
131
121
|
'<div class="'+classPrefix+'-buttons">'+
|
|
132
|
-
'<a class="'+classPrefix+'-clear"
|
|
133
|
-
'<a class="'+classPrefix+'-today"
|
|
122
|
+
'<a class="'+classPrefix+'-clear"></a>'+
|
|
123
|
+
'<a class="'+classPrefix+'-today"></a>'+
|
|
134
124
|
'</div>'+
|
|
135
125
|
'<div class="'+classPrefix+'-calendar"></div>'+
|
|
136
126
|
'</div>'+
|
|
@@ -150,9 +140,11 @@ var DateTime = function ( input, opts ) {
|
|
|
150
140
|
calendar: structure.find( '.'+classPrefix+'-calendar' ),
|
|
151
141
|
time: structure.find( '.'+classPrefix+'-time' ),
|
|
152
142
|
error: structure.find( '.'+classPrefix+'-error' ),
|
|
153
|
-
buttons:
|
|
143
|
+
buttons: structure.find( '.'+classPrefix+'-buttons' ),
|
|
154
144
|
clear: structure.find( '.'+classPrefix+'-clear' ),
|
|
155
145
|
today: structure.find( '.'+classPrefix+'-today' ),
|
|
146
|
+
previous: structure.find( '.'+classPrefix+'-iconLeft' ),
|
|
147
|
+
next: structure.find( '.'+classPrefix+'-iconRight' ),
|
|
156
148
|
input: $(input)
|
|
157
149
|
};
|
|
158
150
|
|
|
@@ -283,25 +275,9 @@ $.extend( DateTime.prototype, {
|
|
|
283
275
|
this.s.d = this._dateToUtc(new Date());
|
|
284
276
|
}
|
|
285
277
|
else if ( typeof set === 'string' ) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this.s.d = luxDT.isValid ? luxDT.toJSDate() : null;
|
|
290
|
-
}
|
|
291
|
-
else if ( dateLib ) {
|
|
292
|
-
// Use moment, dayjs or luxon if possible (even for ISO8601 strings, since it
|
|
293
|
-
// will correctly handle 0000-00-00 and the like)
|
|
294
|
-
var m = dateLib.utc( set, this.c.format, this.c.locale, this.c.strict );
|
|
295
|
-
this.s.d = m.isValid() ? m.toDate() : null;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
// Else must be using ISO8601 without a date library (constructor would
|
|
299
|
-
// have thrown an error otherwise)
|
|
300
|
-
var match = set.match(/(\d{4})\-(\d{2})\-(\d{2})/ );
|
|
301
|
-
this.s.d = match ?
|
|
302
|
-
new Date( Date.UTC(match[1], match[2]-1, match[3]) ) :
|
|
303
|
-
null;
|
|
304
|
-
}
|
|
278
|
+
this.s.d = this._dateToUtc(
|
|
279
|
+
this._convert(set, this.c.format, null)
|
|
280
|
+
);
|
|
305
281
|
}
|
|
306
282
|
|
|
307
283
|
if ( write || write === undefined ) {
|
|
@@ -331,6 +307,25 @@ $.extend( DateTime.prototype, {
|
|
|
331
307
|
return this;
|
|
332
308
|
},
|
|
333
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Similar to `val()` but uses a given date / time format
|
|
312
|
+
*
|
|
313
|
+
* @param format Format to get the data as (getter) or that is input (setter)
|
|
314
|
+
* @param val Value to write (if undefined, used as a getter)
|
|
315
|
+
* @returns
|
|
316
|
+
*/
|
|
317
|
+
valFormat: function (format, val) {
|
|
318
|
+
if (! val) {
|
|
319
|
+
return this._convert(this.val(), null, format);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Convert from the format given here to the instance's configured format
|
|
323
|
+
this.val(
|
|
324
|
+
this._convert(val, format, null)
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
return this;
|
|
328
|
+
},
|
|
334
329
|
|
|
335
330
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
336
331
|
* Constructor
|
|
@@ -662,11 +657,75 @@ $.extend( DateTime.prototype, {
|
|
|
662
657
|
_compareDates: function( a, b ) {
|
|
663
658
|
// Can't use toDateString as that converts to local time
|
|
664
659
|
// luxon uses different method names so need to be able to call them
|
|
665
|
-
return
|
|
666
|
-
? dateLib.DateTime.fromJSDate(a).toISODate() === dateLib.DateTime.fromJSDate(b).toISODate()
|
|
660
|
+
return this._isLuxon()
|
|
661
|
+
? dateLib.DateTime.fromJSDate(a).toUTC().toISODate() === dateLib.DateTime.fromJSDate(b).toUTC().toISODate()
|
|
667
662
|
: this._dateToUtcString(a) === this._dateToUtcString(b);
|
|
668
663
|
},
|
|
669
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Convert from one format to another
|
|
667
|
+
*
|
|
668
|
+
* @param {string|Date} val Value
|
|
669
|
+
* @param {string|null} from Format to convert from. If null a `Date` must be given
|
|
670
|
+
* @param {string|null} to Format to convert to. If null a `Date` will be returned
|
|
671
|
+
* @returns {string|Date} Converted value
|
|
672
|
+
*/
|
|
673
|
+
_convert(val, from, to) {
|
|
674
|
+
if (! val) {
|
|
675
|
+
return val;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (! dateLib) {
|
|
679
|
+
// Note that in here from and to can either be null or YYYY-MM-DD
|
|
680
|
+
// They cannot be anything else
|
|
681
|
+
if ((! from && ! to) || (from && to)) {
|
|
682
|
+
// No conversion
|
|
683
|
+
return val;
|
|
684
|
+
}
|
|
685
|
+
else if (! from) {
|
|
686
|
+
// Date in, string back
|
|
687
|
+
return val.getUTCFullYear() +'-'+
|
|
688
|
+
this._pad(val.getUTCMonth() + 1) +'-'+
|
|
689
|
+
this._pad(val.getUTCDate());
|
|
690
|
+
}
|
|
691
|
+
else { // (! to)
|
|
692
|
+
// String in, date back
|
|
693
|
+
var match = val.match(/(\d{4})\-(\d{2})\-(\d{2})/ );
|
|
694
|
+
return match ?
|
|
695
|
+
new Date( match[1], match[2]-1, match[3] ) :
|
|
696
|
+
null;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
else if (this._isLuxon()) {
|
|
700
|
+
// Luxon
|
|
701
|
+
var dtLux = val instanceof Date
|
|
702
|
+
? dateLib.DateTime.fromJSDate(val).toUTC()
|
|
703
|
+
: dateLib.DateTime.fromFormat(val, from);
|
|
704
|
+
|
|
705
|
+
if (! dtLux.isValid) {
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return to
|
|
710
|
+
? dtLux.toFormat(to)
|
|
711
|
+
: dtLux.toJSDate();
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
// Moment / DayJS
|
|
715
|
+
var dtMo = val instanceof Date
|
|
716
|
+
? dateLib.utc( val, undefined, this.c.locale, this.c.strict )
|
|
717
|
+
: dateLib( val, from, this.c.locale, this.c.strict );
|
|
718
|
+
|
|
719
|
+
if (! dtMo.isValid()) {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return to
|
|
724
|
+
? dtMo.format(to)
|
|
725
|
+
: dtMo.toDate();
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
|
|
670
729
|
/**
|
|
671
730
|
* When changing month, take account of the fact that some months don't have
|
|
672
731
|
* the same number of days. For example going from January to February you
|
|
@@ -714,6 +773,10 @@ $.extend( DateTime.prototype, {
|
|
|
714
773
|
* @return {Date} Shifted date
|
|
715
774
|
*/
|
|
716
775
|
_dateToUtc: function ( s ) {
|
|
776
|
+
if (! s) {
|
|
777
|
+
return s;
|
|
778
|
+
}
|
|
779
|
+
|
|
717
780
|
return new Date( Date.UTC(
|
|
718
781
|
s.getFullYear(), s.getMonth(), s.getDate(),
|
|
719
782
|
s.getHours(), s.getMinutes(), s.getSeconds()
|
|
@@ -728,8 +791,8 @@ $.extend( DateTime.prototype, {
|
|
|
728
791
|
*/
|
|
729
792
|
_dateToUtcString: function ( d ) {
|
|
730
793
|
// luxon uses different method names so need to be able to call them
|
|
731
|
-
return
|
|
732
|
-
? dateLib.DateTime.fromJSDate(d).toISODate()
|
|
794
|
+
return this._isLuxon()
|
|
795
|
+
? dateLib.DateTime.fromJSDate(d).toUTC().toISODate()
|
|
733
796
|
: d.getUTCFullYear()+'-'+
|
|
734
797
|
this._pad(d.getUTCMonth()+1)+'-'+
|
|
735
798
|
this._pad(d.getUTCDate());
|
|
@@ -988,6 +1051,17 @@ $.extend( DateTime.prototype, {
|
|
|
988
1051
|
return '<td class="'+this.c.classPrefix+'-week">' + weekNum + '</td>';
|
|
989
1052
|
},
|
|
990
1053
|
|
|
1054
|
+
/**
|
|
1055
|
+
* Determine if Luxon is being used
|
|
1056
|
+
*
|
|
1057
|
+
* @returns Flag for Luxon
|
|
1058
|
+
*/
|
|
1059
|
+
_isLuxon: function () {
|
|
1060
|
+
return dateLib && dateLib.DateTime && dateLib.Duration && dateLib.Settings
|
|
1061
|
+
? true
|
|
1062
|
+
: false;
|
|
1063
|
+
},
|
|
1064
|
+
|
|
991
1065
|
/**
|
|
992
1066
|
* Check if the instance has a date object value - it might be null.
|
|
993
1067
|
* If is doesn't set one to now.
|
|
@@ -1206,6 +1280,18 @@ $.extend( DateTime.prototype, {
|
|
|
1206
1280
|
|
|
1207
1281
|
this._options( 'month', this._range( 0, 11 ), i18n.months );
|
|
1208
1282
|
this._options( 'year', this._range( i, j ) );
|
|
1283
|
+
|
|
1284
|
+
// Set the language strings in case any have changed
|
|
1285
|
+
this.dom.today.text(i18n.today).text(i18n.today);
|
|
1286
|
+
this.dom.clear.text(i18n.clear).text(i18n.clear);
|
|
1287
|
+
this.dom.previous
|
|
1288
|
+
.attr('title', i18n.previous)
|
|
1289
|
+
.children('button')
|
|
1290
|
+
.text(i18n.previous);
|
|
1291
|
+
this.dom.next
|
|
1292
|
+
.attr('title', i18n.next)
|
|
1293
|
+
.children('button')
|
|
1294
|
+
.text(i18n.next);
|
|
1209
1295
|
},
|
|
1210
1296
|
|
|
1211
1297
|
/**
|
|
@@ -1342,8 +1428,8 @@ $.extend( DateTime.prototype, {
|
|
|
1342
1428
|
|
|
1343
1429
|
// luxon uses different method names so need to be able to call them. This happens a few time later in this method too
|
|
1344
1430
|
var luxDT = null
|
|
1345
|
-
if (
|
|
1346
|
-
luxDT = dateLib.DateTime.fromJSDate(d);
|
|
1431
|
+
if (this._isLuxon()) {
|
|
1432
|
+
luxDT = dateLib.DateTime.fromJSDate(d).toUTC();
|
|
1347
1433
|
}
|
|
1348
1434
|
|
|
1349
1435
|
var hours = luxDT != null
|
|
@@ -1452,17 +1538,8 @@ $.extend( DateTime.prototype, {
|
|
|
1452
1538
|
var date = this.s.d;
|
|
1453
1539
|
var out = '';
|
|
1454
1540
|
|
|
1455
|
-
// Use moment, dayjs or luxon if possible - otherwise it must be ISO8601 (or the
|
|
1456
|
-
// constructor would have thrown an error)
|
|
1457
|
-
// luxon uses different method names so need to be able to call them.
|
|
1458
1541
|
if (date) {
|
|
1459
|
-
out =
|
|
1460
|
-
? dateLib.DateTime.fromJSDate(this.s.d).toFormat(this.c.format)
|
|
1461
|
-
: dateLib ?
|
|
1462
|
-
dateLib.utc( date, undefined, this.c.locale, this.c.strict ).format( this.c.format ) :
|
|
1463
|
-
date.getUTCFullYear() +'-'+
|
|
1464
|
-
this._pad(date.getUTCMonth() + 1) +'-'+
|
|
1465
|
-
this._pad(date.getUTCDate());
|
|
1542
|
+
out = this._convert(date, null, this.c.format);
|
|
1466
1543
|
}
|
|
1467
1544
|
|
|
1468
1545
|
this.dom.input
|
|
@@ -1559,13 +1636,18 @@ DateTime.defaults = {
|
|
|
1559
1636
|
yearRange: 25
|
|
1560
1637
|
};
|
|
1561
1638
|
|
|
1562
|
-
DateTime.version = '1.
|
|
1639
|
+
DateTime.version = '1.3.1';
|
|
1563
1640
|
|
|
1564
1641
|
// Global export - if no conflicts
|
|
1565
1642
|
if (! window.DateTime) {
|
|
1566
1643
|
window.DateTime = DateTime;
|
|
1567
1644
|
}
|
|
1568
1645
|
|
|
1646
|
+
// Global DataTable
|
|
1647
|
+
if (window.DataTable) {
|
|
1648
|
+
window.DataTable.DateTime = DateTime;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1569
1651
|
// Make available via jQuery
|
|
1570
1652
|
$.fn.dtDateTime = function (options) {
|
|
1571
1653
|
return this.each(function() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.1
|
|
2
2
|
*
|
|
3
3
|
* © SpryMedia Ltd, all rights reserved.
|
|
4
4
|
* License: MIT datatables.net/license/mit
|
|
5
5
|
*/
|
|
6
|
-
!function(s){"function"==typeof define&&define.amd?define(["jquery"],function(t){return s(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t=t||window,e=e||("undefined"!=typeof window?require("jquery"):require("jquery")(t)),s(e,t,t.document)}:s(jQuery,window,document)}(function(C,o,i,n){"use strict";function a(t,e){void 0===r&&(r=o.moment||o.dayjs||o.luxon||null),this.c=C.extend(!0,{},a.defaults,e);var e=this.c.classPrefix,s=this.c.i18n;if(!r&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate)),s=C('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button" title="'+s.previous+'">'+s.previous+'</button></div><div class="'+e+'-iconRight"><button type="button" title="'+s.next+'">'+s.next+'</button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear">'+s.clear+'</a><a class="'+e+'-today">'+s.today+'</a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>'),this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),input:C(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+a._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()}var r;return C.extend(a.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<C(t).parents().filter(this.dom.container).length},val:function(t,e){var s;return t===n?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(r&&r==o.luxon?(s=r.DateTime.fromFormat(t,this.c.format),this.s.d=s.isValid?s.toJSDate():null):r?(s=r.utc(t,this.c.format,this.c.locale,this.c.strict),this.s.d=s.isValid()?s.toDate():null):(s=t.match(/(\d{4})\-(\d{2})\-(\d{2})/),this.s.d=s?new Date(Date.UTC(s[1],s[2]-1,s[3])):null)),!e&&e!==n||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},_constructor:function(){function a(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,r=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+r+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),C(i).on("i18n.dt",function(t,e){e.oLanguage.datetime&&(C.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=C(this),i=s.val();s.hasClass(r+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(r+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(r+"-hours")||s.hasClass(r+"-ampm")?(o.s.parts.hours12?(t=+C(o.dom.container).find("."+r+"-hours").val(),e="pm"===C(o.dom.container).find("."+r+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),a()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),C(s).hasClass(r+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),a()):C(s).hasClass(r+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=C(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(r+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(r+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+r+"-time").length){var s=t.data("value"),n=t.data("unit"),e=o._needValue();if("minutes"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===n?"setUTCHours":"minutes"===n?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);a()}}else o.dom.input.focus()})},_compareDates:function(t,e){return r&&r==o.luxon?r.DateTime.fromJSDate(t).toISODate()===r.DateTime.fromJSDate(e).toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return r&&r==o.luxon?r.DateTime.fromJSDate(t).toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),C(o).off("."+t),C(i).off("keydown."+t),C("div.dataTables_scrollBody").off("scroll."+t),C("div.DTE_Body_Content").off("scroll."+t),C("body").off("click."+t),C(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),n=new Date(Date.UTC(t,e,1)).getUTCDay(),a=[],o=[],r=(0<this.c.firstDay&&(n-=this.c.firstDay)<0&&(n+=7),i+n),d=r;7<d;)d-=7;r+=7-d;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<r;c++){var m=new Date(Date.UTC(t,e,c-n+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),y=c<n||i+n<=c,T=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-n+1,month:e,year:t,selected:f,today:p,disabled:T=Array.isArray(_)&&-1!==C.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:T,empty:y};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-n,e,t)),a.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,g=D+"-table";return this.c.showWeekNumber&&(g+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+g+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+a.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var n=0,a=e.length;n<a;n++)i.append('<option value="'+e[n]+'">'+s[n]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(n,a,o,r,t){var e,d=this.c.classPrefix,s=this.dom.container.find("div."+d+"-"+n),i=12===a?function(t){return t}:this._pad,l=(d=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){var c="",u=10,m=function(t,e,s){12===a&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&r&&-1===C.inArray(t,r)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+d+"-button "+d+'-day" type="button" data-unit="'+n+'" data-value="'+t+'"><span>'+e+"</span></button></td>"};if(12===a){for(c+="<tr>",e=1;e<=6;e++)c+=m(e,i(e));for(c=(c+=m("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)c+=m(e,i(e));c=c+m("pm",h.amPm[1])+"</tr>",u=7}else{if(24===a)for(var f=0,p=0;p<4;p++){for(c+="<tr>",e=0;e<6;e++)c+=m(f,i(f)),f++;c+="</tr>"}else{for(c+="<tr>",p=0;p<60;p+=10)c+=m(p,i(p),"range");var c=c+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),y=null!==t?t:-1===o?0:10*Math.floor(o/10);for(c+="<tr>",p=y+1;p<y+10;p++)c+=m(p,i(p));c+="</tr>"}u=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+u+'">'+h[n]+"</th></tr></thead><tbody>"+c+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s))},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),n=this.dom.container,a=this.dom.input.outerHeight();n.hasClass("inline")?n.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<C(o).width()?n.addClass("horizontal"):n.removeClass("horizontal"),"input"===this.c.attachTo?n.css({top:i.top+a,left:i.left}).insertAfter(this.dom.input):n.css({top:i.top+a,left:i.left}).appendTo("body"),t=n.outerHeight(),e=n.outerWidth(),s=C(o).scrollTop(),i.top+a+t-s>C(o).height()&&(a=i.top-t,n.css("top",a<0?0:a)),e+i.left>C(o).width()&&(s=C(o).width()-e,"input"===this.c.attachTo&&(s-=C(n).offsetParent().offset().left),n.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var n=t;n<=e;n+=s)i.push(n);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,n=null!=(i=r&&r==o.luxon?r.DateTime.fromJSDate(s):i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,n,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),C(o).on("scroll."+t+" resize."+t,function(){e._position()}),C("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),C("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==i.body&&C(s).on("scroll."+t,function(){e._position()}),C(i).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){C("body").on("click."+t,function(t){C(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=r&&r==o.luxon?r.DateTime.fromJSDate(this.s.d).toFormat(this.c.format):r?r.utc(e,n,this.c.locale,this.c.strict).format(this.c.format):e.getUTCFullYear()+"-"+this._pad(e.getUTCMonth()+1)+"-"+this._pad(e.getUTCDate())),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),a.use=function(t){r=t},a._instance=0,a.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},a.version="1.2.0",o.DateTime||(o.DateTime=a),C.fn.dtDateTime=function(t){return this.each(function(){new a(this,t)})},C.fn.dataTable&&(C.fn.dataTable.DateTime=a,C.fn.DataTable.DateTime=a,C.fn.dataTable.Editor)&&(C.fn.dataTable.Editor.DateTime=a),a});
|
|
6
|
+
!function(s){"function"==typeof define&&define.amd?define(["jquery"],function(t){return s(t,window,document)}):"object"==typeof exports?module.exports=function(t,e){return t=t||window,e=e||("undefined"!=typeof window?require("jquery"):require("jquery")(t)),s(e,t,t.document)}:s(jQuery,window,document)}(function(C,o,i,n){"use strict";function a(t,e){if(void 0===r&&(r=o.moment||o.dayjs||o.luxon||null),this.c=C.extend(!0,{},a.defaults,e),e=this.c.classPrefix,this.c.i18n,!r&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));var s=C('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:C(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+a._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()}var r;return C.extend(a.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<C(t).parents().filter(this.dom.container).length},val:function(t,e){return t===n?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._dateToUtc(this._convert(t,this.c.format,null))),!e&&e!==n||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function a(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,r=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+r+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),C(i).on("i18n.dt",function(t,e){e.oLanguage.datetime&&(C.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=C(this),i=s.val();s.hasClass(r+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(r+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(r+"-hours")||s.hasClass(r+"-ampm")?(o.s.parts.hours12?(t=+C(o.dom.container).find("."+r+"-hours").val(),e="pm"===C(o.dom.container).find("."+r+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),a()):s.hasClass(r+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),a()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),C(s).hasClass(r+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),a()):C(s).hasClass(r+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=C(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(r+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(r+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+r+"-time").length){var s=t.data("value"),n=t.data("unit"),e=o._needValue();if("minutes"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===n){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===n?"setUTCHours":"minutes"===n?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);a()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?r.DateTime.fromJSDate(t).toUTC().toISODate()===r.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert(t,e,s){var i;return t&&(r?this._isLuxon()?(i=t instanceof Date?r.DateTime.fromJSDate(t).toUTC():r.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):i.toJSDate():null:(i=t instanceof Date?r.utc(t,n,this.c.locale,this.c.strict):r(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(i[1],i[2]-1,i[3]):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return t&&new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?r.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),C(o).off("."+t),C(i).off("keydown."+t),C("div.dataTables_scrollBody").off("scroll."+t),C("div.DTE_Body_Content").off("scroll."+t),C("body").off("click."+t),C(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),n=new Date(Date.UTC(t,e,1)).getUTCDay(),a=[],o=[],r=(0<this.c.firstDay&&(n-=this.c.firstDay)<0&&(n+=7),i+n),d=r;7<d;)d-=7;r+=7-d;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<r;c++){var m=new Date(Date.UTC(t,e,c-n+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),y=c<n||i+n<=c,T=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-n+1,month:e,year:t,selected:f,today:p,disabled:T=Array.isArray(_)&&-1!==C.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:T,empty:y};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-n,e,t)),a.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,g=D+"-table";return this.c.showWeekNumber&&(g+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+g+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+a.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(r&&r.DateTime&&r.Duration&&r.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var n=0,a=e.length;n<a;n++)i.append('<option value="'+e[n]+'">'+s[n]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(n,a,o,r,t){var e,d=this.c.classPrefix,s=this.dom.container.find("div."+d+"-"+n),i=12===a?function(t){return t}:this._pad,l=(d=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){var c="",u=10,m=function(t,e,s){12===a&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&r&&-1===C.inArray(t,r)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+d+"-button "+d+'-day" type="button" data-unit="'+n+'" data-value="'+t+'"><span>'+e+"</span></button></td>"};if(12===a){for(c+="<tr>",e=1;e<=6;e++)c+=m(e,i(e));for(c=(c+=m("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)c+=m(e,i(e));c=c+m("pm",h.amPm[1])+"</tr>",u=7}else{if(24===a)for(var f=0,p=0;p<4;p++){for(c+="<tr>",e=0;e<6;e++)c+=m(f,i(f)),f++;c+="</tr>"}else{for(c+="<tr>",p=0;p<60;p+=10)c+=m(p,i(p),"range");var c=c+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),y=null!==t?t:-1===o?0:10*Math.floor(o/10);for(c+="<tr>",p=y+1;p<y+10;p++)c+=m(p,i(p));c+="</tr>"}u=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+u+'">'+h[n]+"</th></tr></thead><tbody>"+c+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),n=this.dom.container,a=this.dom.input.outerHeight();n.hasClass("inline")?n.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<C(o).width()?n.addClass("horizontal"):n.removeClass("horizontal"),"input"===this.c.attachTo?n.css({top:i.top+a,left:i.left}).insertAfter(this.dom.input):n.css({top:i.top+a,left:i.left}).appendTo("body"),t=n.outerHeight(),e=n.outerWidth(),s=C(o).scrollTop(),i.top+a+t-s>C(o).height()&&(a=i.top-t,n.css("top",a<0?0:a)),e+i.left>C(o).width()&&(s=C(o).width()-e,"input"===this.c.attachTo&&(s-=C(n).offsetParent().offset().left),n.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var n=t;n<=e;n+=s)i.push(n);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,n=null!=(i=this._isLuxon()?r.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,n,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),C(o).on("scroll."+t+" resize."+t,function(){e._position()}),C("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),C("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==i.body&&C(s).on("scroll."+t,function(){e._position()}),C(i).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){C("body").on("click."+t,function(t){C(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=this._convert(e,null,this.c.format)),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),a.use=function(t){r=t},a._instance=0,a.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},a.version="1.3.1",o.DateTime||(o.DateTime=a),o.DataTable&&(o.DataTable.DateTime=a),C.fn.dtDateTime=function(t){return this.each(function(){new a(this,t)})},C.fn.dataTable&&(C.fn.dataTable.DateTime=a,C.fn.DataTable.DateTime=a,C.fn.dataTable.Editor)&&(C.fn.dataTable.Editor.DateTime=a),a});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! DateTime picker for DataTables.net v1.
|
|
1
|
+
/*! DateTime picker for DataTables.net v1.3.1
|
|
2
2
|
*
|
|
3
3
|
* © SpryMedia Ltd, all rights reserved.
|
|
4
4
|
* License: MIT datatables.net/license/mit
|
|
5
5
|
*/
|
|
6
|
-
import $ from"jquery";var dateLib,DateTime=function(t,e){void 0===dateLib&&(dateLib=window.moment||window.dayjs||window.luxon||null),this.c=$.extend(!0,{},DateTime.defaults,e);var e=this.c.classPrefix,s=this.c.i18n;if(!dateLib&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));s=$('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button" title="'+s.previous+'">'+s.previous+'</button></div><div class="'+e+'-iconRight"><button type="button" title="'+s.next+'">'+s.next+'</button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear">'+s.clear+'</a><a class="'+e+'-today">'+s.today+'</a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),input:$(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+DateTime._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()};$.extend(DateTime.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<$(t).parents().filter(this.dom.container).length},val:function(t,e){var s;return void 0===t?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(dateLib&&dateLib==window.luxon?(s=dateLib.DateTime.fromFormat(t,this.c.format),this.s.d=s.isValid?s.toJSDate():null):dateLib?(s=dateLib.utc(t,this.c.format,this.c.locale,this.c.strict),this.s.d=s.isValid()?s.toDate():null):(s=t.match(/(\d{4})\-(\d{2})\-(\d{2})/),this.s.d=s?new Date(Date.UTC(s[1],s[2]-1,s[3])):null)),!e&&void 0!==e||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},_constructor:function(){function n(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,d=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+d+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),$(document).on("i18n.dt",function(t,e){e.oLanguage.datetime&&($.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=$(this),i=s.val();s.hasClass(d+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(d+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(d+"-hours")||s.hasClass(d+"-ampm")?(o.s.parts.hours12?(t=+$(o.dom.container).find("."+d+"-hours").val(),e="pm"===$(o.dom.container).find("."+d+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),n()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),$(s).hasClass(d+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),n()):$(s).hasClass(d+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=$(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(d+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(d+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+d+"-time").length){var s=t.data("value"),a=t.data("unit"),e=o._needValue();if("minutes"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===a?"setUTCHours":"minutes"===a?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);n()}}else o.dom.input.focus()})},_compareDates:function(t,e){return dateLib&&dateLib==window.luxon?dateLib.DateTime.fromJSDate(t).toISODate()===dateLib.DateTime.fromJSDate(e).toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return dateLib&&dateLib==window.luxon?dateLib.DateTime.fromJSDate(t).toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),$(window).off("."+t),$(document).off("keydown."+t),$("div.dataTables_scrollBody").off("scroll."+t),$("div.DTE_Body_Content").off("scroll."+t),$("body").off("click."+t),$(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),a=new Date(Date.UTC(t,e,1)).getUTCDay(),n=[],o=[],d=(0<this.c.firstDay&&(a-=this.c.firstDay)<0&&(a+=7),i+a),r=d;7<r;)r-=7;d+=7-r;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<d;c++){var m=new Date(Date.UTC(t,e,c-a+1)),p=!!this.s.d&&this._compareDates(m,this.s.d),f=this._compareDates(m,s),T=c<a||i+a<=c,y=l&&m<l||h&&h<m,_=this.c.disableDays,p={day:c-a+1,month:e,year:t,selected:p,today:f,disabled:y=Array.isArray(_)&&-1!==$.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:y,empty:T};o.push(this._htmlDay(p)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-a,e,t)),n.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,b=D+"-table";return this.c.showWeekNumber&&(b+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+b+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+n.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var a=0,n=e.length;a<n;a++)i.append('<option value="'+e[a]+'">'+s[a]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(a,n,o,d,t){var e,r=this.c.classPrefix,s=this.dom.container.find("div."+r+"-"+a),i=12===n?function(t){return t}:this._pad,l=(r=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){function c(t,e,s){12===n&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&d&&-1===$.inArray(t,d)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+r+"-button "+r+'-day" type="button" data-unit="'+a+'" data-value="'+t+'"><span>'+e+"</span></button></td>"}var u="",m=10;if(12===n){for(u+="<tr>",e=1;e<=6;e++)u+=c(e,i(e));for(u=(u+=c("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)u+=c(e,i(e));u=u+c("pm",h.amPm[1])+"</tr>",m=7}else{if(24===n)for(var p=0,f=0;f<4;f++){for(u+="<tr>",e=0;e<6;e++)u+=c(p,i(p)),p++;u+="</tr>"}else{for(u+="<tr>",f=0;f<60;f+=10)u+=c(f,i(f),"range");var u=u+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),T=null!==t?t:-1===o?0:10*Math.floor(o/10);for(u+="<tr>",f=T+1;f<T+10;f++)u+=c(f,i(f));u+="</tr>"}m=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+m+'">'+h[a]+"</th></tr></thead><tbody>"+u+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s))},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),a=this.dom.container,n=this.dom.input.outerHeight();a.hasClass("inline")?a.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<$(window).width()?a.addClass("horizontal"):a.removeClass("horizontal"),"input"===this.c.attachTo?a.css({top:i.top+n,left:i.left}).insertAfter(this.dom.input):a.css({top:i.top+n,left:i.left}).appendTo("body"),t=a.outerHeight(),e=a.outerWidth(),s=$(window).scrollTop(),i.top+n+t-s>$(window).height()&&(n=i.top-t,a.css("top",n<0?0:n)),e+i.left>$(window).width()&&(s=$(window).width()-e,"input"===this.c.attachTo&&(s-=$(a).offsetParent().offset().left),a.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var a=t;a<=e;a+=s)i.push(a);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,a=null!=(i=dateLib&&dateLib==window.luxon?dateLib.DateTime.fromJSDate(s):i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,a,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),$(window).on("scroll."+t+" resize."+t,function(){e._position()}),$("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),$("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==document.body&&$(s).on("scroll."+t,function(){e._position()}),$(document).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){$("body").on("click."+t,function(t){$(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=dateLib&&dateLib==window.luxon?dateLib.DateTime.fromJSDate(this.s.d).toFormat(this.c.format):dateLib?dateLib.utc(e,void 0,this.c.locale,this.c.strict).format(this.c.format):e.getUTCFullYear()+"-"+this._pad(e.getUTCMonth()+1)+"-"+this._pad(e.getUTCDate())),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),DateTime.use=function(t){dateLib=t},DateTime._instance=0,DateTime.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},DateTime.version="1.2.0",window.DateTime||(window.DateTime=DateTime),$.fn.dtDateTime=function(t){return this.each(function(){new DateTime(this,t)})},$.fn.dataTable&&($.fn.dataTable.DateTime=DateTime,$.fn.DataTable.DateTime=DateTime,$.fn.dataTable.Editor)&&($.fn.dataTable.Editor.DateTime=DateTime);export default DateTime;
|
|
6
|
+
import $ from"jquery";var dateLib,DateTime=function(t,e){void 0===dateLib&&(dateLib=window.moment||window.dayjs||window.luxon||null),this.c=$.extend(!0,{},DateTime.defaults,e);e=this.c.classPrefix;this.c.i18n;if(!dateLib&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"string"==typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate)),"string"==typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));var s=$('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:$(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+DateTime._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}},this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()};$.extend(DateTime.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<$(t).parents().filter(this.dom.container).length},val:function(t,e){return void 0===t?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._dateToUtc(this._convert(t,this.c.format,null))),!e&&void 0!==e||(this.s.d?this._writeOutput():this.dom.input.val(t)),this.s.display=this.s.d?new Date(this.s.d.toString()):new Date,this.s.display.setUTCDate(1),this._setTitle(),this._setCalander(),this._setTime(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function n(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,d=this.c.classPrefix,e=this.dom.input.val();this.s.parts.date||this.dom.date.css("display","none"),this.s.parts.time||this.dom.time.css("display","none"),this.s.parts.seconds||(this.dom.time.children("div."+d+"-seconds").remove(),this.dom.time.children("span").eq(1).remove()),this.c.buttons.clear||this.dom.clear.css("display","none"),this.c.buttons.today||this.dom.today.css("display","none"),this._optionsTitle(),$(document).on("i18n.dt",function(t,e){e.oLanguage.datetime&&($.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=$(this),i=s.val();s.hasClass(d+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(d+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(d+"-hours")||s.hasClass(d+"-ampm")?(o.s.parts.hours12?(t=+$(o.dom.container).find("."+d+"-hours").val(),e="pm"===$(o.dom.container).find("."+d+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),n()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),$(s).hasClass(d+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),n()):$(s).hasClass(d+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=$(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(d+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(d+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+d+"-time").length){var s=t.data("value"),a=t.data("unit"),e=o._needValue();if("minutes"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===a?"setUTCHours":"minutes"===a?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);n()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate()===dateLib.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert(t,e,s){var i;return t&&(dateLib?this._isLuxon()?(i=t instanceof Date?dateLib.DateTime.fromJSDate(t).toUTC():dateLib.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):i.toJSDate():null:(i=t instanceof Date?dateLib.utc(t,void 0,this.c.locale,this.c.strict):dateLib(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(i[1],i[2]-1,i[3]):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return t&&new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),$(window).off("."+t),$(document).off("keydown."+t),$("div.dataTables_scrollBody").off("scroll."+t),$("div.DTE_Body_Content").off("scroll."+t),$("body").off("click."+t),$(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),a=new Date(Date.UTC(t,e,1)).getUTCDay(),n=[],o=[],d=(0<this.c.firstDay&&(a-=this.c.firstDay)<0&&(a+=7),i+a),r=d;7<r;)r-=7;d+=7-r;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<d;c++){var m=new Date(Date.UTC(t,e,c-a+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),T=c<a||i+a<=c,y=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-a+1,month:e,year:t,selected:f,today:p,disabled:y=Array.isArray(_)&&-1!==$.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:y,empty:T};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-a,e,t)),n.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,b=D+"-table";return this.c.showWeekNumber&&(b+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+b+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+n.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(dateLib&&dateLib.DateTime&&dateLib.Duration&&dateLib.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var a=0,n=e.length;a<n;a++)i.append('<option value="'+e[a]+'">'+s[a]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(a,n,o,d,t){var e,r=this.c.classPrefix,s=this.dom.container.find("div."+r+"-"+a),i=12===n?function(t){return t}:this._pad,l=(r=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){function c(t,e,s){12===n&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&d&&-1===$.inArray(t,d)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+r+"-button "+r+'-day" type="button" data-unit="'+a+'" data-value="'+t+'"><span>'+e+"</span></button></td>"}var u="",m=10;if(12===n){for(u+="<tr>",e=1;e<=6;e++)u+=c(e,i(e));for(u=(u+=c("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)u+=c(e,i(e));u=u+c("pm",h.amPm[1])+"</tr>",m=7}else{if(24===n)for(var f=0,p=0;p<4;p++){for(u+="<tr>",e=0;e<6;e++)u+=c(f,i(f)),f++;u+="</tr>"}else{for(u+="<tr>",p=0;p<60;p+=10)u+=c(p,i(p),"range");var u=u+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),T=null!==t?t:-1===o?0:10*Math.floor(o/10);for(u+="<tr>",p=T+1;p<T+10;p++)u+=c(p,i(p));u+="</tr>"}m=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+m+'">'+h[a]+"</th></tr></thead><tbody>"+u+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),a=this.dom.container,n=this.dom.input.outerHeight();a.hasClass("inline")?a.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<$(window).width()?a.addClass("horizontal"):a.removeClass("horizontal"),"input"===this.c.attachTo?a.css({top:i.top+n,left:i.left}).insertAfter(this.dom.input):a.css({top:i.top+n,left:i.left}).appendTo("body"),t=a.outerHeight(),e=a.outerWidth(),s=$(window).scrollTop(),i.top+n+t-s>$(window).height()&&(n=i.top-t,a.css("top",n<0?0:n)),e+i.left>$(window).width()&&(s=$(window).width()-e,"input"===this.c.attachTo&&(s-=$(a).offsetParent().offset().left),a.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var a=t;a<=e;a+=s)i.push(a);return i},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth()),this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,a=null!=(i=this._isLuxon()?dateLib.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,a,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),$(window).on("scroll."+t+" resize."+t,function(){e._position()}),$("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),$("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==document.body&&$(s).on("scroll."+t,function(){e._position()}),$(document).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){$("body").on("click."+t,function(t){$(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=this._convert(e,null,this.c.format)),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),DateTime.use=function(t){dateLib=t},DateTime._instance=0,DateTime.defaults={attachTo:"body",buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},DateTime.version="1.3.1",window.DateTime||(window.DateTime=DateTime),window.DataTable&&(window.DataTable.DateTime=DateTime),$.fn.dtDateTime=function(t){return this.each(function(){new DateTime(this,t)})},$.fn.dataTable&&($.fn.dataTable.DateTime=DateTime,$.fn.DataTable.DateTime=DateTime,$.fn.dataTable.Editor)&&($.fn.dataTable.Editor.DateTime=DateTime);export default DateTime;
|