datatables.net 1.10.25 → 1.11.3
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/Readme.md +56 -1
- package/js/jquery.dataTables.js +482 -531
- package/js/jquery.dataTables.min.js +184 -165
- package/package.json +3 -2
- package/types/types.d.ts +2714 -0
package/js/jquery.dataTables.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/*! DataTables 1.
|
|
1
|
+
/*! DataTables 1.11.3
|
|
2
2
|
* ©2008-2021 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.
|
|
8
|
+
* @version 1.11.3
|
|
9
9
|
* @file jquery.dataTables.js
|
|
10
10
|
* @author SpryMedia Ltd
|
|
11
11
|
* @contact www.datatables.net
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
// Browser
|
|
56
|
-
factory( jQuery, window, document );
|
|
56
|
+
window.DataTable = factory( jQuery, window, document );
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
(function( $, window, document, undefined ) {
|
|
@@ -91,8 +91,17 @@
|
|
|
91
91
|
* } );
|
|
92
92
|
* } );
|
|
93
93
|
*/
|
|
94
|
-
var DataTable = function ( options )
|
|
94
|
+
var DataTable = function ( selector, options )
|
|
95
95
|
{
|
|
96
|
+
// When creating with `new`, create a new DataTable, returning the API instance
|
|
97
|
+
if (this instanceof DataTable) {
|
|
98
|
+
return $(selector).DataTable(options);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Argument switching
|
|
102
|
+
options = selector;
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
/**
|
|
97
106
|
* Perform a jQuery selector action on the table's TR elements (from the tbody) and
|
|
98
107
|
* return the resulting jQuery object.
|
|
@@ -1085,8 +1094,8 @@
|
|
|
1085
1094
|
dataType: 'json',
|
|
1086
1095
|
url: oLanguage.sUrl,
|
|
1087
1096
|
success: function ( json ) {
|
|
1088
|
-
_fnLanguageCompat( json );
|
|
1089
1097
|
_fnCamelToHungarian( defaults.oLanguage, json );
|
|
1098
|
+
_fnLanguageCompat( json );
|
|
1090
1099
|
$.extend( true, oLanguage, json );
|
|
1091
1100
|
|
|
1092
1101
|
_fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
|
|
@@ -1301,10 +1310,11 @@
|
|
|
1301
1310
|
};
|
|
1302
1311
|
|
|
1303
1312
|
/* Must be done after everything which can be overridden by the state saving! */
|
|
1313
|
+
_fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
|
|
1314
|
+
|
|
1304
1315
|
if ( oInit.bStateSave )
|
|
1305
1316
|
{
|
|
1306
1317
|
features.bStateSave = true;
|
|
1307
|
-
_fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
|
|
1308
1318
|
_fnLoadState( oSettings, oInit, loadedInit );
|
|
1309
1319
|
}
|
|
1310
1320
|
else {
|
|
@@ -1604,6 +1614,14 @@
|
|
|
1604
1614
|
return out;
|
|
1605
1615
|
}
|
|
1606
1616
|
|
|
1617
|
+
var _includes = function (search, start) {
|
|
1618
|
+
if (start === undefined) {
|
|
1619
|
+
start = 0;
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
return this.indexOf(search, start) !== -1;
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1607
1625
|
// Array.isArray polyfill.
|
|
1608
1626
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
1609
1627
|
if (! Array.isArray) {
|
|
@@ -1612,6 +1630,10 @@
|
|
|
1612
1630
|
};
|
|
1613
1631
|
}
|
|
1614
1632
|
|
|
1633
|
+
if (! Array.prototype.includes) {
|
|
1634
|
+
Array.prototype.includes = _includes;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1615
1637
|
// .trim() polyfill
|
|
1616
1638
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
|
|
1617
1639
|
if (!String.prototype.trim) {
|
|
@@ -1620,6 +1642,10 @@
|
|
|
1620
1642
|
};
|
|
1621
1643
|
}
|
|
1622
1644
|
|
|
1645
|
+
if (! String.prototype.includes) {
|
|
1646
|
+
String.prototype.includes = _includes;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1623
1649
|
/**
|
|
1624
1650
|
* DataTables utility methods
|
|
1625
1651
|
*
|
|
@@ -1675,6 +1701,227 @@
|
|
|
1675
1701
|
*/
|
|
1676
1702
|
escapeRegex: function ( val ) {
|
|
1677
1703
|
return val.replace( _re_escape_regex, '\\$1' );
|
|
1704
|
+
},
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* Create a function that will write to a nested object or array
|
|
1708
|
+
* @param {*} source JSON notation string
|
|
1709
|
+
* @returns Write function
|
|
1710
|
+
*/
|
|
1711
|
+
set: function ( source ) {
|
|
1712
|
+
if ( $.isPlainObject( source ) ) {
|
|
1713
|
+
/* Unlike get, only the underscore (global) option is used for for
|
|
1714
|
+
* setting data since we don't know the type here. This is why an object
|
|
1715
|
+
* option is not documented for `mData` (which is read/write), but it is
|
|
1716
|
+
* for `mRender` which is read only.
|
|
1717
|
+
*/
|
|
1718
|
+
return DataTable.util.set( source._ );
|
|
1719
|
+
}
|
|
1720
|
+
else if ( source === null ) {
|
|
1721
|
+
// Nothing to do when the data source is null
|
|
1722
|
+
return function () {};
|
|
1723
|
+
}
|
|
1724
|
+
else if ( typeof source === 'function' ) {
|
|
1725
|
+
return function (data, val, meta) {
|
|
1726
|
+
source( data, 'set', val, meta );
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
|
|
1730
|
+
source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
|
|
1731
|
+
{
|
|
1732
|
+
// Like the get, we need to get data from a nested object
|
|
1733
|
+
var setData = function (data, val, src) {
|
|
1734
|
+
var a = _fnSplitObjNotation( src ), b;
|
|
1735
|
+
var aLast = a[a.length-1];
|
|
1736
|
+
var arrayNotation, funcNotation, o, innerSrc;
|
|
1737
|
+
|
|
1738
|
+
for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ ) {
|
|
1739
|
+
// Protect against prototype pollution
|
|
1740
|
+
if (a[i] === '__proto__' || a[i] === 'constructor') {
|
|
1741
|
+
throw new Error('Cannot set prototype values');
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// Check if we are dealing with an array notation request
|
|
1745
|
+
arrayNotation = a[i].match(__reArray);
|
|
1746
|
+
funcNotation = a[i].match(__reFn);
|
|
1747
|
+
|
|
1748
|
+
if ( arrayNotation ) {
|
|
1749
|
+
a[i] = a[i].replace(__reArray, '');
|
|
1750
|
+
data[ a[i] ] = [];
|
|
1751
|
+
|
|
1752
|
+
// Get the remainder of the nested object to set so we can recurse
|
|
1753
|
+
b = a.slice();
|
|
1754
|
+
b.splice( 0, i+1 );
|
|
1755
|
+
innerSrc = b.join('.');
|
|
1756
|
+
|
|
1757
|
+
// Traverse each entry in the array setting the properties requested
|
|
1758
|
+
if ( Array.isArray( val ) ) {
|
|
1759
|
+
for ( var j=0, jLen=val.length ; j<jLen ; j++ ) {
|
|
1760
|
+
o = {};
|
|
1761
|
+
setData( o, val[j], innerSrc );
|
|
1762
|
+
data[ a[i] ].push( o );
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
else {
|
|
1766
|
+
// We've been asked to save data to an array, but it
|
|
1767
|
+
// isn't array data to be saved. Best that can be done
|
|
1768
|
+
// is to just save the value.
|
|
1769
|
+
data[ a[i] ] = val;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// The inner call to setData has already traversed through the remainder
|
|
1773
|
+
// of the source and has set the data, thus we can exit here
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
else if ( funcNotation ) {
|
|
1777
|
+
// Function call
|
|
1778
|
+
a[i] = a[i].replace(__reFn, '');
|
|
1779
|
+
data = data[ a[i] ]( val );
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
// If the nested object doesn't currently exist - since we are
|
|
1783
|
+
// trying to set the value - create it
|
|
1784
|
+
if ( data[ a[i] ] === null || data[ a[i] ] === undefined ) {
|
|
1785
|
+
data[ a[i] ] = {};
|
|
1786
|
+
}
|
|
1787
|
+
data = data[ a[i] ];
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
// Last item in the input - i.e, the actual set
|
|
1791
|
+
if ( aLast.match(__reFn ) ) {
|
|
1792
|
+
// Function call
|
|
1793
|
+
data = data[ aLast.replace(__reFn, '') ]( val );
|
|
1794
|
+
}
|
|
1795
|
+
else {
|
|
1796
|
+
// If array notation is used, we just want to strip it and use the property name
|
|
1797
|
+
// and assign the value. If it isn't used, then we get the result we want anyway
|
|
1798
|
+
data[ aLast.replace(__reArray, '') ] = val;
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1802
|
+
return function (data, val) { // meta is also passed in, but not used
|
|
1803
|
+
return setData( data, val, source );
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
else {
|
|
1807
|
+
// Array or flat object mapping
|
|
1808
|
+
return function (data, val) { // meta is also passed in, but not used
|
|
1809
|
+
data[source] = val;
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
},
|
|
1813
|
+
|
|
1814
|
+
/**
|
|
1815
|
+
* Create a function that will read nested objects from arrays, based on JSON notation
|
|
1816
|
+
* @param {*} source JSON notation string
|
|
1817
|
+
* @returns Value read
|
|
1818
|
+
*/
|
|
1819
|
+
get: function ( source ) {
|
|
1820
|
+
if ( $.isPlainObject( source ) ) {
|
|
1821
|
+
// Build an object of get functions, and wrap them in a single call
|
|
1822
|
+
var o = {};
|
|
1823
|
+
$.each( source, function (key, val) {
|
|
1824
|
+
if ( val ) {
|
|
1825
|
+
o[key] = DataTable.util.get( val );
|
|
1826
|
+
}
|
|
1827
|
+
} );
|
|
1828
|
+
|
|
1829
|
+
return function (data, type, row, meta) {
|
|
1830
|
+
var t = o[type] || o._;
|
|
1831
|
+
return t !== undefined ?
|
|
1832
|
+
t(data, type, row, meta) :
|
|
1833
|
+
data;
|
|
1834
|
+
};
|
|
1835
|
+
}
|
|
1836
|
+
else if ( source === null ) {
|
|
1837
|
+
// Give an empty string for rendering / sorting etc
|
|
1838
|
+
return function (data) { // type, row and meta also passed, but not used
|
|
1839
|
+
return data;
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
else if ( typeof source === 'function' ) {
|
|
1843
|
+
return function (data, type, row, meta) {
|
|
1844
|
+
return source( data, type, row, meta );
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
|
|
1848
|
+
source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
|
|
1849
|
+
{
|
|
1850
|
+
/* If there is a . in the source string then the data source is in a
|
|
1851
|
+
* nested object so we loop over the data for each level to get the next
|
|
1852
|
+
* level down. On each loop we test for undefined, and if found immediately
|
|
1853
|
+
* return. This allows entire objects to be missing and sDefaultContent to
|
|
1854
|
+
* be used if defined, rather than throwing an error
|
|
1855
|
+
*/
|
|
1856
|
+
var fetchData = function (data, type, src) {
|
|
1857
|
+
var arrayNotation, funcNotation, out, innerSrc;
|
|
1858
|
+
|
|
1859
|
+
if ( src !== "" ) {
|
|
1860
|
+
var a = _fnSplitObjNotation( src );
|
|
1861
|
+
|
|
1862
|
+
for ( var i=0, iLen=a.length ; i<iLen ; i++ ) {
|
|
1863
|
+
// Check if we are dealing with special notation
|
|
1864
|
+
arrayNotation = a[i].match(__reArray);
|
|
1865
|
+
funcNotation = a[i].match(__reFn);
|
|
1866
|
+
|
|
1867
|
+
if ( arrayNotation ) {
|
|
1868
|
+
// Array notation
|
|
1869
|
+
a[i] = a[i].replace(__reArray, '');
|
|
1870
|
+
|
|
1871
|
+
// Condition allows simply [] to be passed in
|
|
1872
|
+
if ( a[i] !== "" ) {
|
|
1873
|
+
data = data[ a[i] ];
|
|
1874
|
+
}
|
|
1875
|
+
out = [];
|
|
1876
|
+
|
|
1877
|
+
// Get the remainder of the nested object to get
|
|
1878
|
+
a.splice( 0, i+1 );
|
|
1879
|
+
innerSrc = a.join('.');
|
|
1880
|
+
|
|
1881
|
+
// Traverse each entry in the array getting the properties requested
|
|
1882
|
+
if ( Array.isArray( data ) ) {
|
|
1883
|
+
for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
|
|
1884
|
+
out.push( fetchData( data[j], type, innerSrc ) );
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
// If a string is given in between the array notation indicators, that
|
|
1889
|
+
// is used to join the strings together, otherwise an array is returned
|
|
1890
|
+
var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
|
|
1891
|
+
data = (join==="") ? out : out.join(join);
|
|
1892
|
+
|
|
1893
|
+
// The inner call to fetchData has already traversed through the remainder
|
|
1894
|
+
// of the source requested, so we exit from the loop
|
|
1895
|
+
break;
|
|
1896
|
+
}
|
|
1897
|
+
else if ( funcNotation ) {
|
|
1898
|
+
// Function call
|
|
1899
|
+
a[i] = a[i].replace(__reFn, '');
|
|
1900
|
+
data = data[ a[i] ]();
|
|
1901
|
+
continue;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
if ( data === null || data[ a[i] ] === undefined ) {
|
|
1905
|
+
return undefined;
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
data = data[ a[i] ];
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
return data;
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
return function (data, type) { // row and meta also passed, but not used
|
|
1916
|
+
return fetchData( data, type, source );
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
else {
|
|
1920
|
+
// Array or flat object mapping
|
|
1921
|
+
return function (data, type) { // row and meta also passed, but not used
|
|
1922
|
+
return data[source];
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1678
1925
|
}
|
|
1679
1926
|
};
|
|
1680
1927
|
|
|
@@ -2189,7 +2436,7 @@
|
|
|
2189
2436
|
|
|
2190
2437
|
|
|
2191
2438
|
/**
|
|
2192
|
-
*
|
|
2439
|
+
* Convert the index of a visible column to the index in the data array (take account
|
|
2193
2440
|
* of hidden columns)
|
|
2194
2441
|
* @param {object} oSettings dataTables settings object
|
|
2195
2442
|
* @param {int} iMatch Visible column index to lookup
|
|
@@ -2207,7 +2454,7 @@
|
|
|
2207
2454
|
|
|
2208
2455
|
|
|
2209
2456
|
/**
|
|
2210
|
-
*
|
|
2457
|
+
* Convert the index of an index in the data array and convert it to the visible
|
|
2211
2458
|
* column index (take account of hidden columns)
|
|
2212
2459
|
* @param {int} iMatch Column index to lookup
|
|
2213
2460
|
* @param {object} oSettings dataTables settings object
|
|
@@ -2521,12 +2768,19 @@
|
|
|
2521
2768
|
* @param {object} settings dataTables settings object
|
|
2522
2769
|
* @param {int} rowIdx aoData row id
|
|
2523
2770
|
* @param {int} colIdx Column index
|
|
2524
|
-
* @param {string} type data get type ('display', 'type' 'filter' 'sort')
|
|
2771
|
+
* @param {string} type data get type ('display', 'type' 'filter|search' 'sort|order')
|
|
2525
2772
|
* @returns {*} Cell data
|
|
2526
2773
|
* @memberof DataTable#oApi
|
|
2527
2774
|
*/
|
|
2528
2775
|
function _fnGetCellData( settings, rowIdx, colIdx, type )
|
|
2529
2776
|
{
|
|
2777
|
+
if (type === 'search') {
|
|
2778
|
+
type = 'filter';
|
|
2779
|
+
}
|
|
2780
|
+
else if (type === 'order') {
|
|
2781
|
+
type = 'sort';
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2530
2784
|
var draw = settings.iDraw;
|
|
2531
2785
|
var col = settings.aoColumns[colIdx];
|
|
2532
2786
|
var rowData = settings.aoData[rowIdx]._aData;
|
|
@@ -2558,9 +2812,18 @@
|
|
|
2558
2812
|
return cellData.call( rowData );
|
|
2559
2813
|
}
|
|
2560
2814
|
|
|
2561
|
-
if ( cellData === null && type
|
|
2815
|
+
if ( cellData === null && type === 'display' ) {
|
|
2562
2816
|
return '';
|
|
2563
2817
|
}
|
|
2818
|
+
|
|
2819
|
+
if ( type === 'filter' ) {
|
|
2820
|
+
var fomatters = DataTable.ext.type.search;
|
|
2821
|
+
|
|
2822
|
+
if ( fomatters[ col.sType ] ) {
|
|
2823
|
+
cellData = fomatters[ col.sType ]( cellData );
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2564
2827
|
return cellData;
|
|
2565
2828
|
}
|
|
2566
2829
|
|
|
@@ -2610,122 +2873,7 @@
|
|
|
2610
2873
|
* @returns {function} Data get function
|
|
2611
2874
|
* @memberof DataTable#oApi
|
|
2612
2875
|
*/
|
|
2613
|
-
|
|
2614
|
-
{
|
|
2615
|
-
if ( $.isPlainObject( mSource ) )
|
|
2616
|
-
{
|
|
2617
|
-
/* Build an object of get functions, and wrap them in a single call */
|
|
2618
|
-
var o = {};
|
|
2619
|
-
$.each( mSource, function (key, val) {
|
|
2620
|
-
if ( val ) {
|
|
2621
|
-
o[key] = _fnGetObjectDataFn( val );
|
|
2622
|
-
}
|
|
2623
|
-
} );
|
|
2624
|
-
|
|
2625
|
-
return function (data, type, row, meta) {
|
|
2626
|
-
var t = o[type] || o._;
|
|
2627
|
-
return t !== undefined ?
|
|
2628
|
-
t(data, type, row, meta) :
|
|
2629
|
-
data;
|
|
2630
|
-
};
|
|
2631
|
-
}
|
|
2632
|
-
else if ( mSource === null )
|
|
2633
|
-
{
|
|
2634
|
-
/* Give an empty string for rendering / sorting etc */
|
|
2635
|
-
return function (data) { // type, row and meta also passed, but not used
|
|
2636
|
-
return data;
|
|
2637
|
-
};
|
|
2638
|
-
}
|
|
2639
|
-
else if ( typeof mSource === 'function' )
|
|
2640
|
-
{
|
|
2641
|
-
return function (data, type, row, meta) {
|
|
2642
|
-
return mSource( data, type, row, meta );
|
|
2643
|
-
};
|
|
2644
|
-
}
|
|
2645
|
-
else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
|
|
2646
|
-
mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
|
|
2647
|
-
{
|
|
2648
|
-
/* If there is a . in the source string then the data source is in a
|
|
2649
|
-
* nested object so we loop over the data for each level to get the next
|
|
2650
|
-
* level down. On each loop we test for undefined, and if found immediately
|
|
2651
|
-
* return. This allows entire objects to be missing and sDefaultContent to
|
|
2652
|
-
* be used if defined, rather than throwing an error
|
|
2653
|
-
*/
|
|
2654
|
-
var fetchData = function (data, type, src) {
|
|
2655
|
-
var arrayNotation, funcNotation, out, innerSrc;
|
|
2656
|
-
|
|
2657
|
-
if ( src !== "" )
|
|
2658
|
-
{
|
|
2659
|
-
var a = _fnSplitObjNotation( src );
|
|
2660
|
-
|
|
2661
|
-
for ( var i=0, iLen=a.length ; i<iLen ; i++ )
|
|
2662
|
-
{
|
|
2663
|
-
// Check if we are dealing with special notation
|
|
2664
|
-
arrayNotation = a[i].match(__reArray);
|
|
2665
|
-
funcNotation = a[i].match(__reFn);
|
|
2666
|
-
|
|
2667
|
-
if ( arrayNotation )
|
|
2668
|
-
{
|
|
2669
|
-
// Array notation
|
|
2670
|
-
a[i] = a[i].replace(__reArray, '');
|
|
2671
|
-
|
|
2672
|
-
// Condition allows simply [] to be passed in
|
|
2673
|
-
if ( a[i] !== "" ) {
|
|
2674
|
-
data = data[ a[i] ];
|
|
2675
|
-
}
|
|
2676
|
-
out = [];
|
|
2677
|
-
|
|
2678
|
-
// Get the remainder of the nested object to get
|
|
2679
|
-
a.splice( 0, i+1 );
|
|
2680
|
-
innerSrc = a.join('.');
|
|
2681
|
-
|
|
2682
|
-
// Traverse each entry in the array getting the properties requested
|
|
2683
|
-
if ( Array.isArray( data ) ) {
|
|
2684
|
-
for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
|
|
2685
|
-
out.push( fetchData( data[j], type, innerSrc ) );
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
// If a string is given in between the array notation indicators, that
|
|
2690
|
-
// is used to join the strings together, otherwise an array is returned
|
|
2691
|
-
var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
|
|
2692
|
-
data = (join==="") ? out : out.join(join);
|
|
2693
|
-
|
|
2694
|
-
// The inner call to fetchData has already traversed through the remainder
|
|
2695
|
-
// of the source requested, so we exit from the loop
|
|
2696
|
-
break;
|
|
2697
|
-
}
|
|
2698
|
-
else if ( funcNotation )
|
|
2699
|
-
{
|
|
2700
|
-
// Function call
|
|
2701
|
-
a[i] = a[i].replace(__reFn, '');
|
|
2702
|
-
data = data[ a[i] ]();
|
|
2703
|
-
continue;
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
if ( data === null || data[ a[i] ] === undefined )
|
|
2707
|
-
{
|
|
2708
|
-
return undefined;
|
|
2709
|
-
}
|
|
2710
|
-
data = data[ a[i] ];
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
return data;
|
|
2715
|
-
};
|
|
2716
|
-
|
|
2717
|
-
return function (data, type) { // row and meta also passed, but not used
|
|
2718
|
-
return fetchData( data, type, mSource );
|
|
2719
|
-
};
|
|
2720
|
-
}
|
|
2721
|
-
else
|
|
2722
|
-
{
|
|
2723
|
-
/* Array or flat object mapping */
|
|
2724
|
-
return function (data, type) { // row and meta also passed, but not used
|
|
2725
|
-
return data[mSource];
|
|
2726
|
-
};
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2876
|
+
var _fnGetObjectDataFn = DataTable.util.get;
|
|
2729
2877
|
|
|
2730
2878
|
|
|
2731
2879
|
/**
|
|
@@ -2735,122 +2883,7 @@
|
|
|
2735
2883
|
* @returns {function} Data set function
|
|
2736
2884
|
* @memberof DataTable#oApi
|
|
2737
2885
|
*/
|
|
2738
|
-
|
|
2739
|
-
{
|
|
2740
|
-
if ( $.isPlainObject( mSource ) )
|
|
2741
|
-
{
|
|
2742
|
-
/* Unlike get, only the underscore (global) option is used for for
|
|
2743
|
-
* setting data since we don't know the type here. This is why an object
|
|
2744
|
-
* option is not documented for `mData` (which is read/write), but it is
|
|
2745
|
-
* for `mRender` which is read only.
|
|
2746
|
-
*/
|
|
2747
|
-
return _fnSetObjectDataFn( mSource._ );
|
|
2748
|
-
}
|
|
2749
|
-
else if ( mSource === null )
|
|
2750
|
-
{
|
|
2751
|
-
/* Nothing to do when the data source is null */
|
|
2752
|
-
return function () {};
|
|
2753
|
-
}
|
|
2754
|
-
else if ( typeof mSource === 'function' )
|
|
2755
|
-
{
|
|
2756
|
-
return function (data, val, meta) {
|
|
2757
|
-
mSource( data, 'set', val, meta );
|
|
2758
|
-
};
|
|
2759
|
-
}
|
|
2760
|
-
else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
|
|
2761
|
-
mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
|
|
2762
|
-
{
|
|
2763
|
-
/* Like the get, we need to get data from a nested object */
|
|
2764
|
-
var setData = function (data, val, src) {
|
|
2765
|
-
var a = _fnSplitObjNotation( src ), b;
|
|
2766
|
-
var aLast = a[a.length-1];
|
|
2767
|
-
var arrayNotation, funcNotation, o, innerSrc;
|
|
2768
|
-
|
|
2769
|
-
for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
|
|
2770
|
-
{
|
|
2771
|
-
// Protect against prototype pollution
|
|
2772
|
-
if (a[i] === '__proto__' || a[i] === 'constructor') {
|
|
2773
|
-
throw new Error('Cannot set prototype values');
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2776
|
-
// Check if we are dealing with an array notation request
|
|
2777
|
-
arrayNotation = a[i].match(__reArray);
|
|
2778
|
-
funcNotation = a[i].match(__reFn);
|
|
2779
|
-
|
|
2780
|
-
if ( arrayNotation )
|
|
2781
|
-
{
|
|
2782
|
-
a[i] = a[i].replace(__reArray, '');
|
|
2783
|
-
data[ a[i] ] = [];
|
|
2784
|
-
|
|
2785
|
-
// Get the remainder of the nested object to set so we can recurse
|
|
2786
|
-
b = a.slice();
|
|
2787
|
-
b.splice( 0, i+1 );
|
|
2788
|
-
innerSrc = b.join('.');
|
|
2789
|
-
|
|
2790
|
-
// Traverse each entry in the array setting the properties requested
|
|
2791
|
-
if ( Array.isArray( val ) )
|
|
2792
|
-
{
|
|
2793
|
-
for ( var j=0, jLen=val.length ; j<jLen ; j++ )
|
|
2794
|
-
{
|
|
2795
|
-
o = {};
|
|
2796
|
-
setData( o, val[j], innerSrc );
|
|
2797
|
-
data[ a[i] ].push( o );
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
else
|
|
2801
|
-
{
|
|
2802
|
-
// We've been asked to save data to an array, but it
|
|
2803
|
-
// isn't array data to be saved. Best that can be done
|
|
2804
|
-
// is to just save the value.
|
|
2805
|
-
data[ a[i] ] = val;
|
|
2806
|
-
}
|
|
2807
|
-
|
|
2808
|
-
// The inner call to setData has already traversed through the remainder
|
|
2809
|
-
// of the source and has set the data, thus we can exit here
|
|
2810
|
-
return;
|
|
2811
|
-
}
|
|
2812
|
-
else if ( funcNotation )
|
|
2813
|
-
{
|
|
2814
|
-
// Function call
|
|
2815
|
-
a[i] = a[i].replace(__reFn, '');
|
|
2816
|
-
data = data[ a[i] ]( val );
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
// If the nested object doesn't currently exist - since we are
|
|
2820
|
-
// trying to set the value - create it
|
|
2821
|
-
if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
|
|
2822
|
-
{
|
|
2823
|
-
data[ a[i] ] = {};
|
|
2824
|
-
}
|
|
2825
|
-
data = data[ a[i] ];
|
|
2826
|
-
}
|
|
2827
|
-
|
|
2828
|
-
// Last item in the input - i.e, the actual set
|
|
2829
|
-
if ( aLast.match(__reFn ) )
|
|
2830
|
-
{
|
|
2831
|
-
// Function call
|
|
2832
|
-
data = data[ aLast.replace(__reFn, '') ]( val );
|
|
2833
|
-
}
|
|
2834
|
-
else
|
|
2835
|
-
{
|
|
2836
|
-
// If array notation is used, we just want to strip it and use the property name
|
|
2837
|
-
// and assign the value. If it isn't used, then we get the result we want anyway
|
|
2838
|
-
data[ aLast.replace(__reArray, '') ] = val;
|
|
2839
|
-
}
|
|
2840
|
-
};
|
|
2841
|
-
|
|
2842
|
-
return function (data, val) { // meta is also passed in, but not used
|
|
2843
|
-
return setData( data, val, mSource );
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
else
|
|
2847
|
-
{
|
|
2848
|
-
/* Array or flat object mapping */
|
|
2849
|
-
return function (data, val) { // meta is also passed in, but not used
|
|
2850
|
-
data[mSource] = val;
|
|
2851
|
-
};
|
|
2852
|
-
}
|
|
2853
|
-
}
|
|
2886
|
+
var _fnSetObjectDataFn = DataTable.util.set;
|
|
2854
2887
|
|
|
2855
2888
|
|
|
2856
2889
|
/**
|
|
@@ -3279,9 +3312,6 @@
|
|
|
3279
3312
|
if ( createHeader ) {
|
|
3280
3313
|
_fnDetectHeader( oSettings.aoHeader, thead );
|
|
3281
3314
|
}
|
|
3282
|
-
|
|
3283
|
-
/* ARIA role for the rows */
|
|
3284
|
-
$(thead).children('tr').attr('role', 'row');
|
|
3285
3315
|
|
|
3286
3316
|
/* Deal with the footer - add classes if required */
|
|
3287
3317
|
$(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
|
|
@@ -3900,6 +3930,22 @@
|
|
|
3900
3930
|
var ajax = oSettings.ajax;
|
|
3901
3931
|
var instance = oSettings.oInstance;
|
|
3902
3932
|
var callback = function ( json ) {
|
|
3933
|
+
var status = oSettings.jqXhr
|
|
3934
|
+
? oSettings.jqXhr.status
|
|
3935
|
+
: null;
|
|
3936
|
+
|
|
3937
|
+
if ( json === null || (typeof status === 'number' && status == 204 ) ) {
|
|
3938
|
+
json = {};
|
|
3939
|
+
_fnAjaxDataSrc( oSettings, json, [] );
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
var error = json.error || json.sError;
|
|
3943
|
+
if ( error ) {
|
|
3944
|
+
_fnLog( oSettings, 0, error );
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
oSettings.json = json;
|
|
3948
|
+
|
|
3903
3949
|
_fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
|
|
3904
3950
|
fn( json );
|
|
3905
3951
|
};
|
|
@@ -3924,15 +3970,7 @@
|
|
|
3924
3970
|
|
|
3925
3971
|
var baseAjax = {
|
|
3926
3972
|
"data": data,
|
|
3927
|
-
"success":
|
|
3928
|
-
var error = json.error || json.sError;
|
|
3929
|
-
if ( error ) {
|
|
3930
|
-
_fnLog( oSettings, 0, error );
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
oSettings.json = json;
|
|
3934
|
-
callback( json );
|
|
3935
|
-
},
|
|
3973
|
+
"success": callback,
|
|
3936
3974
|
"dataType": "json",
|
|
3937
3975
|
"cache": false,
|
|
3938
3976
|
"type": oSettings.sServerMethod,
|
|
@@ -4154,6 +4192,11 @@
|
|
|
4154
4192
|
settings.iDraw = draw * 1;
|
|
4155
4193
|
}
|
|
4156
4194
|
|
|
4195
|
+
// No data in returned object, so rather than an array, we show an empty table
|
|
4196
|
+
if ( ! data ) {
|
|
4197
|
+
data = [];
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4157
4200
|
_fnClearTable( settings );
|
|
4158
4201
|
settings._iRecordsTotal = parseInt(recordsTotal, 10);
|
|
4159
4202
|
settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
|
|
@@ -4181,21 +4224,26 @@
|
|
|
4181
4224
|
* @param {object} json Data source object / array from the server
|
|
4182
4225
|
* @return {array} Array of data to use
|
|
4183
4226
|
*/
|
|
4184
|
-
|
|
4185
|
-
|
|
4227
|
+
function _fnAjaxDataSrc ( oSettings, json, write )
|
|
4228
|
+
{
|
|
4186
4229
|
var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
|
|
4187
4230
|
oSettings.ajax.dataSrc :
|
|
4188
4231
|
oSettings.sAjaxDataProp; // Compatibility with 1.9-.
|
|
4189
4232
|
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4233
|
+
if ( ! write ) {
|
|
4234
|
+
if ( dataSrc === 'data' ) {
|
|
4235
|
+
// If the default, then we still want to support the old style, and safely ignore
|
|
4236
|
+
// it if possible
|
|
4237
|
+
return json.aaData || json[dataSrc];
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
return dataSrc !== "" ?
|
|
4241
|
+
_fnGetObjectDataFn( dataSrc )( json ) :
|
|
4242
|
+
json;
|
|
4194
4243
|
}
|
|
4195
4244
|
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
json;
|
|
4245
|
+
// set
|
|
4246
|
+
_fnSetObjectDataFn( dataSrc )( json, write );
|
|
4199
4247
|
}
|
|
4200
4248
|
|
|
4201
4249
|
/**
|
|
@@ -4224,18 +4272,21 @@
|
|
|
4224
4272
|
} )
|
|
4225
4273
|
.append( $('<label/>' ).append( str ) );
|
|
4226
4274
|
|
|
4227
|
-
var searchFn = function() {
|
|
4275
|
+
var searchFn = function(event) {
|
|
4228
4276
|
/* Update all other filter input elements for the new display */
|
|
4229
4277
|
var n = features.f;
|
|
4230
4278
|
var val = !this.value ? "" : this.value; // mental IE8 fix :-(
|
|
4231
|
-
|
|
4279
|
+
if(previousSearch.return && event.key !== "Enter") {
|
|
4280
|
+
return;
|
|
4281
|
+
}
|
|
4232
4282
|
/* Now do the filter */
|
|
4233
4283
|
if ( val != previousSearch.sSearch ) {
|
|
4234
4284
|
_fnFilterComplete( settings, {
|
|
4235
4285
|
"sSearch": val,
|
|
4236
4286
|
"bRegex": previousSearch.bRegex,
|
|
4237
4287
|
"bSmart": previousSearch.bSmart ,
|
|
4238
|
-
"bCaseInsensitive": previousSearch.bCaseInsensitive
|
|
4288
|
+
"bCaseInsensitive": previousSearch.bCaseInsensitive,
|
|
4289
|
+
"return": previousSearch.return
|
|
4239
4290
|
} );
|
|
4240
4291
|
|
|
4241
4292
|
// Need to redraw, without resorting
|
|
@@ -4264,7 +4315,7 @@
|
|
|
4264
4315
|
// on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
|
|
4265
4316
|
// checks the value to see if it has changed. In other browsers it won't have.
|
|
4266
4317
|
setTimeout( function () {
|
|
4267
|
-
searchFn.call(jqFilter[0]);
|
|
4318
|
+
searchFn.call(jqFilter[0], e);
|
|
4268
4319
|
}, 10);
|
|
4269
4320
|
} )
|
|
4270
4321
|
.on( 'keypress.DT', function(e) {
|
|
@@ -4310,6 +4361,7 @@
|
|
|
4310
4361
|
oPrevSearch.bRegex = oFilter.bRegex;
|
|
4311
4362
|
oPrevSearch.bSmart = oFilter.bSmart;
|
|
4312
4363
|
oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
|
|
4364
|
+
oPrevSearch.return = oFilter.return;
|
|
4313
4365
|
};
|
|
4314
4366
|
var fnRegex = function ( o ) {
|
|
4315
4367
|
// Backwards compatibility with the bEscapeRegex option
|
|
@@ -4324,7 +4376,7 @@
|
|
|
4324
4376
|
if ( _fnDataSource( oSettings ) != 'ssp' )
|
|
4325
4377
|
{
|
|
4326
4378
|
/* Global filter */
|
|
4327
|
-
_fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
|
|
4379
|
+
_fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive, oInput.return );
|
|
4328
4380
|
fnSaveFilter( oInput );
|
|
4329
4381
|
|
|
4330
4382
|
/* Now do the individual column filter */
|
|
@@ -4387,7 +4439,7 @@
|
|
|
4387
4439
|
* @param {int} iColumn column to filter
|
|
4388
4440
|
* @param {bool} bRegex treat search string as a regular expression or not
|
|
4389
4441
|
* @param {bool} bSmart use smart filtering or not
|
|
4390
|
-
* @param {bool} bCaseInsensitive Do case
|
|
4442
|
+
* @param {bool} bCaseInsensitive Do case insensitive matching or not
|
|
4391
4443
|
* @memberof DataTable#oApi
|
|
4392
4444
|
*/
|
|
4393
4445
|
function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
|
|
@@ -4420,7 +4472,7 @@
|
|
|
4420
4472
|
* @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
|
|
4421
4473
|
* @param {bool} regex treat as a regular expression or not
|
|
4422
4474
|
* @param {bool} smart perform smart filtering or not
|
|
4423
|
-
* @param {bool} caseInsensitive Do case
|
|
4475
|
+
* @param {bool} caseInsensitive Do case insensitive matching or not
|
|
4424
4476
|
* @memberof DataTable#oApi
|
|
4425
4477
|
*/
|
|
4426
4478
|
function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
|
|
@@ -4526,7 +4578,6 @@
|
|
|
4526
4578
|
var columns = settings.aoColumns;
|
|
4527
4579
|
var column;
|
|
4528
4580
|
var i, j, ien, jen, filterData, cellData, row;
|
|
4529
|
-
var fomatters = DataTable.ext.type.search;
|
|
4530
4581
|
var wasInvalidated = false;
|
|
4531
4582
|
|
|
4532
4583
|
for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
|
@@ -4541,10 +4592,6 @@
|
|
|
4541
4592
|
if ( column.bSearchable ) {
|
|
4542
4593
|
cellData = _fnGetCellData( settings, i, j, 'filter' );
|
|
4543
4594
|
|
|
4544
|
-
if ( fomatters[ column.sType ] ) {
|
|
4545
|
-
cellData = fomatters[ column.sType ]( cellData );
|
|
4546
|
-
}
|
|
4547
|
-
|
|
4548
4595
|
// Search in DataTables 1.10 is string based. In 1.11 this
|
|
4549
4596
|
// should be altered to also allow strict type checking.
|
|
4550
4597
|
if ( cellData === null ) {
|
|
@@ -5081,9 +5128,6 @@
|
|
|
5081
5128
|
{
|
|
5082
5129
|
var table = $(settings.nTable);
|
|
5083
5130
|
|
|
5084
|
-
// Add the ARIA grid role to the table
|
|
5085
|
-
table.attr( 'role', 'grid' );
|
|
5086
|
-
|
|
5087
5131
|
// Scrolling from here on in
|
|
5088
5132
|
var scroll = settings.oScroll;
|
|
5089
5133
|
|
|
@@ -5371,17 +5415,17 @@
|
|
|
5371
5415
|
|
|
5372
5416
|
// Read all widths in next pass
|
|
5373
5417
|
_fnApplyToChildren( function(nSizer) {
|
|
5418
|
+
var style = window.getComputedStyle ?
|
|
5419
|
+
window.getComputedStyle(nSizer).width :
|
|
5420
|
+
_fnStringToCss( $(nSizer).width() );
|
|
5421
|
+
|
|
5374
5422
|
headerContent.push( nSizer.innerHTML );
|
|
5375
|
-
headerWidths.push(
|
|
5423
|
+
headerWidths.push( style );
|
|
5376
5424
|
}, headerSrcEls );
|
|
5377
5425
|
|
|
5378
5426
|
// Apply all widths in final pass
|
|
5379
5427
|
_fnApplyToChildren( function(nToSize, i) {
|
|
5380
|
-
|
|
5381
|
-
// prevents complex headers from having contradictory sizes applied
|
|
5382
|
-
if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
|
|
5383
|
-
nToSize.style.width = headerWidths[i];
|
|
5384
|
-
}
|
|
5428
|
+
nToSize.style.width = headerWidths[i];
|
|
5385
5429
|
}, headerTrgEls );
|
|
5386
5430
|
|
|
5387
5431
|
$(headerSrcEls).height(0);
|
|
@@ -6338,8 +6382,7 @@
|
|
|
6338
6382
|
*/
|
|
6339
6383
|
function _fnSaveState ( settings )
|
|
6340
6384
|
{
|
|
6341
|
-
if (
|
|
6342
|
-
{
|
|
6385
|
+
if (settings._bLoadingState) {
|
|
6343
6386
|
return;
|
|
6344
6387
|
}
|
|
6345
6388
|
|
|
@@ -6358,10 +6401,13 @@
|
|
|
6358
6401
|
} )
|
|
6359
6402
|
};
|
|
6360
6403
|
|
|
6361
|
-
_fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
|
|
6362
|
-
|
|
6363
6404
|
settings.oSavedState = state;
|
|
6364
|
-
|
|
6405
|
+
_fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
|
|
6406
|
+
|
|
6407
|
+
if ( settings.oFeatures.bStateSave && !settings.bDestroying )
|
|
6408
|
+
{
|
|
6409
|
+
settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
|
|
6410
|
+
}
|
|
6365
6411
|
}
|
|
6366
6412
|
|
|
6367
6413
|
|
|
@@ -6374,98 +6420,128 @@
|
|
|
6374
6420
|
*/
|
|
6375
6421
|
function _fnLoadState ( settings, oInit, callback )
|
|
6376
6422
|
{
|
|
6423
|
+
if ( ! settings.oFeatures.bStateSave ) {
|
|
6424
|
+
callback();
|
|
6425
|
+
return;
|
|
6426
|
+
}
|
|
6427
|
+
|
|
6428
|
+
var loaded = function(state) {
|
|
6429
|
+
_fnImplementState(settings, state, callback);
|
|
6430
|
+
}
|
|
6431
|
+
|
|
6432
|
+
var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
|
|
6433
|
+
|
|
6434
|
+
if ( state !== undefined ) {
|
|
6435
|
+
_fnImplementState( settings, state, callback );
|
|
6436
|
+
}
|
|
6437
|
+
// otherwise, wait for the loaded callback to be executed
|
|
6438
|
+
|
|
6439
|
+
return true;
|
|
6440
|
+
}
|
|
6441
|
+
|
|
6442
|
+
function _fnImplementState ( settings, s, callback) {
|
|
6377
6443
|
var i, ien;
|
|
6378
6444
|
var columns = settings.aoColumns;
|
|
6379
|
-
|
|
6380
|
-
if ( ! s || ! s.time ) {
|
|
6381
|
-
callback();
|
|
6382
|
-
return;
|
|
6383
|
-
}
|
|
6445
|
+
settings._bLoadingState = true;
|
|
6384
6446
|
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
if ( $.inArray( false, abStateLoad ) !== -1 ) {
|
|
6389
|
-
callback();
|
|
6390
|
-
return;
|
|
6391
|
-
}
|
|
6447
|
+
// When StateRestore was introduced the state could now be implemented at any time
|
|
6448
|
+
// Not just initialisation. To do this an api instance is required in some places
|
|
6449
|
+
var api = settings._bInitComplete ? new DataTable.Api(settings) : null;
|
|
6392
6450
|
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
}
|
|
6451
|
+
if ( ! s || ! s.time ) {
|
|
6452
|
+
settings._bLoadingState = false;
|
|
6453
|
+
callback();
|
|
6454
|
+
return;
|
|
6455
|
+
}
|
|
6399
6456
|
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6457
|
+
// Allow custom and plug-in manipulation functions to alter the saved data set and
|
|
6458
|
+
// cancelling of loading by returning false
|
|
6459
|
+
var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
|
|
6460
|
+
if ( $.inArray( false, abStateLoad ) !== -1 ) {
|
|
6461
|
+
settings._bLoadingState = false;
|
|
6462
|
+
callback();
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
6405
6465
|
|
|
6406
|
-
|
|
6407
|
-
|
|
6466
|
+
// Reject old data
|
|
6467
|
+
var duration = settings.iStateDuration;
|
|
6468
|
+
if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
|
|
6469
|
+
settings._bLoadingState = false;
|
|
6470
|
+
callback();
|
|
6471
|
+
return;
|
|
6472
|
+
}
|
|
6408
6473
|
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6474
|
+
// Number of columns have changed - all bets are off, no restore of settings
|
|
6475
|
+
if ( s.columns && columns.length !== s.columns.length ) {
|
|
6476
|
+
settings._bLoadingState = false;
|
|
6477
|
+
callback();
|
|
6478
|
+
return;
|
|
6479
|
+
}
|
|
6480
|
+
|
|
6481
|
+
// Store the saved state so it might be accessed at any time
|
|
6482
|
+
settings.oLoadedState = $.extend( true, {}, s );
|
|
6483
|
+
|
|
6484
|
+
// Restore key features - todo - for 1.11 this needs to be done by
|
|
6485
|
+
// subscribed events
|
|
6486
|
+
if ( s.start !== undefined ) {
|
|
6487
|
+
settings._iDisplayStart = s.start;
|
|
6488
|
+
if(api === null) {
|
|
6413
6489
|
settings.iInitDisplayStart = s.start;
|
|
6414
6490
|
}
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6491
|
+
}
|
|
6492
|
+
if ( s.length !== undefined ) {
|
|
6493
|
+
settings._iDisplayLength = s.length;
|
|
6494
|
+
}
|
|
6418
6495
|
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6496
|
+
// Order
|
|
6497
|
+
if ( s.order !== undefined ) {
|
|
6498
|
+
settings.aaSorting = [];
|
|
6499
|
+
$.each( s.order, function ( i, col ) {
|
|
6500
|
+
settings.aaSorting.push( col[0] >= columns.length ?
|
|
6501
|
+
[ 0, col[1] ] :
|
|
6502
|
+
col
|
|
6503
|
+
);
|
|
6504
|
+
} );
|
|
6505
|
+
}
|
|
6429
6506
|
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6507
|
+
// Search
|
|
6508
|
+
if ( s.search !== undefined ) {
|
|
6509
|
+
$.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
|
|
6510
|
+
}
|
|
6434
6511
|
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
var col = s.columns[i];
|
|
6512
|
+
// Columns
|
|
6513
|
+
if ( s.columns ) {
|
|
6514
|
+
for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
|
|
6515
|
+
var col = s.columns[i];
|
|
6440
6516
|
|
|
6441
|
-
|
|
6442
|
-
|
|
6517
|
+
// Visibility
|
|
6518
|
+
if ( col.visible !== undefined ) {
|
|
6519
|
+
// If the api is defined, the table has been initialised so we need to use it rather than internal settings
|
|
6520
|
+
if (api) {
|
|
6521
|
+
// Don't redraw the columns on every iteration of this loop, we will do this at the end instead
|
|
6522
|
+
api.column(i).visible(col.visible, false);
|
|
6523
|
+
}
|
|
6524
|
+
else {
|
|
6443
6525
|
columns[i].bVisible = col.visible;
|
|
6444
6526
|
}
|
|
6527
|
+
}
|
|
6445
6528
|
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
}
|
|
6529
|
+
// Search
|
|
6530
|
+
if ( col.search !== undefined ) {
|
|
6531
|
+
$.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
|
|
6450
6532
|
}
|
|
6451
6533
|
}
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
if ( ! settings.oFeatures.bStateSave ) {
|
|
6458
|
-
callback();
|
|
6459
|
-
return;
|
|
6534
|
+
|
|
6535
|
+
// If the api is defined then we need to adjust the columns once the visibility has been changed
|
|
6536
|
+
if (api) {
|
|
6537
|
+
api.columns.adjust();
|
|
6538
|
+
}
|
|
6460
6539
|
}
|
|
6461
6540
|
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
}
|
|
6467
|
-
// otherwise, wait for the loaded callback to be executed
|
|
6468
|
-
}
|
|
6541
|
+
settings._bLoadingState = false;
|
|
6542
|
+
_fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
|
|
6543
|
+
callback();
|
|
6544
|
+
};
|
|
6469
6545
|
|
|
6470
6546
|
|
|
6471
6547
|
/**
|
|
@@ -7860,7 +7936,7 @@
|
|
|
7860
7936
|
_range( 0, displayMaster.length );
|
|
7861
7937
|
}
|
|
7862
7938
|
else if ( page == 'current' ) {
|
|
7863
|
-
// Current page implies that order=current and
|
|
7939
|
+
// Current page implies that order=current and filter=applied, since it is
|
|
7864
7940
|
// fairly senseless otherwise, regardless of what order and search actually
|
|
7865
7941
|
// are
|
|
7866
7942
|
for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
|
|
@@ -8241,6 +8317,24 @@
|
|
|
8241
8317
|
} );
|
|
8242
8318
|
|
|
8243
8319
|
|
|
8320
|
+
$(document).on('plugin-init.dt', function (e, context) {
|
|
8321
|
+
var api = new _Api( context );
|
|
8322
|
+
api.on( 'stateSaveParams', function ( e, settings, data ) {
|
|
8323
|
+
var indexes = api.rows().iterator( 'row', function ( settings, idx ) {
|
|
8324
|
+
return settings.aoData[idx]._detailsShow ? idx : undefined;
|
|
8325
|
+
});
|
|
8326
|
+
|
|
8327
|
+
data.childRows = api.rows( indexes ).ids( true ).toArray();
|
|
8328
|
+
})
|
|
8329
|
+
|
|
8330
|
+
var loaded = api.state.loaded();
|
|
8331
|
+
|
|
8332
|
+
if ( loaded && loaded.childRows ) {
|
|
8333
|
+
api.rows( loaded.childRows ).every( function () {
|
|
8334
|
+
_fnCallbackFire( context, null, 'requestChild', [ this ] )
|
|
8335
|
+
})
|
|
8336
|
+
}
|
|
8337
|
+
})
|
|
8244
8338
|
|
|
8245
8339
|
var __details_add = function ( ctx, row, data, klass )
|
|
8246
8340
|
{
|
|
@@ -8299,6 +8393,8 @@
|
|
|
8299
8393
|
|
|
8300
8394
|
row._detailsShow = undefined;
|
|
8301
8395
|
row._details = undefined;
|
|
8396
|
+
$( row.nTr ).removeClass( 'dt-hasChild' );
|
|
8397
|
+
_fnSaveState( ctx[0] );
|
|
8302
8398
|
}
|
|
8303
8399
|
}
|
|
8304
8400
|
};
|
|
@@ -8315,12 +8411,17 @@
|
|
|
8315
8411
|
|
|
8316
8412
|
if ( show ) {
|
|
8317
8413
|
row._details.insertAfter( row.nTr );
|
|
8414
|
+
$( row.nTr ).addClass( 'dt-hasChild' );
|
|
8318
8415
|
}
|
|
8319
8416
|
else {
|
|
8320
8417
|
row._details.detach();
|
|
8418
|
+
$( row.nTr ).removeClass( 'dt-hasChild' );
|
|
8321
8419
|
}
|
|
8322
8420
|
|
|
8421
|
+
_fnCallbackFire( ctx[0], null, 'childRow', [ show, api.row( api[0] ) ] )
|
|
8422
|
+
|
|
8323
8423
|
__details_events( ctx[0] );
|
|
8424
|
+
_fnSaveState( ctx[0] );
|
|
8324
8425
|
}
|
|
8325
8426
|
}
|
|
8326
8427
|
};
|
|
@@ -9531,7 +9632,7 @@
|
|
|
9531
9632
|
* @type string
|
|
9532
9633
|
* @default Version number
|
|
9533
9634
|
*/
|
|
9534
|
-
DataTable.version = "1.
|
|
9635
|
+
DataTable.version = "1.11.3";
|
|
9535
9636
|
|
|
9536
9637
|
/**
|
|
9537
9638
|
* Private data store, containing all of the settings objects that are
|
|
@@ -9591,7 +9692,15 @@
|
|
|
9591
9692
|
* @type boolean
|
|
9592
9693
|
* @default true
|
|
9593
9694
|
*/
|
|
9594
|
-
"bSmart": true
|
|
9695
|
+
"bSmart": true,
|
|
9696
|
+
|
|
9697
|
+
/**
|
|
9698
|
+
* Flag to indicate if DataTables should only trigger a search when
|
|
9699
|
+
* the return key is pressed.
|
|
9700
|
+
* @type boolean
|
|
9701
|
+
* @default false
|
|
9702
|
+
*/
|
|
9703
|
+
"return": false
|
|
9595
9704
|
};
|
|
9596
9705
|
|
|
9597
9706
|
|
|
@@ -12487,7 +12596,7 @@
|
|
|
12487
12596
|
* "data": function ( source, type, val ) {
|
|
12488
12597
|
* if (type === 'set') {
|
|
12489
12598
|
* source.price = val;
|
|
12490
|
-
* // Store the computed
|
|
12599
|
+
* // Store the computed display and filter values for efficiency
|
|
12491
12600
|
* source.price_display = val=="" ? "" : "$"+numberFormat(val);
|
|
12492
12601
|
* source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
|
|
12493
12602
|
* return;
|
|
@@ -13036,7 +13145,7 @@
|
|
|
13036
13145
|
* Delay the creation of TR and TD elements until they are actually
|
|
13037
13146
|
* needed by a driven page draw. This can give a significant speed
|
|
13038
13147
|
* increase for Ajax source and Javascript source data, but makes no
|
|
13039
|
-
* difference at all
|
|
13148
|
+
* difference at all for DOM and server-side processing tables.
|
|
13040
13149
|
* Note that this parameter will be set by the initialisation routine. To
|
|
13041
13150
|
* set a default use {@link DataTable.defaults}.
|
|
13042
13151
|
* @type boolean
|
|
@@ -14394,7 +14503,7 @@
|
|
|
14394
14503
|
|
|
14395
14504
|
//
|
|
14396
14505
|
// Depreciated
|
|
14397
|
-
// The following properties are retained for backwards
|
|
14506
|
+
// The following properties are retained for backwards compatibility only.
|
|
14398
14507
|
// The should not be used in new projects and will be removed in a future
|
|
14399
14508
|
// version
|
|
14400
14509
|
//
|
|
@@ -14981,6 +15090,10 @@
|
|
|
14981
15090
|
*/
|
|
14982
15091
|
|
|
14983
15092
|
var __htmlEscapeEntities = function ( d ) {
|
|
15093
|
+
if (Array.isArray(d)) {
|
|
15094
|
+
d = d.join(',');
|
|
15095
|
+
}
|
|
15096
|
+
|
|
14984
15097
|
return typeof d === 'string' ?
|
|
14985
15098
|
d
|
|
14986
15099
|
.replace(/&/g, '&')
|
|
@@ -15175,6 +15288,7 @@
|
|
|
15175
15288
|
_fnSortData: _fnSortData,
|
|
15176
15289
|
_fnSaveState: _fnSaveState,
|
|
15177
15290
|
_fnLoadState: _fnLoadState,
|
|
15291
|
+
_fnImplementState: _fnImplementState,
|
|
15178
15292
|
_fnSettingsFromNode: _fnSettingsFromNode,
|
|
15179
15293
|
_fnLog: _fnLog,
|
|
15180
15294
|
_fnMap: _fnMap,
|
|
@@ -15214,168 +15328,5 @@
|
|
|
15214
15328
|
$.fn.DataTable[ prop ] = val;
|
|
15215
15329
|
} );
|
|
15216
15330
|
|
|
15217
|
-
|
|
15218
|
-
// Information about events fired by DataTables - for documentation.
|
|
15219
|
-
/**
|
|
15220
|
-
* Draw event, fired whenever the table is redrawn on the page, at the same
|
|
15221
|
-
* point as fnDrawCallback. This may be useful for binding events or
|
|
15222
|
-
* performing calculations when the table is altered at all.
|
|
15223
|
-
* @name DataTable#draw.dt
|
|
15224
|
-
* @event
|
|
15225
|
-
* @param {event} e jQuery event object
|
|
15226
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15227
|
-
*/
|
|
15228
|
-
|
|
15229
|
-
/**
|
|
15230
|
-
* Search event, fired when the searching applied to the table (using the
|
|
15231
|
-
* built-in global search, or column filters) is altered.
|
|
15232
|
-
* @name DataTable#search.dt
|
|
15233
|
-
* @event
|
|
15234
|
-
* @param {event} e jQuery event object
|
|
15235
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15236
|
-
*/
|
|
15237
|
-
|
|
15238
|
-
/**
|
|
15239
|
-
* Page change event, fired when the paging of the table is altered.
|
|
15240
|
-
* @name DataTable#page.dt
|
|
15241
|
-
* @event
|
|
15242
|
-
* @param {event} e jQuery event object
|
|
15243
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15244
|
-
*/
|
|
15245
|
-
|
|
15246
|
-
/**
|
|
15247
|
-
* Order event, fired when the ordering applied to the table is altered.
|
|
15248
|
-
* @name DataTable#order.dt
|
|
15249
|
-
* @event
|
|
15250
|
-
* @param {event} e jQuery event object
|
|
15251
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15252
|
-
*/
|
|
15253
|
-
|
|
15254
|
-
/**
|
|
15255
|
-
* DataTables initialisation complete event, fired when the table is fully
|
|
15256
|
-
* drawn, including Ajax data loaded, if Ajax data is required.
|
|
15257
|
-
* @name DataTable#init.dt
|
|
15258
|
-
* @event
|
|
15259
|
-
* @param {event} e jQuery event object
|
|
15260
|
-
* @param {object} oSettings DataTables settings object
|
|
15261
|
-
* @param {object} json The JSON object request from the server - only
|
|
15262
|
-
* present if client-side Ajax sourced data is used</li></ol>
|
|
15263
|
-
*/
|
|
15264
|
-
|
|
15265
|
-
/**
|
|
15266
|
-
* State save event, fired when the table has changed state a new state save
|
|
15267
|
-
* is required. This event allows modification of the state saving object
|
|
15268
|
-
* prior to actually doing the save, including addition or other state
|
|
15269
|
-
* properties (for plug-ins) or modification of a DataTables core property.
|
|
15270
|
-
* @name DataTable#stateSaveParams.dt
|
|
15271
|
-
* @event
|
|
15272
|
-
* @param {event} e jQuery event object
|
|
15273
|
-
* @param {object} oSettings DataTables settings object
|
|
15274
|
-
* @param {object} json The state information to be saved
|
|
15275
|
-
*/
|
|
15276
|
-
|
|
15277
|
-
/**
|
|
15278
|
-
* State load event, fired when the table is loading state from the stored
|
|
15279
|
-
* data, but prior to the settings object being modified by the saved state
|
|
15280
|
-
* - allowing modification of the saved state is required or loading of
|
|
15281
|
-
* state for a plug-in.
|
|
15282
|
-
* @name DataTable#stateLoadParams.dt
|
|
15283
|
-
* @event
|
|
15284
|
-
* @param {event} e jQuery event object
|
|
15285
|
-
* @param {object} oSettings DataTables settings object
|
|
15286
|
-
* @param {object} json The saved state information
|
|
15287
|
-
*/
|
|
15288
|
-
|
|
15289
|
-
/**
|
|
15290
|
-
* State loaded event, fired when state has been loaded from stored data and
|
|
15291
|
-
* the settings object has been modified by the loaded data.
|
|
15292
|
-
* @name DataTable#stateLoaded.dt
|
|
15293
|
-
* @event
|
|
15294
|
-
* @param {event} e jQuery event object
|
|
15295
|
-
* @param {object} oSettings DataTables settings object
|
|
15296
|
-
* @param {object} json The saved state information
|
|
15297
|
-
*/
|
|
15298
|
-
|
|
15299
|
-
/**
|
|
15300
|
-
* Processing event, fired when DataTables is doing some kind of processing
|
|
15301
|
-
* (be it, order, search or anything else). It can be used to indicate to
|
|
15302
|
-
* the end user that there is something happening, or that something has
|
|
15303
|
-
* finished.
|
|
15304
|
-
* @name DataTable#processing.dt
|
|
15305
|
-
* @event
|
|
15306
|
-
* @param {event} e jQuery event object
|
|
15307
|
-
* @param {object} oSettings DataTables settings object
|
|
15308
|
-
* @param {boolean} bShow Flag for if DataTables is doing processing or not
|
|
15309
|
-
*/
|
|
15310
|
-
|
|
15311
|
-
/**
|
|
15312
|
-
* Ajax (XHR) event, fired whenever an Ajax request is completed from a
|
|
15313
|
-
* request to made to the server for new data. This event is called before
|
|
15314
|
-
* DataTables processed the returned data, so it can also be used to pre-
|
|
15315
|
-
* process the data returned from the server, if needed.
|
|
15316
|
-
*
|
|
15317
|
-
* Note that this trigger is called in `fnServerData`, if you override
|
|
15318
|
-
* `fnServerData` and which to use this event, you need to trigger it in you
|
|
15319
|
-
* success function.
|
|
15320
|
-
* @name DataTable#xhr.dt
|
|
15321
|
-
* @event
|
|
15322
|
-
* @param {event} e jQuery event object
|
|
15323
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15324
|
-
* @param {object} json JSON returned from the server
|
|
15325
|
-
*
|
|
15326
|
-
* @example
|
|
15327
|
-
* // Use a custom property returned from the server in another DOM element
|
|
15328
|
-
* $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
|
|
15329
|
-
* $('#status').html( json.status );
|
|
15330
|
-
* } );
|
|
15331
|
-
*
|
|
15332
|
-
* @example
|
|
15333
|
-
* // Pre-process the data returned from the server
|
|
15334
|
-
* $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
|
|
15335
|
-
* for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
|
|
15336
|
-
* json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
|
|
15337
|
-
* }
|
|
15338
|
-
* // Note no return - manipulate the data directly in the JSON object.
|
|
15339
|
-
* } );
|
|
15340
|
-
*/
|
|
15341
|
-
|
|
15342
|
-
/**
|
|
15343
|
-
* Destroy event, fired when the DataTable is destroyed by calling fnDestroy
|
|
15344
|
-
* or passing the bDestroy:true parameter in the initialisation object. This
|
|
15345
|
-
* can be used to remove bound events, added DOM nodes, etc.
|
|
15346
|
-
* @name DataTable#destroy.dt
|
|
15347
|
-
* @event
|
|
15348
|
-
* @param {event} e jQuery event object
|
|
15349
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15350
|
-
*/
|
|
15351
|
-
|
|
15352
|
-
/**
|
|
15353
|
-
* Page length change event, fired when number of records to show on each
|
|
15354
|
-
* page (the length) is changed.
|
|
15355
|
-
* @name DataTable#length.dt
|
|
15356
|
-
* @event
|
|
15357
|
-
* @param {event} e jQuery event object
|
|
15358
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15359
|
-
* @param {integer} len New length
|
|
15360
|
-
*/
|
|
15361
|
-
|
|
15362
|
-
/**
|
|
15363
|
-
* Column sizing has changed.
|
|
15364
|
-
* @name DataTable#column-sizing.dt
|
|
15365
|
-
* @event
|
|
15366
|
-
* @param {event} e jQuery event object
|
|
15367
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15368
|
-
*/
|
|
15369
|
-
|
|
15370
|
-
/**
|
|
15371
|
-
* Column visibility has changed.
|
|
15372
|
-
* @name DataTable#column-visibility.dt
|
|
15373
|
-
* @event
|
|
15374
|
-
* @param {event} e jQuery event object
|
|
15375
|
-
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
|
|
15376
|
-
* @param {int} column Column index
|
|
15377
|
-
* @param {bool} vis `false` if column now hidden, or `true` if visible
|
|
15378
|
-
*/
|
|
15379
|
-
|
|
15380
|
-
return $.fn.dataTable;
|
|
15331
|
+
return DataTable;
|
|
15381
15332
|
}));
|