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.js CHANGED
@@ -1,11 +1,11 @@
1
- /*! DataTables 2.0.1
1
+ /*! DataTables 2.0.2
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.0.1
8
+ * @version 2.0.2
9
9
  * @author SpryMedia Ltd
10
10
  * @contact www.datatables.net
11
11
  * @copyright SpryMedia Ltd.
@@ -317,7 +317,7 @@
317
317
  _fnCamelToHungarian( defaults.oLanguage, json );
318
318
  $.extend( true, oLanguage, json, oSettings.oInit.oLanguage );
319
319
 
320
- _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
320
+ _fnCallbackFire( oSettings, null, 'i18n', [oSettings], true);
321
321
  _fnInitialise( oSettings );
322
322
  },
323
323
  error: function () {
@@ -2355,7 +2355,7 @@
2355
2355
  */
2356
2356
  function _columnAutoClass(container, colIdx, className) {
2357
2357
  container.forEach(function (row) {
2358
- if (row[colIdx].unique) {
2358
+ if (row[colIdx] && row[colIdx].unique) {
2359
2359
  _addClass(row[colIdx].cell, className);
2360
2360
  }
2361
2361
  });
@@ -2442,17 +2442,19 @@
2442
2442
  else {
2443
2443
  // Cell selector
2444
2444
  headerLayout.forEach(function (row) {
2445
- var cell = $(row[k].cell);
2446
-
2447
- // Legacy support. Note that it means that we don't support
2448
- // an element name selector only, since they are treated as
2449
- // class names for 1.x compat.
2450
- if (target.match(/^[a-z][\w-]*$/i)) {
2451
- target = '.' + target;
2452
- }
2453
-
2454
- if (cell.is( target )) {
2455
- fn( k, def );
2445
+ if (row[k]) {
2446
+ var cell = $(row[k].cell);
2447
+
2448
+ // Legacy support. Note that it means that we don't support
2449
+ // an element name selector only, since they are treated as
2450
+ // class names for 1.x compat.
2451
+ if (target.match(/^[a-z][\w-]*$/i)) {
2452
+ target = '.' + target;
2453
+ }
2454
+
2455
+ if (cell.is( target )) {
2456
+ fn( k, def );
2457
+ }
2456
2458
  }
2457
2459
  });
2458
2460
  }
@@ -3266,11 +3268,15 @@
3266
3268
  colspan++;
3267
3269
  }
3268
3270
 
3271
+ var titleSpan = $('span.dt-column-title', cell);
3272
+
3269
3273
  structure[row][column] = {
3270
3274
  cell: cell,
3271
3275
  colspan: colspan,
3272
3276
  rowspan: rowspan,
3273
- title: $('span.dt-column-title', cell).html()
3277
+ title: titleSpan.length
3278
+ ? titleSpan.html()
3279
+ : $(cell).html()
3274
3280
  };
3275
3281
  }
3276
3282
  }
@@ -4055,7 +4061,12 @@
4055
4061
  oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
4056
4062
  }
4057
4063
  else if (ajax.url === '') {
4058
- callback({});
4064
+ // No url, so don't load any data. Just apply an empty data array
4065
+ // to the object for the callback.
4066
+ var empty = {};
4067
+
4068
+ DataTable.util.set(ajax.dataSrc)(empty, []);
4069
+ callback(empty);
4059
4070
  }
