datatables.net 2.1.3 → 2.1.5

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/dataTables.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! DataTables 2.1.3
1
+ /*! DataTables 2.1.5
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -1000,7 +1000,8 @@ $.extend( DataTable.ext.classes, {
1000
1000
  active: 'current',
1001
1001
  button: 'dt-paging-button',
1002
1002
  container: 'dt-paging',
1003
- disabled: 'disabled'
1003
+ disabled: 'disabled',
1004
+ nav: ''
1004
1005
  }
1005
1006
  } );
1006
1007
 
@@ -2102,7 +2103,11 @@ function _fnColumnSizes ( settings )
2102
2103
  for (var i=0 ; i<cols.length ; i++) {
2103
2104
  var width = _fnColumnsSumWidth(settings, [i], false, false);
2104
2105
 
2105
- cols[i].colEl.css('width', width);
2106
+ // Need to set the min-width, otherwise the browser might try to collapse
2107
+ // it further
2108
+ cols[i].colEl
2109
+ .css('width', width)
2110
+ .css('min-width', width);
2106
2111
  }
2107
2112
  }
2108
2113
 
@@ -3068,6 +3073,9 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
3068
3073
  _fnWriteCell(nTd, display[i]);
3069
3074
  }
3070
3075
 
3076
+ // column class
3077
+ _addClass(nTd, oCol.sClass);
3078
+
3071
3079
  // Visibility - add or remove as required
3072
3080
  if ( oCol.bVisible && create )
3073
3081
  {
@@ -3399,7 +3407,6 @@ function _fnDraw( oSettings, ajaxComplete )
3399
3407
  var td = aoData.anCells[i];
3400
3408
 
3401
3409
  _addClass(td, _ext.type.className[col.sType]); // auto class
3402
- _addClass(td, col.sClass); // column class
3403
3410
  _addClass(td, oSettings.oClasses.tbody.cell); // all cells
3404
3411
  }
3405
3412
 
@@ -5173,21 +5180,37 @@ function _fnScrollDraw ( settings )
5173
5180
  // is because of Responsive which might remove `col` elements, knocking the alignment
5174
5181
  // of the indexes out.
5175
5182
  if (settings.aiDisplay.length) {
5176
- // Get the column sizes from the first row in the table
5177
- var colSizes = table.children('tbody').eq(0).children('tr').eq(0).children('th, td').map(function (vis) {
5178
- return {
5179
- idx: _fnVisibleToColumnIndex(settings, vis),
5180
- width: $(this).outerWidth()
5183
+ // Get the column sizes from the first row in the table. This should really be a
5184
+ // [].find, but it wasn't supported in Chrome until Sept 2015, and DT has 10 year
5185
+ // browser support
5186
+ var firstTr = null;
5187
+
5188
+ for (i=0 ; i<settings.aiDisplay.length ; i++) {
5189
+ var idx = settings.aiDisplay[i];
5190
+ var tr = settings.aoData[idx].nTr;
5191
+
5192
+ if (tr) {
5193
+ firstTr = tr;
5194
+ break;
5181
5195
  }
5182
- });
5196
+ }
5197
+
5198
+ if (firstTr) {
5199
+ var colSizes = $(firstTr).children('th, td').map(function (vis) {
5200
+ return {
5201
+ idx: _fnVisibleToColumnIndex(settings, vis),
5202
+ width: $(this).outerWidth()
5203
+ }
5204
+ });
5183
5205
 
5184
- // Check against what the colgroup > col is set to and correct if needed
5185
- for (var i=0 ; i<colSizes.length ; i++) {
5186
- var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5187
- var colWidth = colEl.style.width.replace('px', '');
5206
+ // Check against what the colgroup > col is set to and correct if needed
5207
+ for (var i=0 ; i<colSizes.length ; i++) {
5208
+ var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5209
+ var colWidth = colEl.style.width.replace('px', '');
5188
5210
 
5189
- if (colWidth !== colSizes[i].width) {
5190
- colEl.style.width = colSizes[i].width + 'px';
5211
+ if (colWidth !== colSizes[i].width) {
5212
+ colEl.style.width = colSizes[i].width + 'px';
5213
+ }
5191
5214
  }
5192
5215
  }
5193
5216
  }
@@ -5330,7 +5353,11 @@ function _fnCalculateColumnWidths ( settings )
5330
5353
  var width = _fnColumnsSumWidth( settings, this, true, false );
5331
5354
 
5332
5355
  if ( width ) {
5356
+ // Need to set the width and min-width, otherwise the browser
5357
+ // will attempt to collapse the table beyond want might have
5358
+ // been specified
5333
5359
  this.style.width = width;
5360
+ this.style.minWidth = width;
5334
5361
 
5335
5362
  // For scrollX we need to force the column width otherwise the
5336
5363
  // browser will collapse it. If this width is smaller than the
@@ -6715,6 +6742,7 @@ _Api = function ( context, data )
6715
6742
  return new _Api( context, data );
6716
6743
  }
6717
6744
 
6745
+ var i;
6718
6746
  var settings = [];
6719
6747
  var ctxSettings = function ( o ) {
6720
6748
  var a = _toSettings( o );
@@ -6724,7 +6752,7 @@ _Api = function ( context, data )
6724
6752
  };
6725
6753
 
6726
6754
  if ( Array.isArray( context ) ) {
6727
- for ( var i=0, ien=context.length ; i<ien ; i++ ) {
6755
+ for ( i=0 ; i<context.length ; i++ ) {
6728
6756
  ctxSettings( context[i] );
6729
6757
  }
6730
6758
  }
@@ -6739,7 +6767,16 @@ _Api = function ( context, data )
6739
6767
 
6740
6768
  // Initial data
6741
6769
  if ( data ) {
6742
- this.push.apply(this, data);
6770
+ // Chrome can throw a max stack error if apply is called with
6771
+ // too large an array, but apply is faster.
6772
+ if (data.length < 10000) {
6773
+ this.push.apply(this, data);
6774
+ }
6775
+ else {
6776
+ for (i=0 ; i<data.length ; i++) {
6777
+ this.push(data[i]);
6778
+ }
6779
+ }
6743
6780
  }
6744
6781
 
6745
6782
  // selector
@@ -8429,8 +8466,10 @@ var __column_selector = function ( settings, selector, opts )
8429
8466
  switch( match[2] ) {
8430
8467
  case 'visIdx':
8431
8468
  case 'visible':
8432
- if (match[1]) {
8469
+ // Selector is a column index
8470
+ if (match[1] && match[1].match(/^\d+$/)) {
8433
8471
  var idx = parseInt( match[1], 10 );
8472
+
8434
8473
  // Visible index given, convert to column index
8435
8474
  if ( idx < 0 ) {
8436
8475
  // Counting from the right
@@ -8443,9 +8482,19 @@ var __column_selector = function ( settings, selector, opts )
8443
8482
  return [ _fnVisibleToColumnIndex( settings, idx ) ];
8444
8483
  }
8445
8484
 
8446
- // `:visible` on its own
8447
- return columns.map( function (col, i) {
8448
- return col.bVisible ? i : null;
8485
+ return columns.map( function (col, idx) {
8486
+ // Not visible, can't match
8487
+ if (! col.bVisible) {
8488
+ return null;
8489
+ }
8490
+
8491
+ // Selector
8492
+ if (match[1]) {
8493
+ return $(nodes[idx]).filter(match[1]).length > 0 ? idx : null;
8494
+ }
8495
+
8496
+ // `:visible` on its own
8497
+ return idx;
8449
8498
  } );
8450
8499
 
8451
8500
  case 'name':
@@ -9758,7 +9807,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9758
9807
  * @type string
9759
9808
  * @default Version number
9760
9809
  */
