datatables.net 1.13.6 → 1.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! DataTables 1.13.5
1
+ /*! DataTables 1.13.7
2
2
  * ©2008-2023 SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -1288,7 +1288,7 @@ var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}(
1288
1288
  // Escape regular expression special characters
1289
1289
  var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
1290
1290
 
1291
- // http://en.wikipedia.org/wiki/Foreign_exchange_market
1291
+ // https://en.wikipedia.org/wiki/Foreign_exchange_market
1292
1292
  // - \u20BD - Russian ruble.
1293
1293
  // - \u20a9 - South Korean Won
1294
1294
  // - \u20BA - Turkish Lira
@@ -2287,6 +2287,12 @@ function _fnColumnOptions( oSettings, iCol, oOptions )
2287
2287
  oCol.aDataSort = [ oOptions.iDataSort ];
2288
2288
  }
2289
2289
  _fnMap( oCol, oOptions, "aDataSort" );
2290
+
2291
+ // Fall back to the aria-label attribute on the table header if no ariaTitle is
2292
+ // provided.
2293
+ if (! oCol.ariaTitle) {
2294
+ oCol.ariaTitle = th.attr("aria-label");
2295
+ }
2290
2296
  }
2291
2297
 
2292
2298
  /* Cache the data get and set functions for speed */
@@ -4250,7 +4256,7 @@ function _fnFeatureHtmlFilter ( settings )
4250
4256
  /* Update all other filter input elements for the new display */
4251
4257
  var n = features.f;
4252
4258
  var val = !this.value ? "" : this.value; // mental IE8 fix :-(
4253
- if(previousSearch.return && event.key !== "Enter") {
4259
+ if(previousSearch['return'] && event.key !== "Enter") {
4254
4260
  return;
4255
4261
  }
4256
4262
  /* Now do the filter */
@@ -4260,7 +4266,7 @@ function _fnFeatureHtmlFilter ( settings )
4260
4266
  "bRegex": previousSearch.bRegex,
4261
4267
  "bSmart": previousSearch.bSmart ,
4262
4268
  "bCaseInsensitive": previousSearch.bCaseInsensitive,
4263
- "return": previousSearch.return
4269
+ "return": previousSearch['return']
4264
4270
  } );
4265
4271
 
4266
4272
  // Need to redraw, without resorting
@@ -4335,7 +4341,7 @@ function _fnFilterComplete ( oSettings, oInput, iForce )
4335
4341
  oPrevSearch.bRegex = oFilter.bRegex;
4336
4342
  oPrevSearch.bSmart = oFilter.bSmart;
4337
4343
  oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
4338
- oPrevSearch.return = oFilter.return;
4344
+ oPrevSearch['return'] = oFilter['return'];
4339
4345
  };
4340
4346
  var fnRegex = function ( o ) {
4341
4347
  // Backwards compatibility with the bEscapeRegex option
@@ -4587,7 +4593,7 @@ function _fnFilterData ( settings )
4587
4593
  // If it looks like there is an HTML entity in the string,
4588
4594
  // attempt to decode it so sorting works as expected. Note that
4589
4595
  // we could use a single line of jQuery to do this, but the DOM
4590
- // method used here is much faster http://jsperf.com/html-decode
4596
+ // method used here is much faster https://jsperf.com/html-decode
4591
4597
  if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
4592
4598
  __filter_div.innerHTML = cellData;
4593
4599
  cellData = __filter_div_textContent ?
@@ -5612,11 +5618,13 @@ function _fnCalculateColumnWidths ( oSettings )
5612
5618
  }
5613
5619
 
5614
5620
  /* Convert any user input sizes into pixel sizes */
