datatables.net 1.11.4 → 1.12.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/js/jquery.dataTables.js +318 -83
- package/js/jquery.dataTables.min.js +178 -173
- package/package.json +2 -2
- package/types/types.d.ts +11 -0
package/js/jquery.dataTables.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
/*! DataTables 1.
|
|
2
|
-
* ©2008-
|
|
1
|
+
/*! DataTables 1.12.1
|
|
2
|
+
* ©2008-2022 SpryMedia Ltd - datatables.net/license
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @summary DataTables
|
|
7
7
|
* @description Paginate, search and order HTML tables
|
|
8
|
-
* @version 1.
|
|
9
|
-
* @file jquery.dataTables.js
|
|
8
|
+
* @version 1.12.1
|
|
10
9
|
* @author SpryMedia Ltd
|
|
11
10
|
* @contact www.datatables.net
|
|
12
|
-
* @copyright
|
|
11
|
+
* @copyright SpryMedia Ltd.
|
|
13
12
|
*
|
|
14
13
|
* This source file is free software, available under the following license:
|
|
15
14
|
* MIT license - http://datatables.net/license
|
|
@@ -59,38 +58,7 @@
|
|
|
59
58
|
(function( $, window, document, undefined ) {
|
|
60
59
|
"use strict";
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
* DataTables is a plug-in for the jQuery Javascript library. It is a highly
|
|
64
|
-
* flexible tool, based upon the foundations of progressive enhancement,
|
|
65
|
-
* which will add advanced interaction controls to any HTML table. For a
|
|
66
|
-
* full list of features please refer to
|
|
67
|
-
* [DataTables.net](href="http://datatables.net).
|
|
68
|
-
*
|
|
69
|
-
* Note that the `DataTable` object is not a global variable but is aliased
|
|
70
|
-
* to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
|
|
71
|
-
* be accessed.
|
|
72
|
-
*
|
|
73
|
-
* @class
|
|
74
|
-
* @param {object} [init={}] Configuration object for DataTables. Options
|
|
75
|
-
* are defined by {@link DataTable.defaults}
|
|
76
|
-
* @requires jQuery 1.7+
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* // Basic initialisation
|
|
80
|
-
* $(document).ready( function {
|
|
81
|
-
* $('#example').dataTable();
|
|
82
|
-
* } );
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* // Initialisation with configuration options - in this case, disable
|
|
86
|
-
* // pagination and sorting.
|
|
87
|
-
* $(document).ready( function {
|
|
88
|
-
* $('#example').dataTable( {
|
|
89
|
-
* "paginate": false,
|
|
90
|
-
* "sort": false
|
|
91
|
-
* } );
|
|
92
|
-
* } );
|
|
93
|
-
*/
|
|
61
|
+
|
|
94
62
|
var DataTable = function ( selector, options )
|
|
95
63
|
{
|
|
96
64
|
// When creating with `new`, create a new DataTable, returning the API instance
|
|
@@ -101,7 +69,7 @@
|
|
|
101
69
|
// Argument switching
|
|
102
70
|
options = selector;
|
|
103
71
|
}
|
|
104
|
-
|
|
72
|
+
|
|
105
73
|
/**
|
|
106
74
|
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
|
|
107
75
|
* return the resulting jQuery object.
|
|
@@ -857,24 +825,24 @@
|
|
|
857
825
|
*/
|
|
858
826
|
this.fnVersionCheck = _ext.fnVersionCheck;
|
|
859
827
|
|
|
860
|
-
|
|
828
|
+
|
|
861
829
|
var _that = this;
|
|
862
830
|
var emptyInit = options === undefined;
|
|
863
831
|
var len = this.length;
|
|
864
|
-
|
|
832
|
+
|
|
865
833
|
if ( emptyInit ) {
|
|
866
834
|
options = {};
|
|
867
835
|
}
|
|
868
|
-
|
|
836
|
+
|
|
869
837
|
this.oApi = this.internal = _ext.internal;
|
|
870
|
-
|
|
838
|
+
|
|
871
839
|
// Extend with old style plug-in API methods
|
|
872
840
|
for ( var fn in DataTable.ext.internal ) {
|
|
873
841
|
if ( fn ) {
|
|
874
842
|
this[fn] = _fnExternApiFunc(fn);
|
|
875
843
|
}
|
|
876
844
|
}
|
|
877
|
-
|
|
845
|
+
|
|
878
846
|
this.each(function() {
|
|
879
847
|
// For each initialisation we want to give it a clean initialisation
|
|
880
848
|
// object that can be bashed around
|
|
@@ -882,7 +850,7 @@
|
|
|
882
850
|
var oInit = len > 1 ? // optimisation for single table case
|
|
883
851
|
_fnExtend( o, options, true ) :
|
|
884
852
|
options;
|
|
885
|
-
|
|
853
|
+
|
|
886
854
|
/*global oInit,_that,emptyInit*/
|
|
887
855
|
var i=0, iLen, j, jLen, k, kLen;
|
|
888
856
|
var sId = this.getAttribute( 'id' );
|
|
@@ -1096,7 +1064,7 @@
|
|
|
1096
1064
|
success: function ( json ) {
|
|
1097
1065
|
_fnCamelToHungarian( defaults.oLanguage, json );
|
|
1098
1066
|
_fnLanguageCompat( json );
|
|
1099
|
-
$.extend( true, oLanguage, json );
|
|
1067
|
+
$.extend( true, oLanguage, json, oSettings.oInit.oLanguage );
|
|
1100
1068
|
|
|
1101
1069
|
_fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
|
|
1102
1070
|
_fnInitialise( oSettings );
|
|
@@ -1325,7 +1293,7 @@
|
|
|
1325
1293
|
_that = null;
|
|
1326
1294
|
return this;
|
|
1327
1295
|
};
|
|
1328
|
-
|
|
1296
|
+
|
|
1329
1297
|
|
|
1330
1298
|
/*
|
|
1331
1299
|
* It is useful to have variables which are scoped locally so only the
|
|
@@ -2329,9 +2297,17 @@
|
|
|
2329
2297
|
th.addClass( oOptions.sClass );
|
|
2330
2298
|
}
|
|
2331
2299
|
|
|
2300
|
+
var origClass = oCol.sClass;
|
|
2301
|
+
|
|
2332
2302
|
$.extend( oCol, oOptions );
|
|
2333
2303
|
_fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
|
|
2334
2304
|
|
|
2305
|
+
// Merge class from previously defined classes with this one, rather than just
|
|
2306
|
+
// overwriting it in the extend above
|
|
2307
|
+
if (origClass !== oCol.sClass) {
|
|
2308
|
+
oCol.sClass = origClass + ' ' + oCol.sClass;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2335
2311
|
/* iDataSort to be applied (backwards compatibility), but aDataSort will take
|
|
2336
2312
|
* priority if defined
|
|
2337
2313
|
*/
|
|
@@ -2604,9 +2580,11 @@
|
|
|
2604
2580
|
def = aoColDefs[i];
|
|
2605
2581
|
|
|
2606
2582
|
/* Each definition can target multiple columns, as it is an array */
|
|
2607
|
-
var aTargets = def.
|
|
2608
|
-
def.
|
|
2609
|
-
def.
|
|
2583
|
+
var aTargets = def.target !== undefined
|
|
2584
|
+
? def.target
|
|
2585
|
+
: def.targets !== undefined
|
|
2586
|
+
? def.targets
|
|
2587
|
+
: def.aTargets;
|
|
2610
2588
|
|
|
2611
2589
|
if ( ! Array.isArray( aTargets ) )
|
|
2612
2590
|
{
|
|
@@ -5108,6 +5086,7 @@
|
|
|
5108
5086
|
'class': settings.oClasses.sProcessing
|
|
5109
5087
|
} )
|
|
5110
5088
|
.html( settings.oLanguage.sProcessing )
|
|
5089
|
+
.append('<div><div></div><div></div><div></div><div></div></div>')
|
|
5111
5090
|
.insertBefore( settings.nTable )[0];
|
|
5112
5091
|
}
|
|
5113
5092
|
|
|
@@ -5357,6 +5336,7 @@
|
|
|
5357
5336
|
footerCopy = footer.clone().prependTo( table );
|
|
5358
5337
|
footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
|
|
5359
5338
|
footerSrcEls = footerCopy.find('tr');
|
|
5339
|
+
footerCopy.find('[id]').removeAttr('id');
|
|
5360
5340
|
}
|
|
5361
5341
|
|
|
5362
5342
|
// Clone the current header and footer elements and then place it into the inner table
|
|
@@ -5364,6 +5344,7 @@
|
|
|
5364
5344
|
headerTrgEls = header.find('tr'); // original header is in its own table
|
|
5365
5345
|
headerSrcEls = headerCopy.find('tr');
|
|
5366
5346
|
headerCopy.find('th, td').removeAttr('tabindex');
|
|
5347
|
+
headerCopy.find('[id]').removeAttr('id');
|
|
5367
5348
|
|
|
5368
5349
|
|
|
5369
5350
|
/*
|
|
@@ -5437,7 +5418,7 @@
|
|
|
5437
5418
|
nToSize.style.width = headerWidths[i];
|
|
5438
5419
|
}, headerTrgEls );
|
|
5439
5420
|
|
|
5440
|
-
$(headerSrcEls).height
|
|
5421
|
+
$(headerSrcEls).css('height', 0);
|
|
5441
5422
|
|
|
5442
5423
|
/* Same again with the footer if we have one */
|
|
5443
5424
|
if ( footer )
|
|
@@ -6490,6 +6471,17 @@
|
|
|
6490
6471
|
// Store the saved state so it might be accessed at any time
|
|
6491
6472
|
settings.oLoadedState = $.extend( true, {}, s );
|
|
6492
6473
|
|
|
6474
|
+
// Page Length
|
|
6475
|
+
if ( s.length !== undefined ) {
|
|
6476
|
+
// If already initialised just set the value directly so that the select element is also updated
|
|
6477
|
+
if (api) {
|
|
6478
|
+
api.page.len(s.length)
|
|
6479
|
+
}
|
|
6480
|
+
else {
|
|
6481
|
+
settings._iDisplayLength = s.length;
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
|
|
6493
6485
|
// Restore key features - todo - for 1.11 this needs to be done by
|
|
6494
6486
|
// subscribed events
|
|
6495
6487
|
if ( s.start !== undefined ) {
|
|
@@ -6498,13 +6490,9 @@
|
|
|
6498
6490
|
settings.iInitDisplayStart = s.start;
|
|
6499
6491
|
}
|
|
6500
6492
|
else {
|
|
6501
|
-
_fnPageChange(settings, s.start/
|
|
6502
|
-
|
|
6493
|
+
_fnPageChange(settings, s.start/settings._iDisplayLength);
|
|
6503
6494
|
}
|
|
6504
6495
|
}
|
|
6505
|
-
if ( s.length !== undefined ) {
|
|
6506
|
-
settings._iDisplayLength = s.length;
|
|
6507
|
-
}
|
|
6508
6496
|
|
|
6509
6497
|
// Order
|
|
6510
6498
|
if ( s.order !== undefined ) {
|
|
@@ -6845,7 +6833,7 @@
|
|
|
6845
6833
|
return 'dom';
|
|
6846
6834
|
}
|
|
6847
6835
|
|
|
6848
|
-
|
|
6836
|
+
|
|
6849
6837
|
|
|
6850
6838
|
|
|
6851
6839
|
/**
|
|
@@ -7237,8 +7225,10 @@
|
|
|
7237
7225
|
|
|
7238
7226
|
pluck: function ( prop )
|
|
7239
7227
|
{
|
|
7228
|
+
let fn = DataTable.util.get(prop);
|
|
7229
|
+
|
|
7240
7230
|
return this.map( function ( el ) {
|
|
7241
|
-
return el
|
|
7231
|
+
return fn(el);
|
|
7242
7232
|
} );
|
|
7243
7233
|
},
|
|
7244
7234
|
|
|
@@ -8332,22 +8322,35 @@
|
|
|
8332
8322
|
|
|
8333
8323
|
$(document).on('plugin-init.dt', function (e, context) {
|
|
8334
8324
|
var api = new _Api( context );
|
|
8335
|
-
api.on( 'stateSaveParams', function ( e, settings, data ) {
|
|
8336
|
-
var indexes = api.rows().iterator( 'row', function ( settings, idx ) {
|
|
8337
|
-
return settings.aoData[idx]._detailsShow ? idx : undefined;
|
|
8338
|
-
});
|
|
8339
8325
|
|
|
8340
|
-
|
|
8326
|
+
api.on( 'stateSaveParams', function ( e, settings, d ) {
|
|
8327
|
+
// This could be more compact with the API, but it is a lot faster as a simple
|
|
8328
|
+
// internal loop
|
|
8329
|
+
var idFn = settings.rowIdFn;
|
|
8330
|
+
var data = settings.aoData;
|
|
8331
|
+
var ids = [];
|
|
8332
|
+
|
|
8333
|
+
for (var i=0 ; i<data.length ; i++) {
|
|
8334
|
+
if (data[i]._detailsShow) {
|
|
8335
|
+
ids.push( '#' + idFn(data[i]._aData) );
|
|
8336
|
+
}
|
|
8337
|
+
}
|
|
8338
|
+
|
|
8339
|
+
d.childRows = ids;
|
|
8341
8340
|
})
|
|
8342
8341
|
|
|
8343
8342
|
var loaded = api.state.loaded();
|
|
8344
8343
|
|
|
8345
8344
|
if ( loaded && loaded.childRows ) {
|
|
8346
|
-
api
|
|
8347
|
-
|
|
8348
|
-
|
|
8345
|
+
api
|
|
8346
|
+
.rows( $.map(loaded.childRows, function (id){
|
|
8347
|
+
return id.replace(/:/g, '\\:')
|
|
8348
|
+
}) )
|
|
8349
|
+
.every( function () {
|
|
8350
|
+
_fnCallbackFire( context, null, 'requestChild', [ this ] )
|
|
8351
|
+
});
|
|
8349
8352
|
}
|
|
8350
|
-
})
|
|
8353
|
+
});
|
|
8351
8354
|
|
|
8352
8355
|
var __details_add = function ( ctx, row, data, klass )
|
|
8353
8356
|
{
|
|
@@ -8394,6 +8397,15 @@
|
|
|
8394
8397
|
};
|
|
8395
8398
|
|
|
8396
8399
|
|
|
8400
|
+
// Make state saving of child row details async to allow them to be batch processed
|
|
8401
|
+
var __details_state = DataTable.util.throttle(
|
|
8402
|
+
function (ctx) {
|
|
8403
|
+
_fnSaveState( ctx[0] )
|
|
8404
|
+
},
|
|
8405
|
+
500
|
|
8406
|
+
);
|
|
8407
|
+
|
|
8408
|
+
|
|
8397
8409
|
var __details_remove = function ( api, idx )
|
|
8398
8410
|
{
|
|
8399
8411
|
var ctx = api.context;
|
|
@@ -8407,7 +8419,7 @@
|
|
|
8407
8419
|
row._detailsShow = undefined;
|
|
8408
8420
|
row._details = undefined;
|
|
8409
8421
|
$( row.nTr ).removeClass( 'dt-hasChild' );
|
|
8410
|
-
|
|
8422
|
+
__details_state( ctx );
|
|
8411
8423
|
}
|
|
8412
8424
|
}
|
|
8413
8425
|
};
|
|
@@ -8434,7 +8446,7 @@
|
|
|
8434
8446
|
_fnCallbackFire( ctx[0], null, 'childRow', [ show, api.row( api[0] ) ] )
|
|
8435
8447
|
|
|
8436
8448
|
__details_events( ctx[0] );
|
|
8437
|
-
|
|
8449
|
+
__details_state( ctx );
|
|
8438
8450
|
}
|
|
8439
8451
|
}
|
|
8440
8452
|
};
|
|
@@ -8445,7 +8457,7 @@
|
|
|
8445
8457
|
var api = new _Api( settings );
|
|
8446
8458
|
var namespace = '.dt.DT_details';
|
|
8447
8459
|
var drawEvent = 'draw'+namespace;
|
|
8448
|
-
var colvisEvent = 'column-
|
|
8460
|
+
var colvisEvent = 'column-sizing'+namespace;
|
|
8449
8461
|
var destroyEvent = 'destroy'+namespace;
|
|
8450
8462
|
var data = settings.aoData;
|
|
8451
8463
|
|
|
@@ -9497,7 +9509,6 @@
|
|
|
9497
9509
|
remove = remove || false;
|
|
9498
9510
|
|
|
9499
9511
|
return this.iterator( 'table', function ( settings ) {
|
|
9500
|
-
var orig = settings.nTableWrapper.parentNode;
|
|
9501
9512
|
var classes = settings.oClasses;
|
|
9502
9513
|
var table = settings.nTable;
|
|
9503
9514
|
var tbody = settings.nTBody;
|
|
@@ -9552,6 +9563,8 @@
|
|
|
9552
9563
|
jqTbody.children().detach();
|
|
9553
9564
|
jqTbody.append( rows );
|
|
9554
9565
|
|
|
9566
|
+
var orig = settings.nTableWrapper.parentNode;
|
|
9567
|
+
|
|
9555
9568
|
// Remove the DataTables generated nodes, events and classes
|
|
9556
9569
|
var removedMethod = remove ? 'remove' : 'detach';
|
|
9557
9570
|
jqTable[ removedMethod ]();
|
|
@@ -9636,7 +9649,7 @@
|
|
|
9636
9649
|
}
|
|
9637
9650
|
|
|
9638
9651
|
return resolved.replace( '%d', plural ); // nb: plural might be undefined,
|
|
9639
|
-
} );
|
|
9652
|
+
} );
|
|
9640
9653
|
/**
|
|
9641
9654
|
* Version string for plug-ins to check compatibility. Allowed format is
|
|
9642
9655
|
* `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
|
|
@@ -9645,8 +9658,8 @@
|
|
|
9645
9658
|
* @type string
|
|
9646
9659
|
* @default Version number
|
|
9647
9660
|
*/
|
|
9648
|
-
DataTable.version = "1.
|
|
9649
|
-
|
|
9661
|
+
DataTable.version = "1.12.1";
|
|
9662
|
+
|
|
9650
9663
|
/**
|
|
9651
9664
|
* Private data store, containing all of the settings objects that are
|
|
9652
9665
|
* created for the tables on a given page.
|
|
@@ -9660,7 +9673,7 @@
|
|
|
9660
9673
|
* @private
|
|
9661
9674
|
*/
|
|
9662
9675
|
DataTable.settings = [];
|
|
9663
|
-
|
|
9676
|
+
|
|
9664
9677
|
/**
|
|
9665
9678
|
* Object models container, for the various models that DataTables has
|
|
9666
9679
|
* available to it. These models define the objects that are used to hold
|
|
@@ -11850,7 +11863,6 @@
|
|
|
11850
11863
|
* Text which is displayed when the table is processing a user action
|
|
11851
11864
|
* (usually a sort command or similar).
|
|
11852
11865
|
* @type string
|
|
11853
|
-
* @default Processing...
|
|
11854
11866
|
*
|
|
11855
11867
|
* @dtopt Language
|
|
11856
11868
|
* @name DataTable.defaults.language.processing
|
|
@@ -11864,7 +11876,7 @@
|
|
|
11864
11876
|
* } );
|
|
11865
11877
|
* } );
|
|
11866
11878
|
*/
|
|
11867
|
-
"sProcessing": "
|
|
11879
|
+
"sProcessing": "",
|
|
11868
11880
|
|
|
11869
11881
|
|
|
11870
11882
|
/**
|
|
@@ -14018,7 +14030,7 @@
|
|
|
14018
14030
|
*/
|
|
14019
14031
|
"rowId": null
|
|
14020
14032
|
};
|
|
14021
|
-
|
|
14033
|
+
|
|
14022
14034
|
/**
|
|
14023
14035
|
* Extension object for DataTables that is used to provide all extension
|
|
14024
14036
|
* options.
|
|
@@ -15116,6 +15128,213 @@
|
|
|
15116
15128
|
d;
|
|
15117
15129
|
};
|
|
15118
15130
|
|
|
15131
|
+
// Common logic for moment, luxon or a date action
|
|
15132
|
+
function __mld( dt, momentFn, luxonFn, dateFn, arg1 ) {
|
|
15133
|
+
if (window.moment) {
|
|
15134
|
+
return dt[momentFn]( arg1 );
|
|
15135
|
+
}
|
|
15136
|
+
else if (window.luxon) {
|
|
15137
|
+
return dt[luxonFn]( arg1 );
|
|
15138
|
+
}
|
|
15139
|
+
|
|
15140
|
+
return dateFn ? dt[dateFn]( arg1 ) : dt;
|
|
15141
|
+
}
|
|
15142
|
+
|
|
15143
|
+
|
|
15144
|
+
var __mlWarning = false;
|
|
15145
|
+
function __mldObj (d, format, locale) {
|
|
15146
|
+
var dt;
|
|
15147
|
+
|
|
15148
|
+
if (window.moment) {
|
|
15149
|
+
dt = window.moment.utc( d, format, locale, true );
|
|
15150
|
+
|
|
15151
|
+
if (! dt.isValid()) {
|
|
15152
|
+
return null;
|
|
15153
|
+
}
|
|
15154
|
+
}
|
|
15155
|
+
else if (window.luxon) {
|
|
15156
|
+
dt = format
|
|
15157
|
+
? window.luxon.DateTime.fromFormat( d, format )
|
|
15158
|
+
: window.luxon.DateTime.fromISO( d );
|
|
15159
|
+
|
|
15160
|
+
if (! dt.isValid) {
|
|
15161
|
+
return null;
|
|
15162
|
+
}
|
|
15163
|
+
|
|
15164
|
+
dt.setLocale(locale);
|
|
15165
|
+
}
|
|
15166
|
+
else if (! format) {
|
|
15167
|
+
// No format given, must be ISO
|
|
15168
|
+
dt = new Date(d);
|
|
15169
|
+
}
|
|
15170
|
+
else {
|
|
15171
|
+
if (! __mlWarning) {
|
|
15172
|
+
alert('DataTables warning: Formatted date without Moment.js or Luxon - https://datatables.net/tn/17');
|
|
15173
|
+
}
|
|
15174
|
+
|
|
15175
|
+
__mlWarning = true;
|
|
15176
|
+
}
|
|
15177
|
+
|
|
15178
|
+
return dt;
|
|
15179
|
+
}
|
|
15180
|
+
|
|
15181
|
+
// Wrapper for date, datetime and time which all operate the same way with the exception of
|
|
15182
|
+
// the output string for auto locale support
|
|
15183
|
+
function __mlHelper (localeString) {
|
|
15184
|
+
return function ( from, to, locale, def ) {
|
|
15185
|
+
// Luxon and Moment support
|
|
15186
|
+
// Argument shifting
|
|
15187
|
+
if ( arguments.length === 0 ) {
|
|
15188
|
+
locale = 'en';
|
|
15189
|
+
to = null; // means toLocaleString
|
|
15190
|
+
from = null; // means iso8601
|
|
15191
|
+
}
|
|
15192
|
+
else if ( arguments.length === 1 ) {
|
|
15193
|
+
locale = 'en';
|
|
15194
|
+
to = from;
|
|
15195
|
+
from = null;
|
|
15196
|
+
}
|
|
15197
|
+
else if ( arguments.length === 2 ) {
|
|
15198
|
+
locale = to;
|
|
15199
|
+
to = from;
|
|
15200
|
+
from = null;
|
|
15201
|
+
}
|
|
15202
|
+
|
|
15203
|
+
var typeName = 'datetime-' + to;
|
|
15204
|
+
|
|
15205
|
+
// Add type detection and sorting specific to this date format - we need to be able to identify
|
|
15206
|
+
// date type columns as such, rather than as numbers in extensions. Hence the need for this.
|
|
15207
|
+
if (! DataTable.ext.type.order[typeName]) {
|
|
15208
|
+
// The renderer will give the value to type detect as the type!
|
|
15209
|
+
DataTable.ext.type.detect.unshift(function (d) {
|
|
15210
|
+
return d === typeName ? typeName : false;
|
|
15211
|
+
});
|
|
15212
|
+
|
|
15213
|
+
// The renderer gives us Moment, Luxon or Date obects for the sorting, all of which have a
|
|
15214
|
+
// `valueOf` which gives milliseconds epoch
|
|
15215
|
+
DataTable.ext.type.order[typeName + '-asc'] = function (a, b) {
|
|
15216
|
+
var x = a.valueOf();
|
|
15217
|
+
var y = b.valueOf();
|
|
15218
|
+
|
|
15219
|
+
return x === y
|
|
15220
|
+
? 0
|
|
15221
|
+
: x < y
|
|
15222
|
+
? -1
|
|
15223
|
+
: 1;
|
|
15224
|
+
}
|
|
15225
|
+
|
|
15226
|
+
DataTable.ext.type.order[typeName + '-desc'] = function (a, b) {
|
|
15227
|
+
var x = a.valueOf();
|
|
15228
|
+
var y = b.valueOf();
|
|
15229
|
+
|
|
15230
|
+
return x === y
|
|
15231
|
+
? 0
|
|
15232
|
+
: x > y
|
|
15233
|
+
? -1
|
|
15234
|
+
: 1;
|
|
15235
|
+
}
|
|
15236
|
+
}
|
|
15237
|
+
|
|
15238
|
+
return function ( d, type ) {
|
|
15239
|
+
// Allow for a default value
|
|
15240
|
+
if (d === null || d === undefined) {
|
|
15241
|
+
if (def === '--now') {
|
|
15242
|
+
// We treat everything as UTC further down, so no changes are
|
|
15243
|
+
// made, as such need to get the local date / time as if it were
|
|
15244
|
+
// UTC
|
|
15245
|
+
var local = new Date();
|
|
15246
|
+
d = new Date( Date.UTC(
|
|
15247
|
+
local.getFullYear(), local.getMonth(), local.getDate(),
|
|
15248
|
+
local.getHours(), local.getMinutes(), local.getSeconds()
|
|
15249
|
+
) );
|
|
15250
|
+
}
|
|
15251
|
+
else {
|
|
15252
|
+
d = '';
|
|
15253
|
+
}
|
|
15254
|
+
}
|
|
15255
|
+
|
|
15256
|
+
if (type === 'type') {
|
|
15257
|
+
// Typing uses the type name for fast matching
|
|
15258
|
+
return typeName;
|
|
15259
|
+
}
|
|
15260
|
+
|
|
15261
|
+
if (d === '') {
|
|
15262
|
+
return type !== 'sort'
|
|
15263
|
+
? ''
|
|
15264
|
+
: __mldObj('0000-01-01 00:00:00', null, locale);
|
|
15265
|
+
}
|
|
15266
|
+
|
|
15267
|
+
// Shortcut. If `from` and `to` are the same, we are using the renderer to
|
|
15268
|
+
// format for ordering, not display - its already in the display format.
|
|
15269
|
+
if ( to !== null && from === to && type !== 'sort' && type !== 'type' && ! (d instanceof Date) ) {
|
|
15270
|
+
return d;
|
|
15271
|
+
}
|
|
15272
|
+
|
|
15273
|
+
var dt = __mldObj(d, from, locale);
|
|
15274
|
+
|
|
15275
|
+
if (dt === null) {
|
|
15276
|
+
return d;
|
|
15277
|
+
}
|
|
15278
|
+
|
|
15279
|
+
if (type === 'sort') {
|
|
15280
|
+
return dt;
|
|
15281
|
+
}
|
|
15282
|
+
|
|
15283
|
+
var formatted = to === null
|
|
15284
|
+
? __mld(dt, 'toDate', 'toJSDate', '')[localeString]()
|
|
15285
|
+
: __mld(dt, 'format', 'toFormat', 'toISOString', to);
|
|
15286
|
+
|
|
15287
|
+
// XSS protection
|
|
15288
|
+
return type === 'display' ?
|
|
15289
|
+
__htmlEscapeEntities( formatted ) :
|
|
15290
|
+
formatted;
|
|
15291
|
+
};
|
|
15292
|
+
}
|
|
15293
|
+
}
|
|
15294
|
+
|
|
15295
|
+
// Based on locale, determine standard number formatting
|
|
15296
|
+
// Fallback for legacy browsers is US English
|
|
15297
|
+
var __thousands = ',';
|
|
15298
|
+
var __decimal = '.';
|
|
15299
|
+
|
|
15300
|
+
if (Intl) {
|
|
15301
|
+
try {
|
|
15302
|
+
var num = new Intl.NumberFormat().formatToParts(100000.1);
|
|
15303
|
+
|
|
15304
|
+
for (var i=0 ; i<num.length ; i++) {
|
|
15305
|
+
if (num[i].type === 'group') {
|
|
15306
|
+
__thousands = num[i].value;
|
|
15307
|
+
}
|
|
15308
|
+
else if (num[i].type === 'decimal') {
|
|
15309
|
+
__decimal = num[i].value;
|
|
15310
|
+
}
|
|
15311
|
+
}
|
|
15312
|
+
}
|
|
15313
|
+
catch (e) {
|
|
15314
|
+
// noop
|
|
15315
|
+
}
|
|
15316
|
+
}
|
|
15317
|
+
|
|
15318
|
+
// Formatted date time detection - use by declaring the formats you are going to use
|
|
15319
|
+
DataTable.datetime = function ( format, locale ) {
|
|
15320
|
+
var typeName = 'datetime-detect-' + format;
|
|
15321
|
+
|
|
15322
|
+
if (! locale) {
|
|
15323
|
+
locale = 'en';
|
|
15324
|
+
}
|
|
15325
|
+
|
|
15326
|
+
if (! DataTable.ext.type.order[typeName]) {
|
|
15327
|
+
DataTable.ext.type.detect.unshift(function (d) {
|
|
15328
|
+
var dt = __mldObj(d, format, locale);
|
|
15329
|
+
return d === '' || dt ? typeName : false;
|
|
15330
|
+
});
|
|
15331
|
+
|
|
15332
|
+
DataTable.ext.type.order[typeName + '-pre'] = function (d) {
|
|
15333
|
+
return __mldObj(d, format, locale) || 0;
|
|
15334
|
+
}
|
|
15335
|
+
}
|
|
15336
|
+
}
|
|
15337
|
+
|
|
15119
15338
|
/**
|
|
15120
15339
|
* Helpers for `columns.render`.
|
|
15121
15340
|
*
|
|
@@ -15143,13 +15362,29 @@
|
|
|
15143
15362
|
* @namespace
|
|
15144
15363
|
*/
|
|
15145
15364
|
DataTable.render = {
|
|
15365
|
+
date: __mlHelper('toLocaleDateString'),
|
|
15366
|
+
datetime: __mlHelper('toLocaleString'),
|
|
15367
|
+
time: __mlHelper('toLocaleTimeString'),
|
|
15146
15368
|
number: function ( thousands, decimal, precision, prefix, postfix ) {
|
|
15369
|
+
// Auto locale detection
|
|
15370
|
+
if (thousands === null || thousands === undefined) {
|
|
15371
|
+
thousands = __thousands;
|
|
15372
|
+
}
|
|
15373
|
+
|
|
15374
|
+
if (decimal === null || decimal === undefined) {
|
|
15375
|
+
decimal = __decimal;
|
|
15376
|
+
}
|
|
15377
|
+
|
|
15147
15378
|
return {
|
|
15148
15379
|
display: function ( d ) {
|
|
15149
15380
|
if ( typeof d !== 'number' && typeof d !== 'string' ) {
|
|
15150
15381
|
return d;
|
|
15151
15382
|
}
|
|
15152
15383
|
|
|
15384
|
+
if (d === '' || d === null) {
|
|
15385
|
+
return d;
|
|
15386
|
+
}
|
|
15387
|
+
|
|
15153
15388
|
var negative = d < 0 ? '-' : '';
|
|
15154
15389
|
var flo = parseFloat( d );
|
|
15155
15390
|
|
|
@@ -15318,28 +15553,28 @@
|
|
|
15318
15553
|
// added to prevent errors
|
|
15319
15554
|
} );
|
|
15320
15555
|
|
|
15321
|
-
|
|
15556
|
+
|
|
15322
15557
|
// jQuery access
|
|
15323
15558
|
$.fn.dataTable = DataTable;
|
|
15324
|
-
|
|
15559
|
+
|
|
15325
15560
|
// Provide access to the host jQuery object (circular reference)
|
|
15326
15561
|
DataTable.$ = $;
|
|
15327
|
-
|
|
15562
|
+
|
|
15328
15563
|
// Legacy aliases
|
|
15329
15564
|
$.fn.dataTableSettings = DataTable.settings;
|
|
15330
15565
|
$.fn.dataTableExt = DataTable.ext;
|
|
15331
|
-
|
|
15566
|
+
|
|
15332
15567
|
// With a capital `D` we return a DataTables API instance rather than a
|
|
15333
15568
|
// jQuery object
|
|
15334
15569
|
$.fn.DataTable = function ( opts ) {
|
|
15335
15570
|
return $(this).dataTable( opts ).api();
|
|
15336
15571
|
};
|
|
15337
|
-
|
|
15572
|
+
|
|
15338
15573
|
// All properties that are available to $.fn.dataTable should also be
|
|
15339
15574
|
// available on $.fn.DataTable
|
|
15340
15575
|
$.each( DataTable, function ( prop, val ) {
|
|
15341
15576
|
$.fn.DataTable[ prop ] = val;
|
|
15342
15577
|
} );
|
|
15343
|
-
|
|
15578
|
+
|
|
15344
15579
|
return DataTable;
|
|
15345
15580
|
}));
|