9761
- DataTable.version = "2.1.3";
9810
+ DataTable.version = "2.1.5";
9762
9811
 
9763
9812
  /**
9764
9813
  * Private data store, containing all of the settings objects that are
@@ -12432,7 +12481,7 @@ DataTable.type('string', {
12432
12481
  pre: function ( a ) {
12433
12482
  // This is a little complex, but faster than always calling toString,
12434
12483
  // http://jsperf.com/tostring-v-check
12435
- return _empty(a) ?
12484
+ return _empty(a) && typeof a !== 'boolean' ?
12436
12485
  '' :
12437
12486
  typeof a === 'string' ?
12438
12487
  a.toLowerCase() :
@@ -12685,6 +12734,12 @@ $.extend( true, DataTable.ext.renderer, {
12685
12734
  return; // table, not a nested one
12686
12735
  }
12687
12736
 
12737
+ var sorting = ctx.sortDetails;
12738
+
12739
+ if (! sorting) {
12740
+ return;
12741
+ }
12742
+
12688
12743
  var i;
12689
12744
  var orderClasses = classes.order;
12690
12745
  var columns = ctx.api.columns( cell );
@@ -12693,7 +12748,6 @@ $.extend( true, DataTable.ext.renderer, {
12693
12748
  var ariaType = '';
12694
12749
  var indexes = columns.indexes();
12695
12750
  var sortDirs = columns.orderable(true).flatten();
12696
- var sorting = ctx.sortDetails;
12697
12751
  var orderedColumns = _pluck(sorting, 'col');
12698
12752
 
12699
12753
  cell
@@ -13061,7 +13115,11 @@ DataTable.feature.register( 'paging', function ( settings, opts ) {
13061
13115
 
13062
13116
  var host = $('<div/>')
13063
13117
  .addClass(settings.oClasses.paging.container + (opts.type ? ' paging_' + opts.type : ''))
13064
- .append('<nav>');
13118
+ .append(
13119
+ $('<nav>')
13120
+ .attr('aria-label', 'pagination')
13121
+ .addClass(settings.oClasses.paging.nav)
13122
+ );
13065
13123
  var draw = function () {
13066
13124
  _pagingDraw(settings, host.children(), opts);
13067
13125
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "js/dataTables.js",
5
5
  "module": "js/dataTables.mjs",
6
6
  "types": "./types/types.d.ts",
7
- "version": "2.1.3",
7
+ "version": "2.1.5",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",