4060
4071
  else {
4061
4072
  // Object to extend the base settings
@@ -5057,12 +5068,12 @@
5057
5068
  // the content of the cell so that the width applied to the header and body
5058
5069
  // both match, but we want to hide it completely.
5059
5070
  $('th, td', headerCopy).each(function () {
5060
- $(this).children().wrapAll('<div class="dt-scroll-sizing">');
5071
+ $(this.childNodes).wrapAll('<div class="dt-scroll-sizing">');
5061
5072
  });
5062
5073
 
5063
5074
  if ( footer ) {
5064
5075
  $('th, td', footerCopy).each(function () {
5065
- $(this).children().wrapAll('<div class="dt-scroll-sizing">');
5076
+ $(this.childNodes).wrapAll('<div class="dt-scroll-sizing">');
5066
5077
  });
5067
5078
  }
5068
5079
 
@@ -5417,34 +5428,41 @@
5417
5428
 
5418
5429
  function _fnSortAttachListener(settings, node, selector, column, callback) {
5419
5430
  _fnBindAction( node, selector, function (e) {
5431
+ var run = false;
5420
5432
  var columns = column === undefined
5421
5433
  ? _fnColumnsFromHeader( e.target )
5422
5434
  : [column];
5423
5435
 
5424
5436
  if ( columns.length ) {
5425
- _fnProcessingDisplay( settings, true );
5437
+ for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
5438
+ var ret = _fnSortAdd( settings, columns[i], i, e.shiftKey );
5426
5439
 
5427
- // Allow the processing display to show
5428
- setTimeout( function () {
5429
- for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
5430
- _fnSortAdd( settings, columns[i], i, e.shiftKey );
5440
+ if (ret !== false) {
5441
+ run = true;
5442
+ }
5431
5443
 
5432
- // If the first entry is no sort, then subsequent
5433
- // sort columns are ignored
5434
- if (settings.aaSorting.length === 1 && settings.aaSorting[0][1] === '') {
5435
- break;
5436
- }
5444
+ // If the first entry is no sort, then subsequent
5445
+ // sort columns are ignored
5446
+ if (settings.aaSorting.length === 1 && settings.aaSorting[0][1] === '') {
5447
+ break;
5437
5448
  }
5449
+ }
5438
5450
 
5439
- _fnSort( settings );
5440
- _fnSortDisplay( settings );
5441
- _fnReDraw( settings, false, false );
5442
- _fnProcessingDisplay( settings, false );
5451
+ if (run) {
5452
+ _fnProcessingDisplay( settings, true );
5443
5453
 
5444
- if (callback) {
5445
- callback();
5446
- }
5447
- }, 0);
5454
+ // Allow the processing display to show
5455
+ setTimeout( function () {
5456
+ _fnSort( settings );
5457
+ _fnSortDisplay( settings );
5458
+ _fnReDraw( settings, false, false );
5459
+ _fnProcessingDisplay( settings, false );
5460
+
5461
+ if (callback) {
5462
+ callback();
5463
+ }
5464
+ }, 0);
5465
+ }
5448
5466
  }
5449
5467
  } );
5450
5468
  }
@@ -5748,7 +5766,7 @@
5748
5766
  };
5749
5767
 
5750
5768
  if ( ! col.bSortable ) {
5751
- return;
5769
+ return false;
5752
5770
  }
5753
5771
 
5754
5772
  // Convert to 2D array if needed
@@ -8073,7 +8091,7 @@
8073
8091
  for ( var i=0, ien=data.length ; i<ien ; i++ ) {
8074
8092
  row = data[i];
8075
8093
 
8076
- if ( row._details ) {
8094
+ if ( row && row._details ) {
8077
8095
  row._details.each(function () {
8078
8096
  var el = $(this).children('td');
8079
8097
 
@@ -8092,7 +8110,7 @@
8092
8110
  }
8093
8111
 
8094
8112
  for ( var i=0, ien=data.length ; i<ien ; i++ ) {
8095
- if ( data[i]._details ) {
8113
+ if ( data[i] && data[i]._details ) {
8096
8114
  __details_remove( api, i );
8097
8115
  }
8098
8116
  }
@@ -8114,9 +8132,9 @@
8114
8132
 
8115
8133
  if ( data === undefined ) {
8116
8134
  // get
8117
- return ctx.length && this.length ?
8118
- ctx[0].aoData[ this[0] ]._details :
8119
- undefined;
8135
+ return ctx.length && this.length && ctx[0].aoData[ this[0] ]
8136
+ ? ctx[0].aoData[ this[0] ]._details
8137
+ : undefined;
8120
8138
  }
8121
8139
  else if ( data === true ) {
8122
8140
  // show
@@ -9540,7 +9558,7 @@
9540
9558
  * @type string
9541
9559
  * @default Version number
9542
9560
  */
9543
- DataTable.version = "2.0.1";
9561
+ DataTable.version = "2.0.2";
9544
9562
 
9545
9563
  /**
9546
9564
  * Private data store, containing all of the settings objects that are
@@ -12676,7 +12694,7 @@
12676
12694
  };
12677
12695
 
12678
12696
  // prop is optional
12679
- if (! val) {
12697
+ if (val === undefined) {
12680
12698
  val = prop;
12681
12699
  prop = null;
12682
12700
  }
@@ -13335,7 +13353,7 @@
13335
13353
  if (
13336
13354
  buttonEls.length && // any buttons
13337
13355
  opts.numbers > 1 && // prevent infinite
13338
- $(host).outerHeight() >= ($(buttonEls[0]).outerHeight() * 2) - 10
13356
+ $(host).height() >= ($(buttonEls[0]).outerHeight() * 2) - 10
13339
13357
  ) {
13340
13358
  _pagingDraw(settings, host, $.extend({}, opts, { numbers: opts.numbers - 2 }));
13341
13359
  }