datatables.net 2.1.4 → 2.1.6

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.4
1
+ /*! DataTables 2.1.6
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -201,6 +201,7 @@ var DataTable = function ( selector, options )
201
201
  "caption",
202
202
  "layout",
203
203
  "orderDescReverse",
204
+ "typeDetect",
204
205
  [ "iCookieDuration", "iStateDuration" ], // backwards compat
205
206
  [ "oSearch", "oPreviousSearch" ],
206
207
  [ "aoSearchCols", "aoPreSearchCols" ],
@@ -424,7 +425,7 @@ var DataTable = function ( selector, options )
424
425
  } );
425
426
  }
426
427
  else {
427
- _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
428
+ _fnCallbackFire( oSettings, null, 'i18n', [oSettings], true);
428
429
  _fnInitialise( oSettings );
429
430
  }
430
431
  } );
@@ -1000,7 +1001,8 @@ $.extend( DataTable.ext.classes, {
1000
1001
  active: 'current',
1001
1002
  button: 'dt-paging-button',
1002
1003
  container: 'dt-paging',
1003
- disabled: 'disabled'
1004
+ disabled: 'disabled',
1005
+ nav: ''
1004
1006
  }
1005
1007
  } );
1006
1008
 
@@ -1163,7 +1165,7 @@ var _pluck_order = function ( a, order, prop, prop2 )
1163
1165
  // is essential here
1164
1166
  if ( prop2 !== undefined ) {
1165
1167
  for ( ; i<ien ; i++ ) {
1166
- if ( a[ order[i] ][ prop ] ) {
1168
+ if ( a[ order[i] ] && a[ order[i] ][ prop ] ) {
1167
1169
  out.push( a[ order[i] ][ prop ][ prop2 ] );
1168
1170
  }
1169
1171
  }
@@ -2102,7 +2104,11 @@ function _fnColumnSizes ( settings )
2102
2104
  for (var i=0 ; i<cols.length ; i++) {
2103
2105
  var width = _fnColumnsSumWidth(settings, [i], false, false);
2104
2106
 
2105
- cols[i].colEl.css('width', width);
2107
+ // Need to set the min-width, otherwise the browser might try to collapse
2108
+ // it further
2109
+ cols[i].colEl
2110
+ .css('width', width)
2111
+ .css('min-width', width);
2106
2112
  }
2107
2113
  }
2108
2114
 
@@ -2216,12 +2222,6 @@ function _fnColumnTypes ( settings )
2216
2222
  var i, ien, j, jen, k, ken;
2217
2223
  var col, detectedType, cache;
2218
2224
 
2219
- // If SSP then we don't have the full data set, so any type detection would be
2220
- // unreliable and error prone
2221
- if (_fnDataSource( settings ) === 'ssp') {
2222
- return;
2223
- }
2224
-
2225
2225
  // For each column, spin over the data type detection functions, seeing if one matches
2226
2226
  for ( i=0, ien=columns.length ; i<ien ; i++ ) {
2227
2227
  col = columns[i];
@@ -2231,6 +2231,12 @@ function _fnColumnTypes ( settings )
2231
2231
  col.sType = col._sManualType;
2232
2232
  }
2233
2233
  else if ( ! col.sType ) {
2234
+ // With SSP type detection can be unreliable and error prone, so we provide a way
2235
+ // to turn it off.
2236
+ if (! settings.typeDetect) {
2237
+ return;
2238
+ }
2239
+
2234
2240
  for ( j=0, jen=types.length ; j<jen ; j++ ) {
2235
2241
  var typeDetect = types[j];
2236
2242
 
@@ -3068,6 +3074,9 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
3068
3074
  _fnWriteCell(nTd, display[i]);
3069
3075
  }
3070
3076
 
3077
+ // column class
3078
+ _addClass(nTd, oCol.sClass);
3079
+
3071
3080
  // Visibility - add or remove as required
3072
3081
  if ( oCol.bVisible && create )
3073
3082
  {
@@ -3399,7 +3408,6 @@ function _fnDraw( oSettings, ajaxComplete )
3399
3408
  var td = aoData.anCells[i];
3400
3409
 
3401
3410
  _addClass(td, _ext.type.className[col.sType]); // auto class
3402
- _addClass(td, col.sClass); // column class
3403
3411
  _addClass(td, oSettings.oClasses.tbody.cell); // all cells
3404
3412
  }
3405
3413
 
@@ -4280,6 +4288,7 @@ function _fnAjaxUpdateDraw ( settings, json )
4280
4288
  }
4281
4289
  settings.aiDisplay = settings.aiDisplayMaster.slice();
4282
4290
 
4291
+ _fnColumnTypes(settings);
4283
4292
  _fnDraw( settings, true );
4284
4293
  _fnInitComplete( settings );
4285
4294
  _fnProcessingDisplay( settings, false );
@@ -5173,21 +5182,37 @@ function _fnScrollDraw ( settings )
5173
5182
  // is because of Responsive which might remove `col` elements, knocking the alignment
5174
5183
  // of the indexes out.
5175
5184
  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()
5185
+ // Get the column sizes from the first row in the table. This should really be a
5186
+ // [].find, but it wasn't supported in Chrome until Sept 2015, and DT has 10 year
5187
+ // browser support
5188
+ var firstTr = null;
5189
+
5190
+ for (i=0 ; i<settings.aiDisplay.length ; i++) {
5191
+ var idx = settings.aiDisplay[i];
5192
+ var tr = settings.aoData[idx].nTr;
5193
+
5194
+ if (tr) {
5195
+ firstTr = tr;
5196
+ break;
5181
5197
  }
5182
- });
5198
+ }
5183
5199
 
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', '');
5200
+ if (firstTr) {
5201
+ var colSizes = $(firstTr).children('th, td').map(function (vis) {
5202
+ return {
5203
+ idx: _fnVisibleToColumnIndex(settings, vis),
5204
+ width: $(this).outerWidth()
5205
+ }
5206
+ });
5207
+
5208
+ // Check against what the colgroup > col is set to and correct if needed
5209
+ for (var i=0 ; i<colSizes.length ; i++) {
5210
+ var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5211
+ var colWidth = colEl.style.width.replace('px', '');
5188
5212
 
5189
- if (colWidth !== colSizes[i].width) {
5190
- colEl.style.width = colSizes[i].width + 'px';
5213
+ if (colWidth !== colSizes[i].width) {
5214
+ colEl.style.width = colSizes[i].width + 'px';
5215
+ }
5191
5216
  }
5192
5217
  }
5193
5218
  }
@@ -5330,7 +5355,11 @@ function _fnCalculateColumnWidths ( settings )
5330
5355
  var width = _fnColumnsSumWidth( settings, this, true, false );
5331
5356
 
5332
5357
  if ( width ) {
5358
+ // Need to set the width and min-width, otherwise the browser
5359
+ // will attempt to collapse the table beyond want might have
5360
+ // been specified
5333
5361
  this.style.width = width;
5362
+ this.style.minWidth = width;
5334
5363
 
5335
5364
  // For scrollX we need to force the column width otherwise the
5336
5365
  // browser will collapse it. If this width is smaller than the
@@ -6715,6 +6744,7 @@ _Api = function ( context, data )
6715
6744
  return new _Api( context, data );
6716
6745
  }
6717
6746
 
6747
+ var i;
6718
6748
  var settings = [];
6719
6749
  var ctxSettings = function ( o ) {
6720
6750
  var a = _toSettings( o );
@@ -6724,7 +6754,7 @@ _Api = function ( context, data )
6724
6754
  };
6725
6755
 
6726
6756
  if ( Array.isArray( context ) ) {
6727
- for ( var i=0, ien=context.length ; i<ien ; i++ ) {
6757
+ for ( i=0 ; i<context.length ; i++ ) {
6728
6758
  ctxSettings( context[i] );
6729
6759
  }
6730
6760
  }
@@ -6739,7 +6769,16 @@ _Api = function ( context, data )
6739
6769
 
6740
6770
  // Initial data
6741
6771
  if ( data ) {
6742
- this.push.apply(this, data);
6772
+ // Chrome can throw a max stack error if apply is called with
6773
+ // too large an array, but apply is faster.
6774
+ if (data.length < 10000) {
6775
+ this.push.apply(this, data);
6776
+ }
6777
+ else {
6778
+ for (i=0 ; i<data.length ; i++) {
6779
+ this.push(data[i]);
6780
+ }
6781
+ }
6743
6782
  }
6744
6783
 
6745
6784
  // selector
@@ -9770,7 +9809,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9770
9809
  * @type string
9771
9810
  * @default Version number
9772
9811
  */