5621
+ var sizes = _fnConvertToWidth(_pluck(columns, 'sWidthOrig'), tableContainer);
5622
+
5615
5623
  for ( i=0 ; i<visibleColumns.length ; i++ ) {
5616
5624
  column = columns[ visibleColumns[i] ];
5617
5625
 
5618
5626
  if ( column.sWidth !== null ) {
5619
- column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
5627
+ column.sWidth = sizes[i];
5620
5628
 
5621
5629
  userInputs = true;
5622
5630
  }
@@ -5819,26 +5827,40 @@ var _fnThrottle = DataTable.util.throttle;
5819
5827
 
5820
5828
 
5821
5829
  /**
5822
- * Convert a CSS unit width to pixels (e.g. 2em)
5823
- * @param {string} width width to be converted
5830
+ * Convert a set of CSS units width to pixels (e.g. 2em)
5831
+ * @param {string[]} widths widths to be converted
5824
5832
  * @param {node} parent parent to get the with for (required for relative widths) - optional
5825
- * @returns {int} width in pixels
5833
+ * @returns {int[]} widths in pixels
5826
5834
  * @memberof DataTable#oApi
5827
5835
  */
5828
- function _fnConvertToWidth ( width, parent )
5836
+ function _fnConvertToWidth ( widths, parent )
5829
5837
  {
5830
- if ( ! width ) {
5831
- return 0;
5838
+ var els = [];
5839
+ var results = [];
5840
+
5841
+ // Add the elements in a single loop so we only need to reflow once
5842
+ for (var i=0 ; i<widths.length ; i++) {
5843
+ if (widths[i]) {
5844
+ els.push(
5845
+ $('<div/>')
5846
+ .css( 'width', _fnStringToCss( widths[i] ) )
5847
+ .appendTo( parent || document.body )
5848
+ )
5849
+ }
5850
+ else {
5851
+ els.push(null);
5852
+ }
5832
5853
  }
5833
5854
 
5834
- var n = $('<div/>')
5835
- .css( 'width', _fnStringToCss( width ) )
5836
- .appendTo( parent || document.body );
5855
+ // Get the sizes (will reflow once)
5856
+ for (var i=0 ; i<widths.length ; i++) {
5857
+ results.push(els[i] ? els[i][0].offsetWidth : null);
5858
+ }
5837
5859
 
5838
- var val = n[0].offsetWidth;
5839
- n.remove();
5860
+ // Tidy
5861
+ $(els).remove();
5840
5862
 
5841
- return val;
5863
+ return results;
5842
5864
  }
5843
5865
 
5844
5866
 
@@ -6573,7 +6595,7 @@ function _fnLog( settings, level, msg, tn )
6573
6595
 
6574
6596
  if ( tn ) {
6575
6597
  msg += '. For more information about this error, please see '+
6576
- 'http://datatables.net/tn/'+tn;
6598
+ 'https://datatables.net/tn/'+tn;
6577
6599
  }
6578
6600
 
6579
6601
  if ( ! level ) {
@@ -8504,7 +8526,13 @@ var __details_events = function ( settings )
8504
8526
  row = data[i];
8505
8527
 
8506
8528
  if ( row._details ) {
8507
- row._details.children('td[colspan]').attr('colspan', visible );
8529
+ row._details.each(function () {
8530
+ var el = $(this).children('td');
8531
+
8532
+ if (el.length == 1) {
8533
+ el.attr('colspan', visible);
8534
+ }
8535
+ });
8508
8536
  }
8509
8537
  }
8510
8538
  } );
@@ -9711,12 +9739,12 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9711
9739
  /**
9712
9740
  * Version string for plug-ins to check compatibility. Allowed format is
9713
9741
  * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
9714
- * only for non-release builds. See http://semver.org/ for more information.
9742
+ * only for non-release builds. See https://semver.org/ for more information.
9715
9743
  * @member
9716
9744
  * @type string
9717
9745
  * @default Version number
9718
9746
  */
9719
- DataTable.version = "1.13.5";
9747
+ DataTable.version = "1.13.7";
9720
9748
 
