datatables.net 2.0.1 → 2.0.2

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.0.1
1
+ /*! DataTables 2.0.2
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -264,7 +264,7 @@ var DataTable = function ( selector, options )
264
264
  _fnCamelToHungarian( defaults.oLanguage, json );
265
265
  $.extend( true, oLanguage, json, oSettings.oInit.oLanguage );
266
266
 
267
- _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
267
+ _fnCallbackFire( oSettings, null, 'i18n', [oSettings], true);
268
268
  _fnInitialise( oSettings );
269
269
  },
270
270
  error: function () {
@@ -2302,7 +2302,7 @@ function _columnAutoRender(settings, colIdx) {
2302
2302
  */
2303
2303
  function _columnAutoClass(container, colIdx, className) {
2304
2304
  container.forEach(function (row) {
2305
- if (row[colIdx].unique) {
2305
+ if (row[colIdx] && row[colIdx].unique) {
2306
2306
  _addClass(row[colIdx].cell, className);
2307
2307
  }
2308
2308
  });
@@ -2389,17 +2389,19 @@ function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, headerLayout, fn )
2389
2389
  else {
2390
2390
  // Cell selector
2391
2391
  headerLayout.forEach(function (row) {
2392
- var cell = $(row[k].cell);
2393
-
2394
- // Legacy support. Note that it means that we don't support
2395
- // an element name selector only, since they are treated as
2396
- // class names for 1.x compat.
2397
- if (target.match(/^[a-z][\w-]*$/i)) {
2398
- target = '.' + target;
2399
- }
2400
-
2401
- if (cell.is( target )) {
2402
- fn( k, def );
2392
+ if (row[k]) {
2393
+ var cell = $(row[k].cell);
2394
+
2395
+ // Legacy support. Note that it means that we don't support
2396
+ // an element name selector only, since they are treated as
2397
+ // class names for 1.x compat.
2398
+ if (target.match(/^[a-z][\w-]*$/i)) {
2399
+ target = '.' + target;
2400
+ }
2401
+
2402
+ if (cell.is( target )) {
2403
+ fn( k, def );
2404
+ }
2403
2405
  }
2404
2406
  });
2405
2407
  }
@@ -3213,11 +3215,15 @@ function _fnHeaderLayout( settings, source, incColumns )
3213
3215
  colspan++;
3214
3216
  }
3215
3217
 
3218
+ var titleSpan = $('span.dt-column-title', cell);
3219
+
3216
3220
  structure[row][column] = {
3217
3221
  cell: cell,
3218
3222
  colspan: colspan,
3219
3223
  rowspan: rowspan,
3220
- title: $('span.dt-column-title', cell).html()
3224
+ title: titleSpan.length
3225
+ ? titleSpan.html()
3226
+ : $(cell).html()
3221
3227
  };
3222
3228
  }
3223
3229
  }
@@ -4002,7 +4008,12 @@ function _fnBuildAjax( oSettings, data, fn )
4002
4008
  oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
4003
4009
  }
4004
4010
  else if (ajax.url === '') {
4005
- callback({});
4011
+ // No url, so don't load any data. Just apply an empty data array
4012
+ // to the object for the callback.
4013
+ var empty = {};
4014
+
4015
+ DataTable.util.set(ajax.dataSrc)(empty, []);
4016
+ callback(empty);
4006
4017
  }