9773
- DataTable.version = "2.1.4";
9812
+ DataTable.version = "2.1.6";
9774
9813
 
9775
9814
  /**
9776
9815
  * Private data store, containing all of the settings objects that are
@@ -11870,7 +11909,10 @@ DataTable.models.oSettings = {
11870
11909
  colgroup: null,
11871
11910
 
11872
11911
  /** Delay loading of data */
11873
- deferLoading: null
11912
+ deferLoading: null,
11913
+
11914
+ /** Allow auto type detection */
11915
+ typeDetect: true
11874
11916
  };
11875
11917
 
11876
11918
  /**
@@ -13078,7 +13120,11 @@ DataTable.feature.register( 'paging', function ( settings, opts ) {
13078
13120
 
13079
13121
  var host = $('<div/>')
13080
13122
  .addClass(settings.oClasses.paging.container + (opts.type ? ' paging_' + opts.type : ''))
13081
- .append('<nav>');
13123
+ .append(
13124
+ $('<nav>')
13125
+ .attr('aria-label', 'pagination')
13126
+ .addClass(settings.oClasses.paging.nav)
13127
+ );
13082
13128
  var draw = function () {
13083
13129
  _pagingDraw(settings, host.children(), opts);
13084
13130
  };
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.4",
7
+ "version": "2.1.6",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",