9721
9749
  /**
9722
9750
  * Private data store, containing all of the settings objects that are
@@ -10292,7 +10320,7 @@ DataTable.defaults = {
10292
10320
  * --------
10293
10321
  *
10294
10322
  * As an object, the parameters in the object are passed to
10295
- * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
10323
+ * [jQuery.ajax](https://api.jquery.com/jQuery.ajax/) allowing fine control
10296
10324
  * of the Ajax request. DataTables has a number of default parameters which
10297
10325
  * you can override using this option. Please refer to the jQuery
10298
10326
  * documentation for a full description of the options available, although
@@ -12000,7 +12028,7 @@ DataTable.defaults = {
12000
12028
  * $(document).ready( function() {
12001
12029
  * $('#example').dataTable( {
12002
12030
  * "language": {
12003
- * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
12031
+ * "url": "https://www.sprymedia.co.uk/dataTables/lang.txt"
12004
12032
  * }
12005
12033
  * } );
12006
12034
  * } );
@@ -14781,7 +14809,7 @@ $.extend( true, DataTable.ext.renderer, {
14781
14809
  var btnDisplay, btnClass;
14782
14810
 
14783
14811
  var attach = function( container, buttons ) {
14784
- var i, ien, node, button, tabIndex;
14812
+ var i, ien, node, button;
14785
14813
  var disabledClass = classes.sPageButtonDisabled;
14786
14814
  var clickHandler = function ( e ) {
14787
14815
  _fnPageChange( settings, e.data.action, true );
@@ -14796,9 +14824,10 @@ $.extend( true, DataTable.ext.renderer, {
14796
14824
  attach( inner, button );
14797
14825
  }
14798
14826
  else {
14827
+ var disabled = false;
14828
+
14799
14829
  btnDisplay = null;
14800
14830
  btnClass = button;
14801
- tabIndex = settings.iTabIndex;
14802
14831
 
14803
14832
  switch ( button ) {
14804
14833
  case 'ellipsis':
@@ -14809,8 +14838,7 @@ $.extend( true, DataTable.ext.renderer, {
14809
14838
  btnDisplay = lang.sFirst;
14810
14839
 
14811
14840
  if ( page === 0 ) {
14812
- tabIndex = -1;
14813
- btnClass += ' ' + disabledClass;
14841
+ disabled = true;
14814
14842
  }
14815
14843
  break;
14816
14844
 
@@ -14818,8 +14846,7 @@ $.extend( true, DataTable.ext.renderer, {
14818
14846
  btnDisplay = lang.sPrevious;
14819
14847
 
14820
14848
  if ( page === 0 ) {
14821
- tabIndex = -1;
14822
- btnClass += ' ' + disabledClass;
14849
+ disabled = true;
14823
14850
  }
14824
14851
  break;
14825
14852
 
@@ -14827,8 +14854,7 @@ $.extend( true, DataTable.ext.renderer, {
14827
14854
  btnDisplay = lang.sNext;
14828
14855
 
14829
14856
  if ( pages === 0 || page === pages-1 ) {
14830
- tabIndex = -1;
14831
- btnClass += ' ' + disabledClass;
14857
+ disabled = true;
14832
14858
  }
14833
14859
  break;
14834
14860
 
@@ -14836,8 +14862,7 @@ $.extend( true, DataTable.ext.renderer, {
14836
14862
  btnDisplay = lang.sLast;
14837
14863
 
14838
14864
  if ( pages === 0 || page === pages-1 ) {
14839
- tabIndex = -1;
14840
- btnClass += ' ' + disabledClass;
14865
+ disabled = true;
14841
14866
  }
14842
14867
  break;
14843
14868
 
@@ -14850,8 +14875,10 @@ $.extend( true, DataTable.ext.renderer, {
14850
14875
 
14851
14876
  if ( btnDisplay !== null ) {
14852
14877
  var tag = settings.oInit.pagingTag || 'a';
14853
- var disabled = btnClass.indexOf(disabledClass) !== -1;
14854
-
14878
+
14879
+ if (disabled) {
14880
+ btnClass += ' ' + disabledClass;
14881
+ }
14855
14882
 
14856
14883
  node = $('<'+tag+'>', {
14857
14884
  'class': classes.sPageButton+' '+btnClass,
@@ -14861,7 +14888,7 @@ $.extend( true, DataTable.ext.renderer, {
14861
14888
  'role': 'link',
14862
14889
  'aria-current': btnClass === classes.sPageButtonActive ? 'page' : null,
14863
14890
  'data-dt-idx': button,
14864
- 'tabindex': tabIndex,
14891
+ 'tabindex': disabled ? -1 : settings.iTabIndex,
14865
14892
  'id': idx === 0 && typeof button === 'string' ?
14866
14893
  settings.sTableId +'_'+ button :
14867
14894
  null
@@ -15078,7 +15105,7 @@ $.extend( _ext.type.order, {
15078
15105
  // string
15079
15106
  "string-pre": function ( a ) {
15080
15107
  // This is a little complex, but faster than always calling toString,
15081
- // http://jsperf.com/tostring-v-check
15108
+ // https://jsperf.com/tostring-v-check
15082
15109
  return _empty(a) ?
15083
15110
  '' :
15084
15111
  typeof a === 'string' ?
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/jquery.dataTables.js",
5
5
  "module": "js/jquery.dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "1.13.6",
7
+ "version": "1.13.8",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",
package/types/types.d.ts CHANGED
@@ -813,7 +813,17 @@ export interface Api<T> {
813
813
  * @param callback Specific callback function to remove if you want to unbind a single event listener.
814
814
  * @returns DataTables Api instance
815
815
  */
