datatables.net 2.1.5 → 2.1.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.
package/js/dataTables.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! DataTables 2.1.5
1
+ /*! DataTables 2.1.7
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.5
8
+ * @version 2.1.7
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
  } );
@@ -1217,7 +1218,7 @@
1217
1218
  // is essential here
1218
1219
  if ( prop2 !== undefined ) {
1219
1220
  for ( ; i<ien ; i++ ) {
1220
- if ( a[ order[i] ][ prop ] ) {
1221
+ if ( a[ order[i] ] && a[ order[i] ][ prop ] ) {
1221
1222
  out.push( a[ order[i] ][ prop ][ prop2 ] );
1222
1223
  }
1223
1224
  }
@@ -1317,8 +1318,11 @@
1317
1318
  }
1318
1319
 
1319
1320
  // It is faster to just run `normalize` than it is to check if
1320
- // we need to with a regex!
1321
- var res = str.normalize("NFD");
1321
+ // we need to with a regex! (Check as it isn't available in old
1322
+ // Safari)
1323
+ var res = str.normalize
1324
+ ? str.normalize("NFD")
1325
+ : str;
1322
1326
 
1323
1327
  // Equally, here we check if a regex is needed or not
1324
1328
  return res.length !== str.length
@@ -2156,11 +2160,7 @@
2156
2160
  for (var i=0 ; i<cols.length ; i++) {
2157
2161
  var width = _fnColumnsSumWidth(settings, [i], false, false);
2158
2162
 
2159
- // Need to set the min-width, otherwise the browser might try to collapse
2160
- // it further
2161
- cols[i].colEl
2162
- .css('width', width)
2163
- .css('min-width', width);
2163
+ cols[i].colEl.css('width', width);
2164
2164
  }
2165
2165
  }
2166
2166
 
@@ -2257,7 +2257,7 @@
2257
2257
  */
2258
2258
  function _typeResult (typeDetect, res) {
2259
2259
  return res === true
2260
- ? typeDetect.name
2260
+ ? typeDetect._name
2261
2261
  : res;
2262
2262
  }
2263
2263
 
@@ -2274,12 +2274,6 @@
2274
2274
  var i, ien, j, jen, k, ken;
2275
2275
  var col, detectedType, cache;
2276
2276
 
2277
- // If SSP then we don't have the full data set, so any type detection would be
2278
- // unreliable and error prone
2279
- if (_fnDataSource( settings ) === 'ssp') {
2280
- return;
2281
- }
2282
-
2283
2277
  // For each column, spin over the data type detection functions, seeing if one matches
2284
2278
  for ( i=0, ien=columns.length ; i<ien ; i++ ) {
2285
2279
  col = columns[i];
@@ -2289,6 +2283,12 @@
2289
2283
  col.sType = col._sManualType;
2290
2284
  }
