datatables.net 1.13.5 → 1.13.7

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 ) {
@@ -9711,12 +9733,12 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9711
9733
  /**
9712
9734
  * Version string for plug-ins to check compatibility. Allowed format is
9713
9735
  * `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.
9736
+ * only for non-release builds. See https://semver.org/ for more information.
9715
9737
  * @member
9716
9738
  * @type string
9717
9739
  * @default Version number
9718
9740
  */
9719
- DataTable.version = "1.13.5";
9741
+ DataTable.version = "1.13.7";
9720
9742
 
9721
9743
  /**
9722
9744
  * Private data store, containing all of the settings objects that are
@@ -10292,7 +10314,7 @@ DataTable.defaults = {
10292
10314
  * --------
10293
10315
  *
10294
10316
  * As an object, the parameters in the object are passed to
10295
- * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
10317
+ * [jQuery.ajax](https://api.jquery.com/jQuery.ajax/) allowing fine control
10296
10318
  * of the Ajax request. DataTables has a number of default parameters which
10297
10319
  * you can override using this option. Please refer to the jQuery
10298
10320
  * documentation for a full description of the options available, although
@@ -12000,7 +12022,7 @@ DataTable.defaults = {
12000
12022
  * $(document).ready( function() {
12001
12023
  * $('#example').dataTable( {
12002
12024
  * "language": {
12003
- * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
12025
+ * "url": "https://www.sprymedia.co.uk/dataTables/lang.txt"
12004
12026
  * }
12005
12027
  * } );
12006
12028
  * } );
@@ -14781,7 +14803,7 @@ $.extend( true, DataTable.ext.renderer, {
14781
14803
  var btnDisplay, btnClass;
14782
14804
 
14783
14805
  var attach = function( container, buttons ) {
14784
- var i, ien, node, button, tabIndex;
14806
+ var i, ien, node, button;
14785
14807
  var disabledClass = classes.sPageButtonDisabled;
14786
14808
  var clickHandler = function ( e ) {
14787
14809
  _fnPageChange( settings, e.data.action, true );
@@ -14796,9 +14818,10 @@ $.extend( true, DataTable.ext.renderer, {
14796
14818
  attach( inner, button );
14797
14819
  }
14798
14820
  else {
14821
+ var disabled = false;
14822
+
14799
14823
  btnDisplay = null;
14800
14824
  btnClass = button;
14801
- tabIndex = settings.iTabIndex;
14802
14825
 
14803
14826
  switch ( button ) {
14804
14827
  case 'ellipsis':
@@ -14809,8 +14832,7 @@ $.extend( true, DataTable.ext.renderer, {
14809
14832
  btnDisplay = lang.sFirst;
14810
14833
 
14811
14834
  if ( page === 0 ) {
14812
- tabIndex = -1;
14813
- btnClass += ' ' + disabledClass;
14835
+ disabled = true;
14814
14836
  }
14815
14837
  break;
14816
14838
 
@@ -14818,8 +14840,7 @@ $.extend( true, DataTable.ext.renderer, {
14818
14840
  btnDisplay = lang.sPrevious;
14819
14841
 
14820
14842
  if ( page === 0 ) {
14821
- tabIndex = -1;
14822
- btnClass += ' ' + disabledClass;
14843
+ disabled = true;
14823
14844
  }
14824
14845
  break;
14825
14846
 
@@ -14827,8 +14848,7 @@ $.extend( true, DataTable.ext.renderer, {
14827
14848
  btnDisplay = lang.sNext;
14828
14849
 
14829
14850
  if ( pages === 0 || page === pages-1 ) {
14830
- tabIndex = -1;
14831
- btnClass += ' ' + disabledClass;
14851
+ disabled = true;
14832
14852
  }
14833
14853
  break;
14834
14854
 
@@ -14836,8 +14856,7 @@ $.extend( true, DataTable.ext.renderer, {
14836
14856
  btnDisplay = lang.sLast;
14837
14857
 
14838
14858
  if ( pages === 0 || page === pages-1 ) {
14839
- tabIndex = -1;
14840
- btnClass += ' ' + disabledClass;
14859
+ disabled = true;
14841
14860
  }
14842
14861
  break;
14843
14862
 
@@ -14850,8 +14869,10 @@ $.extend( true, DataTable.ext.renderer, {
14850
14869
 
14851
14870
  if ( btnDisplay !== null ) {
14852
14871
  var tag = settings.oInit.pagingTag || 'a';
14853
- var disabled = btnClass.indexOf(disabledClass) !== -1;
14854
-
14872
+
14873
+ if (disabled) {
14874
+ btnClass += ' ' + disabledClass;
14875
+ }
14855
14876
 
14856
14877
  node = $('<'+tag+'>', {
14857
14878
  'class': classes.sPageButton+' '+btnClass,
@@ -14861,7 +14882,7 @@ $.extend( true, DataTable.ext.renderer, {
14861
14882
  'role': 'link',
14862
14883
  'aria-current': btnClass === classes.sPageButtonActive ? 'page' : null,
14863
14884
  'data-dt-idx': button,
14864
- 'tabindex': tabIndex,
14885
+ 'tabindex': disabled ? -1 : settings.iTabIndex,
14865
14886
  'id': idx === 0 && typeof button === 'string' ?
14866
14887
  settings.sTableId +'_'+ button :
14867
14888
  null
@@ -15078,7 +15099,7 @@ $.extend( _ext.type.order, {
15078
15099
  // string
15079
15100
  "string-pre": function ( a ) {
15080
15101
  // This is a little complex, but faster than always calling toString,
15081
- // http://jsperf.com/tostring-v-check
15102
+ // https://jsperf.com/tostring-v-check
15082
15103
  return _empty(a) ?
15083
15104
  '' :
15084
15105
  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.5",
7
+ "version": "1.13.7",
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> {