4007
4018
  else {
4008
4019
  // Object to extend the base settings
@@ -5004,12 +5015,12 @@ function _fnScrollDraw ( settings )
5004
5015
  // the content of the cell so that the width applied to the header and body
5005
5016
  // both match, but we want to hide it completely.
5006
5017
  $('th, td', headerCopy).each(function () {
5007
- $(this).children().wrapAll('<div class="dt-scroll-sizing">');
5018
+ $(this.childNodes).wrapAll('<div class="dt-scroll-sizing">');
5008
5019
  });
5009
5020
 
5010
5021
  if ( footer ) {
5011
5022
  $('th, td', footerCopy).each(function () {
5012
- $(this).children().wrapAll('<div class="dt-scroll-sizing">');
5023
+ $(this.childNodes).wrapAll('<div class="dt-scroll-sizing">');
5013
5024
  });
5014
5025
  }
5015
5026
 
@@ -5364,34 +5375,41 @@ function _fnSortInit( settings ) {
5364
5375
 
5365
5376
  function _fnSortAttachListener(settings, node, selector, column, callback) {
5366
5377
  _fnBindAction( node, selector, function (e) {
5378
+ var run = false;
5367
5379
  var columns = column === undefined
5368
5380
  ? _fnColumnsFromHeader( e.target )
5369
5381
  : [column];
5370
5382
 
5371
5383
  if ( columns.length ) {
5372
- _fnProcessingDisplay( settings, true );
5384
+ for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
5385
+ var ret = _fnSortAdd( settings, columns[i], i, e.shiftKey );
5373
5386
 
5374
- // Allow the processing display to show
5375
- setTimeout( function () {
5376
- for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
5377
- _fnSortAdd( settings, columns[i], i, e.shiftKey );
5387
+ if (ret !== false) {
5388
+ run = true;
5389
+ }
5378
5390
 
5379
- // If the first entry is no sort, then subsequent
5380
- // sort columns are ignored
5381
- if (settings.aaSorting.length === 1 && settings.aaSorting[0][1] === '') {
5382
- break;
5383
- }
5391
+ // If the first entry is no sort, then subsequent
5392
+ // sort columns are ignored
5393
+ if (settings.aaSorting.length === 1 && settings.aaSorting[0][1] === '') {
5394
+ break;
5384
5395
  }
5396
+ }
5385
5397
 
5386
- _fnSort( settings );
5387
- _fnSortDisplay( settings );
5388
- _fnReDraw( settings, false, false );
5389
- _fnProcessingDisplay( settings, false );
5398
+ if (run) {
5399
+ _fnProcessingDisplay( settings, true );
5390
5400
 
5391
- if (callback) {
5392
- callback();
5393
- }
5394
- }, 0);
5401
+ // Allow the processing display to show
5402
+ setTimeout( function () {
5403
+ _fnSort( settings );
5404
+ _fnSortDisplay( settings );
5405
+ _fnReDraw( settings, false, false );
5406
+ _fnProcessingDisplay( settings, false );
5407
+
5408
+ if (callback) {
5409
+ callback();
5410
+ }
5411
+ }, 0);
5412
+ }
5395
5413
  }
5396
5414
  } );
5397
5415
  }
@@ -5695,7 +5713,7 @@ function _fnSortAdd ( settings, colIdx, addIndex, shift )
5695
5713
  };
5696
5714
 
5697
5715
  if ( ! col.bSortable ) {
5698
- return;
5716
+ return false;
5699
5717
  }
5700
5718
 
5701
5719
  // Convert to 2D array if needed
@@ -8020,7 +8038,7 @@ var __details_events = function ( settings )
8020
8038
  for ( var i=0, ien=data.length ; i<ien ; i++ ) {
8021
8039
  row = data[i];
8022
8040
 
8023
- if ( row._details ) {
8041
+ if ( row && row._details ) {
8024
8042
  row._details.each(function () {
8025
8043
  var el = $(this).children('td');
8026
8044
 
@@ -8039,7 +8057,7 @@ var __details_events = function ( settings )
8039
8057
  }
8040
8058
 
8041
8059
  for ( var i=0, ien=data.length ; i<ien ; i++ ) {
8042
- if ( data[i]._details ) {
8060
+ if ( data[i] && data[i]._details ) {
8043
8061
  __details_remove( api, i );
8044
8062
  }
8045
8063
  }
@@ -8061,9 +8079,9 @@ _api_register( _child_mth, function ( data, klass ) {
8061
8079
 
8062
8080
  if ( data === undefined ) {
8063
8081
  // get
8064
- return ctx.length && this.length ?
8065
- ctx[0].aoData[ this[0] ]._details :
8066
- undefined;
8082
+ return ctx.length && this.length && ctx[0].aoData[ this[0] ]
8083
+ ? ctx[0].aoData[ this[0] ]._details
8084
+ : undefined;
8067
8085
  }
8068
8086
  else if ( data === true ) {
8069
8087
  // show
@@ -9487,7 +9505,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9487
9505
  * @type string
9488
9506
  * @default Version number
9489
9507
  */
9490
- DataTable.version = "2.0.1";
9508
+ DataTable.version = "2.0.2";
9491
9509
 
9492
9510
  /**
9493
9511
  * Private data store, containing all of the settings objects that are
@@ -12623,7 +12641,7 @@ DataTable.type = function (name, prop, val) {
12623
12641
  };
12624
12642
 
12625
12643
  // prop is optional
12626
- if (! val) {
12644
+ if (val === undefined) {
12627
12645
  val = prop;
12628
12646
  prop = null;
12629
12647
  }
@@ -13282,7 +13300,7 @@ function _pagingDraw(settings, host, opts) {
13282
13300
  if (
13283
13301
  buttonEls.length && // any buttons
13284
13302
  opts.numbers > 1 && // prevent infinite
13285
- $(host).outerHeight() >= ($(buttonEls[0]).outerHeight() * 2) - 10
13303
+ $(host).height() >= ($(buttonEls[0]).outerHeight() * 2) - 10
13286
13304
  ) {
13287
13305
  _pagingDraw(settings, host, $.extend({}, opts, { numbers: opts.numbers - 2 }));
13288
13306
  }
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.0.1",
7
+ "version": "2.0.2",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",