2291
2285
  else if ( ! col.sType ) {
2286
+ // With SSP type detection can be unreliable and error prone, so we provide a way
2287
+ // to turn it off.
2288
+ if (! settings.typeDetect) {
2289
+ return;
2290
+ }
2291
+
2292
2292
  for ( j=0, jen=types.length ; j<jen ; j++ ) {
2293
2293
  var typeDetect = types[j];
2294
2294
 
@@ -3040,8 +3040,8 @@
3040
3040
  * @returns
3041
3041
  */
3042
3042
  function _fnGetRowDisplay (settings, rowIdx) {
3043
- let rowModal = settings.aoData[rowIdx];
3044
- let columns = settings.aoColumns;
3043
+ var rowModal = settings.aoData[rowIdx];
3044
+ var columns = settings.aoColumns;
3045
3045
 
3046
3046
  if (! rowModal.displayData) {
3047
3047
  // Need to render and cache
@@ -4340,6 +4340,7 @@
4340
4340
  }
4341
4341
  settings.aiDisplay = settings.aiDisplayMaster.slice();
4342
4342
 
4343
+ _fnColumnTypes(settings);
4343
4344
  _fnDraw( settings, true );
4344
4345
  _fnInitComplete( settings );
4345
4346
  _fnProcessingDisplay( settings, false );
@@ -5406,11 +5407,7 @@
5406
5407
  var width = _fnColumnsSumWidth( settings, this, true, false );
5407
5408
 
5408
5409
  if ( width ) {
5409
- // Need to set the width and min-width, otherwise the browser
5410
- // will attempt to collapse the table beyond want might have
5411
- // been specified
5412
5410
  this.style.width = width;
5413
- this.style.minWidth = width;
5414
5411
 
5415
5412
  // For scrollX we need to force the column width otherwise the
5416
5413
  // browser will collapse it. If this width is smaller than the
@@ -7712,7 +7709,7 @@
7712
7709
  // Reduce the API instance to the first item found
7713
7710
  var _selector_first = function ( old )
7714
7711
  {
7715
- let inst = new _Api(old.context[0]);
7712
+ var inst = new _Api(old.context[0]);
7716
7713
 
7717
7714
  // Use a push rather than passing to the constructor, since it will
7718
7715
  // merge arrays down automatically, which isn't what is wanted here
@@ -9707,7 +9704,7 @@
9707
9704
  fn.call(this);
9708
9705
  }
9709
9706
  else {
9710
- this.on('init', function () {
9707
+ this.on('init.dt.DT', function () {
9711
9708
  fn.call(this);
9712
9709
  });
9713
9710
  }
@@ -9860,7 +9857,7 @@
9860
9857
  * @type string
9861
9858
  * @default Version number
9862
9859
  */
9863
- DataTable.version = "2.1.5";
9860
+ DataTable.version = "2.1.7";
9864
9861
 
9865
9862
  /**
9866
9863
  * Private data store, containing all of the settings objects that are
@@ -11960,7 +11957,10 @@
11960
11957
  colgroup: null,
11961
11958
 
11962
11959
  /** Delay loading of data */
11963
- deferLoading: null
11960
+ deferLoading: null,
11961
+
11962
+ /** Allow auto type detection */
11963
+ typeDetect: true
11964
11964
  };
11965
11965
 
11966
11966
  /**
@@ -12421,7 +12421,7 @@
12421
12421
  return {
12422
12422
  className: _extTypes.className[name],
12423
12423
  detect: _extTypes.detect.find(function (fn) {
12424
- return fn.name === name;
12424
+ return fn._name === name;
12425
12425
  }),
12426
12426
  order: {
12427
12427
  pre: _extTypes.order[name + '-pre'],
@@ -12439,10 +12439,10 @@
12439
12439
  var setDetect = function (detect) {
12440
12440
  // `detect` can be a function or an object - we set a name
12441
12441
  // property for either - that is used for the detection
12442
- Object.defineProperty(detect, "name", {value: name});
12442
+ Object.defineProperty(detect, "_name", {value: name});
12443
12443
 
12444
12444
  var idx = _extTypes.detect.findIndex(function (item) {
12445
- return item.name === name;
12445
+ return item._name === name;
12446
12446
  });
12447
12447
 
12448
12448
  if (idx === -1) {
@@ -12505,13 +12505,13 @@
12505
12505
  // Get a list of types
12506
12506
  DataTable.types = function () {
12507
12507
  return _extTypes.detect.map(function (fn) {
12508
- return fn.name;
12508
+ return fn._name;
12509
12509
  });
12510
12510
  };
12511
12511
 
12512
12512
  var __diacriticSort = function (a, b) {
12513
- a = a.toString().toLowerCase();
12514
- b = b.toString().toLowerCase();
12513
+ a = a !== null && a !== undefined ? a.toString().toLowerCase() : '';
12514
+ b = b !== null && b !== undefined ? b.toString().toLowerCase() : '';
12515
12515
 
12516
12516
  // Checked for `navigator.languages` support in `oneOf` so this code can't execute in old
12517
12517
  // Safari and thus can disable this check
@@ -13225,15 +13225,17 @@
13225
13225
  all = len === -1,
13226
13226
  page = all ? 0 : Math.ceil( start / len ),
13227
13227
  pages = all ? 1 : Math.ceil( visRecords / len ),
13228
- buttons = plugin(opts)
13228
+ buttons = [],
13229
+ buttonEls = [],
13230
+ buttonsNested = plugin(opts)
13229
13231
  .map(function (val) {
13230
13232
  return val === 'numbers'
13231
13233
  ? _pagingNumbers(page, pages, opts.buttons, opts.boundaryNumbers)
13232
13234
  : val;
13233
- })
13234
- .flat();
13235
+ });
13235
13236
 
13236
- var buttonEls = [];
13237
+ // .flat() would be better, but not supported in old Safari
13238
+ buttons = buttons.concat.apply(buttons, buttonsNested);
13237
13239
 
13238
13240
  for (var i=0 ; i<buttons.length ; i++) {
13239
13241
  var button = buttons[i];
@@ -13512,14 +13514,14 @@
13512
13514
 
13513
13515
  // Save text node content for macro updating
13514
13516
  var textNodes = [];
13515
- div.find('label')[0].childNodes.forEach(function (el) {
13517
+ Array.from(div.find('label')[0].childNodes).forEach(function (el) {
13516
13518
  if (el.nodeType === Node.TEXT_NODE) {
13517
13519
  textNodes.push({
13518
13520
  el: el,
13519
13521
  text: el.textContent
13520
13522
  });
13521
13523
  }
13522
- })
13524
+ });
13523
13525
 
13524
13526
  // Update the label text in case it has an entries value
13525
13527
  var updateEntries = function (len) {