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.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! DataTables 2.1.4
1
+ /*! DataTables 2.1.6
2
2
  * © 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 2.1.4
8
+ * @version 2.1.6
9
9
  * @author SpryMedia Ltd
10
10
  * @contact www.datatables.net
11
11
  * @copyright SpryMedia Ltd.
@@ -254,6 +254,7 @@
254
254
  "caption",
255
255
  "layout",
256
256
  "orderDescReverse",
257
+ "typeDetect",
257
258
  [ "iCookieDuration", "iStateDuration" ], // backwards compat
258
259
  [ "oSearch", "oPreviousSearch" ],
259
260
  [ "aoSearchCols", "aoPreSearchCols" ],
@@ -477,7 +478,7 @@
477
478
  } );
478
479
  }
479
480
  else {
480
- _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
481
+ _fnCallbackFire( oSettings, null, 'i18n', [oSettings], true);
481
482
  _fnInitialise( oSettings );
482
483
  }
483
484
  } );
@@ -1053,7 +1054,8 @@
1053
1054
  active: 'current',
1054
1055
  button: 'dt-paging-button',
1055
1056
  container: 'dt-paging',
1056
- disabled: 'disabled'
1057
+ disabled: 'disabled',
1058
+ nav: ''
1057
1059
  }
1058
1060
  } );
1059
1061
 
@@ -1216,7 +1218,7 @@
1216
1218
  // is essential here
1217
1219
  if ( prop2 !== undefined ) {
1218
1220
  for ( ; i<ien ; i++ ) {
1219
- if ( a[ order[i] ][ prop ] ) {
1221
+ if ( a[ order[i] ] && a[ order[i] ][ prop ] ) {
1220
1222
  out.push( a[ order[i] ][ prop ][ prop2 ] );
1221
1223
  }
1222
1224
  }
@@ -2155,7 +2157,11 @@
2155
2157
  for (var i=0 ; i<cols.length ; i++) {
2156
2158
  var width = _fnColumnsSumWidth(settings, [i], false, false);
2157
2159
 
2158
- cols[i].colEl.css('width', width);
2160
+ // Need to set the min-width, otherwise the browser might try to collapse
2161
+ // it further
2162
+ cols[i].colEl
2163
+ .css('width', width)
2164
+ .css('min-width', width);
2159
2165
  }
2160
2166
  }
2161
2167
 
@@ -2269,12 +2275,6 @@
2269
2275
  var i, ien, j, jen, k, ken;
2270
2276
  var col, detectedType, cache;
2271
2277
 
2272
- // If SSP then we don't have the full data set, so any type detection would be
2273
- // unreliable and error prone
2274
- if (_fnDataSource( settings ) === 'ssp') {
2275
- return;
2276
- }
2277
-
2278
2278
  // For each column, spin over the data type detection functions, seeing if one matches
2279
2279
  for ( i=0, ien=columns.length ; i<ien ; i++ ) {
2280
2280
  col = columns[i];
@@ -2284,6 +2284,12 @@
2284
2284
  col.sType = col._sManualType;
2285
2285
  }
2286
2286
  else if ( ! col.sType ) {
2287
+ // With SSP type detection can be unreliable and error prone, so we provide a way
2288
+ // to turn it off.
2289
+ if (! settings.typeDetect) {
2290
+ return;
2291
+ }
2292
+
2287
2293
  for ( j=0, jen=types.length ; j<jen ; j++ ) {
2288
2294
  var typeDetect = types[j];
2289
2295
 
@@ -3121,6 +3127,9 @@
3121
3127
  _fnWriteCell(nTd, display[i]);
3122
3128
  }
3123
3129
 
3130
+ // column class
3131
+ _addClass(nTd, oCol.sClass);
3132
+
3124
3133
  // Visibility - add or remove as required
3125
3134
  if ( oCol.bVisible && create )
3126
3135
  {
@@ -3452,7 +3461,6 @@
3452
3461
  var td = aoData.anCells[i];
3453
3462
 
3454
3463
  _addClass(td, _ext.type.className[col.sType]); // auto class
3455
- _addClass(td, col.sClass); // column class
3456
3464
  _addClass(td, oSettings.oClasses.tbody.cell); // all cells
3457
3465
  }
3458
3466
 
@@ -4333,6 +4341,7 @@
4333
4341
  }
4334
4342
  settings.aiDisplay = settings.aiDisplayMaster.slice();
4335
4343
 
4344
+ _fnColumnTypes(settings);
4336
4345
  _fnDraw( settings, true );
4337
4346
  _fnInitComplete( settings );
4338
4347
  _fnProcessingDisplay( settings, false );
@@ -5226,21 +5235,37 @@
5226
5235
  // is because of Responsive which might remove `col` elements, knocking the alignment
5227
5236
  // of the indexes out.
5228
5237
  if (settings.aiDisplay.length) {
5229
- // Get the column sizes from the first row in the table
5230
- var colSizes = table.children('tbody').eq(0).children('tr').eq(0).children('th, td').map(function (vis) {
5231
- return {
5232
- idx: _fnVisibleToColumnIndex(settings, vis),
5233
- width: $(this).outerWidth()
5238
+ // Get the column sizes from the first row in the table. This should really be a
5239
+ // [].find, but it wasn't supported in Chrome until Sept 2015, and DT has 10 year
5240
+ // browser support
5241
+ var firstTr = null;
5242
+
5243
+ for (i=0 ; i<settings.aiDisplay.length ; i++) {
5244
+ var idx = settings.aiDisplay[i];
5245
+ var tr = settings.aoData[idx].nTr;
5246
+
5247
+ if (tr) {
5248
+ firstTr = tr;
5249
+ break;
5234
5250
  }
5235
- });
5251
+ }
5236
5252
 
5237
- // Check against what the colgroup > col is set to and correct if needed
5238
- for (var i=0 ; i<colSizes.length ; i++) {
5239
- var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5240
- var colWidth = colEl.style.width.replace('px', '');
5253
+ if (firstTr) {
5254
+ var colSizes = $(firstTr).children('th, td').map(function (vis) {
5255
+ return {
5256
+ idx: _fnVisibleToColumnIndex(settings, vis),
5257
+ width: $(this).outerWidth()
5258
+ }
5259
+ });
5260
+
5261
+ // Check against what the colgroup > col is set to and correct if needed
5262
+ for (var i=0 ; i<colSizes.length ; i++) {
5263
+ var colEl = settings.aoColumns[ colSizes[i].idx ].colEl[0];
5264
+ var colWidth = colEl.style.width.replace('px', '');
5241
5265
 
5242
- if (colWidth !== colSizes[i].width) {
5243
- colEl.style.width = colSizes[i].width + 'px';
5266
+ if (colWidth !== colSizes[i].width) {
5267
+ colEl.style.width = colSizes[i].width + 'px';
5268
+ }
5244
5269
  }
5245
5270
  }
5246
5271
  }
@@ -5383,7 +5408,11 @@
5383
5408
  var width = _fnColumnsSumWidth( settings, this, true, false );
5384
5409
 
5385
5410
  if ( width ) {
5411
+ // Need to set the width and min-width, otherwise the browser
5412
+ // will attempt to collapse the table beyond want might have
5413
+ // been specified
5386
5414
  this.style.width = width;
5415
+ this.style.minWidth = width;
5387
5416
 
5388
5417
  // For scrollX we need to force the column width otherwise the
5389
5418
  // browser will collapse it. If this width is smaller than the
@@ -6768,6 +6797,7 @@
6768
6797
  return new _Api( context, data );
6769
6798
  }
6770
6799
 
6800
+ var i;
6771
6801
  var settings = [];
6772
6802
  var ctxSettings = function ( o ) {
6773
6803
  var a = _toSettings( o );
@@ -6777,7 +6807,7 @@
6777
6807
  };
6778
6808
 
6779
6809
  if ( Array.isArray( context ) ) {
6780
- for ( var i=0, ien=context.length ; i<ien ; i++ ) {
6810
+ for ( i=0 ; i<context.length ; i++ ) {
6781
6811
  ctxSettings( context[i] );
6782
6812
  }
6783
6813
  }
@@ -6792,7 +6822,16 @@
6792
6822
 
6793
6823
  // Initial data
6794
6824
  if ( data ) {
6795
- this.push.apply(this, data);
6825
+ // Chrome can throw a max stack error if apply is called with
6826
+ // too large an array, but apply is faster.
6827
+ if (data.length < 10000) {
6828
+ this.push.apply(this, data);
6829
+ }
6830
+ else {
6831
+ for (i=0 ; i<data.length ; i++) {
6832
+ this.push(data[i]);
6833
+ }
6834
+ }
6796
6835
  }
6797
6836
 
6798
6837
  // selector
@@ -9823,7 +9862,7 @@
9823
9862
  * @type string
9824
9863
  * @default Version number
9825
9864
  */
9826
- DataTable.version = "2.1.4";
9865
+ DataTable.version = "2.1.6";
9827
9866
 
9828
9867
  /**
9829
9868
  * Private data store, containing all of the settings objects that are
@@ -11923,7 +11962,10 @@
11923
11962
  colgroup: null,
11924
11963
 
11925
11964
  /** Delay loading of data */
11926
- deferLoading: null
11965
+ deferLoading: null,
11966
+
11967
+ /** Allow auto type detection */
11968
+ typeDetect: true
11927
11969
  };
11928
11970
 
11929
11971
  /**
@@ -13131,7 +13173,11 @@
13131
13173
 
13132
13174
  var host = $('<div/>')
13133
13175
  .addClass(settings.oClasses.paging.container + (opts.type ? ' paging_' + opts.type : ''))
13134
- .append('<nav>');
13176
+ .append(
13177
+ $('<nav>')
13178
+ .attr('aria-label', 'pagination')
13179
+ .addClass(settings.oClasses.paging.nav)
13180
+ );
13135
13181
  var draw = function () {
13136
13182
  _pagingDraw(settings, host.children(), opts);
13137
13183
  };