816
- off(event: string, callback?: ((e: Event, ...args: any[]) => void)): Api<T>;
816
+ off(event: string, callback?: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
817
+
818
+ /**
819
+ * Remove event handlers from selected elements
820
+ *
821
+ * @param event Event name to remove.
822
+ * @param selector Element selector
823
+ * @param callback Specific callback function to remove if you want to unbind a single event listener.
824
+ * @returns DataTables Api instance
825
+ */
826
+ off(event: string, selector: string, callback?: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
817
827
 
818
828
  /**
819
829
  * Table events listener.
@@ -822,7 +832,17 @@ export interface Api<T> {
822
832
  * @param callback Specific callback function to remove if you want to unbind a single event listener.
823
833
  * @returns DataTables Api instance
824
834
  */
825
- on(event: string, callback: ((e: Event, ...args: any[]) => void)): Api<T>;
835
+ on(event: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
836
+
837
+ /**
838
+ * Listen for events from selected elements
839
+ *
840
+ * @param event Event to listen for.
841
+ * @param selector Element selector
842
+ * @param callback Event handler.
843
+ * @returns DataTables Api instance
844
+ */
845
+ on(event: string, selector: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
826
846
 
827
847
  /**
828
848
  * Listen for a table event once and then remove the listener.
@@ -832,7 +852,17 @@ export interface Api<T> {
832
852
  * Listen for events from tables and fire a callback when they occur
833
853
  * @returns DataTables Api instance
834
854
  */
835
- one(event: string, callback: ((e: Event, ...args: any[]) => void)): Api<T>;
855
+ one(event: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
856
+
857
+ /**
858
+ * Listen for events from a selected element and trigger only once then remove the listener.
859
+ *
860
+ * @param event Event to listen for.
861
+ * @param selector Element selector
862
+ * @param callback Event handler.
863
+ * @returns DataTables Api instance
864
+ */
865
+ one(event: string, selector: string, callback: ((this: HTMLElement, e: Event, ...args: any[]) => void)): Api<T>;
836
866
 
837
867
  /**
838
868
  * Page Methods / object
@@ -1798,7 +1828,7 @@ export interface ApiRow<T> {
1798
1828
  * @param data Data to use for the new row. This may be an array, object or Javascript object instance, but must be in the same format as the other data in the table+
1799
1829
  * @returns DataTables API instance with the newly added row in its result set.
1800
1830
  */
1801
- add(data: any[] | object): Api<Array<Array<any>>>;
1831
+ add(data: any[] | object): ApiRowMethods<T>;
1802
1832
  }
1803
1833
 
1804
1834
  export interface ApiRowMethods<T> extends Omit<Api<T>, 'data'> {
@@ -1892,7 +1922,7 @@ export interface ApiRows<T> {
1892
1922
  * @param data Array of data elements, with each one describing a new row to be added to the table
1893
1923
  * @returns DataTables API instance with the newly added rows in its result set.
1894
1924
  */
1895
- add(data: T[]): Api<Array<any>>;
1925
+ add(data: T[]): ApiRowsMethods<T>;
1896
1926
  }
1897
1927
 
1898
1928
  export interface ApiRowsMethods<T> extends Api<T> {