datatables.net 2.0.0 → 2.0.1

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.0
1
+ /*! DataTables 2.0.1
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -2376,12 +2376,18 @@ function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, headerLayout, fn )
2376
2376
  else if ( typeof target === 'string' )
2377
2377
  {
2378
2378
  for ( k=0, kLen=columns.length ; k<kLen ; k++ ) {
2379
- if (target.indexOf(':name') !== -1) {
2379
+ if (target === '_all') {
2380
+ // Apply to all columns
2381
+ fn( k, def );
2382
+ }
2383
+ else if (target.indexOf(':name') !== -1) {
2384
+ // Column selector
2380
2385
  if (columns[k].sName === target.replace(':name', '')) {
2381
2386
  fn( k, def );
2382
2387
  }
2383
2388
  }
2384
2389
  else {
2390
+ // Cell selector
2385
2391
  headerLayout.forEach(function (row) {
2386
2392
  var cell = $(row[k].cell);
2387
2393
 
@@ -2392,7 +2398,7 @@ function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, headerLayout, fn )
2392
2398
  target = '.' + target;
2393
2399
  }
2394
2400
 
2395
- if (target === '_all' || cell.is( target )) {
2401
+ if (cell.is( target )) {
2396
2402
  fn( k, def );
2397
2403
  }
2398
2404
  });
@@ -2977,7 +2983,7 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
2977
2983
  for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
2978
2984
  {
2979
2985
  oCol = oSettings.aoColumns[i];
2980
- create = nTrIn ? false : true;
2986
+ create = nTrIn && anTds[i] ? false : true;
2981
2987
 
2982
2988
  nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
2983
2989
 
@@ -3006,11 +3012,11 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
3006
3012
  }
3007
3013
 
3008
3014
  // Visibility - add or remove as required
3009
- if ( oCol.bVisible && ! nTrIn )
3015
+ if ( oCol.bVisible && create )
3010
3016
  {
3011
3017
  nTr.appendChild( nTd );
3012
3018
  }
3013
- else if ( ! oCol.bVisible && nTrIn )
3019
+ else if ( ! oCol.bVisible && ! create )
3014
3020
  {
3015
3021
  nTd.parentNode.removeChild( nTd );
3016
3022
  }
@@ -3094,14 +3100,23 @@ function _fnBuildHead( settings, side )
3094
3100
  }
3095
3101
 
3096
3102
  // If no cells yet and we have content for them, then create
3097
- if ( $('th, td', target).length === 0 && (side === 'header' || _pluck(settings.aoColumns, titleProp).join('')) ) {
3098
- row = $('<tr/>')
3099
- .appendTo( target );
3103
+ if (side === 'header' || _pluck(settings.aoColumns, titleProp).join('')) {
3104
+ row = $('tr', target);
3105
+
3106
+ // Add a row if needed
3107
+ if (! row.length) {
3108
+ row = $('<tr/>').appendTo(target)
3109
+ }
3100
3110
 
3101
- for ( i=0, ien=columns.length ; i<ien ; i++ ) {
3102
- $('<th/>')
3103
- .html( columns[i][titleProp] || '' )
3104
- .appendTo( row );
3111
+ // Add the number of cells needed to make up to the number of columns
3112
+ if (row.length === 1) {
3113
+ var cells = $('td, th', row);
3114
+
3115
+ for ( i=cells.length, ien=columns.length ; i<ien ; i++ ) {
3116
+ $('<th/>')
3117
+ .html( columns[i][titleProp] || '' )
3118
+ .appendTo( row );
3119
+ }
3105
3120
  }
3106
3121
  }
3107
3122
 
@@ -3409,8 +3424,10 @@ function _emptyRow ( settings ) {
3409
3424
  var zero = oLang.sZeroRecords;
3410
3425
  var dataSrc = _fnDataSource( settings );
3411
3426
 
3412
- if ( settings.iDraw <= 1 && (dataSrc === 'ajax' || dataSrc === 'ssp') )
3413
- {
3427
+ if (
3428
+ (settings.iDraw < 1 && dataSrc === 'ssp') ||
3429
+ (settings.iDraw <= 1 && dataSrc === 'ajax')
3430
+ ) {
3414
3431
  zero = oLang.sLoadingRecords;
3415
3432
  }
3416
3433
  else if ( oLang.sEmptyTable && settings.fnRecordsTotal() === 0 )
@@ -3456,30 +3473,34 @@ function _layoutArray ( settings, layout, side )
3456
3473
  'full' :
3457
3474
  splitPos[1].toLowerCase();
3458
3475
  var group = groups[ splitPos[0] ];
3459
-
3460
- // Transform to an object with a contents property
3461
- if ( $.isPlainObject( val ) ) {
3462
- // Already a group from a previous pass
3463
- if (val.contents) {
3464
- group[ align ] = val;
3476
+ var groupRun = function (contents, innerVal) {
3477
+ // If it is an object, then there can be multiple features contained in it
3478
+ if ( $.isPlainObject( innerVal ) ) {
3479
+ Object.keys(innerVal).map(function (key) {
3480
+ contents.push( {
3481
+ feature: key,
3482
+ opts: innerVal[key]
3483
+ });
3484
+ });
3465
3485
  }
3466
3486
  else {
3467
- // For objects, each property becomes an entry in the contents
3468
- // array for this insert position
3469
- group[ align ] = {
3470
- contents: Object.keys(val).map(function (key) {
3471
- return {
3472
- feature: key,
3473
- opts: val[key]
3474
- };
3475
- })
3476
- };
3487
+ contents.push(innerVal);
3488
+ }
3489
+ }
3490
+
3491
+ // Transform to an object with a contents property
3492
+ if (! group[align] || ! group[align].contents) {
3493
+ group[align] = { contents: [] };
3494
+ }
3495
+
3496
+ // Allow for an array or just a single object
3497
+ if ( Array.isArray(val)) {
3498
+ for (var i=0 ; i<val.length ; i++) {
3499
+ groupRun(group[align].contents, val[i]);
3477
3500
  }
3478
3501
  }
3479
3502
  else {
3480
- group[ align ] = {
3481
- contents: val
3482
- };
3503
+ groupRun(group[ align ].contents, val);
3483
3504
  }
3484
3505
 
3485
3506
  // And make contents an array
@@ -4360,6 +4381,9 @@ function _fnFilterCreateSearch( search, inOpts )
4360
4381
  search = search.toString();
4361
4382
  }
4362
4383
 
4384
+ // Remove diacritics if normalize is set up to do so
4385
+ search = _normalize(search);
4386
+
4363
4387
  if (options.exact) {
4364
4388
  return new RegExp(
4365
4389
  '^'+_fnEscapeRegex(search)+'$',
@@ -5350,9 +5374,13 @@ function _fnSortAttachListener(settings, node, selector, column, callback) {
5350
5374
  // Allow the processing display to show
5351
5375
  setTimeout( function () {
5352
5376
  for ( var i=0, ien=columns.length ; i<ien ; i++ ) {
5353
- var append = e.shiftKey || i > 0;
5354
-
5355
- _fnSortAdd( settings, columns[i], append );
5377
+ _fnSortAdd( settings, columns[i], i, e.shiftKey );
5378
+
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
+ }
5356
5384
  }
5357
5385
 
5358
5386
  _fnSort( settings );
@@ -5375,9 +5403,23 @@ function _fnSortAttachListener(settings, node, selector, column, callback) {
5375
5403
  function _fnSortDisplay(settings) {
5376
5404
  var display = settings.aiDisplay;
5377
5405
  var master = settings.aiDisplayMaster;
5406
+ var masterMap = {};
5407
+ var map = {};
5408
+ var i;
5378
5409
 
5379
- display.sort(function(a, b){
5380
- return master.indexOf(a) - master.indexOf(b);
5410
+ // Rather than needing an `indexOf` on master array, we can create a map
5411
+ for (i=0 ; i<master.length ; i++) {
5412
+ masterMap[master[i]] = i;
5413
+ }
5414
+
5415
+ // And then cache what would be the indexOf fom the display
5416
+ for (i=0 ; i<display.length ; i++) {
5417
+ map[display[i]] = masterMap[display[i]];
5418
+ }
5419
+
5420
+ display.sort(function(a, b){
5421
+ // Short version of this function is simply `master.indexOf(a) - master.indexOf(b);`
5422
+ return map[a] - map[b];
5381
5423
  });
5382
5424
  }
5383
5425
 
@@ -5628,12 +5670,12 @@ function _fnSort ( oSettings, col, dir )
5628
5670
  * @param {object} settings dataTables settings object
5629
5671
  * @param {node} attachTo node to attach the handler to
5630
5672
  * @param {int} colIdx column sorting index
5631
- * @param {boolean} [append=false] Append the requested sort to the existing
5632
- * sort if true (i.e. multi-column sort)
5673
+ * @param {int} addIndex Counter
5674
+ * @param {boolean} [shift=false] Shift click add
5633
5675
  * @param {function} [callback] callback function
5634
5676
  * @memberof DataTable#oApi
5635
5677
  */
5636
- function _fnSortAdd ( settings, colIdx, append )
5678
+ function _fnSortAdd ( settings, colIdx, addIndex, shift )
5637
5679
  {
5638
5680
  var col = settings.aoColumns[ colIdx ];
5639
5681
  var sorting = settings.aaSorting;
@@ -5662,7 +5704,7 @@ function _fnSortAdd ( settings, colIdx, append )
5662
5704
  }
5663
5705
 
5664
5706
  // If appending the sort then we are multi-column sorting
5665
- if ( append && settings.oFeatures.bSortMulti ) {
5707
+ if ( (shift || addIndex) && settings.oFeatures.bSortMulti ) {
5666
5708
  // Are we already doing some kind of sort on this column?
5667
5709
  var sortIdx = _pluck(sorting, '0').indexOf(colIdx);
5668
5710
 
@@ -5682,11 +5724,18 @@ function _fnSortAdd ( settings, colIdx, append )
5682
5724
  sorting[sortIdx]._idx = nextSortIdx;
5683
5725
  }
5684
5726
  }
5685
- else {
5686
- // No sort on this column yet
5727
+ else if (shift) {
5728
+ // No sort on this column yet, being added by shift click
5729
+ // add it as itself
5687
5730
  sorting.push( [ colIdx, asSorting[0], 0 ] );
5688
5731
  sorting[sorting.length-1]._idx = 0;
5689
5732
  }
5733
+ else {
5734
+ // No sort on this column yet, being added from a colspan
5735
+ // so add with same direction as first column
5736
+ sorting.push( [ colIdx, sorting[0][1], 0 ] );
5737
+ sorting[sorting.length-1]._idx = 0;
5738
+ }
5690
5739
  }
5691
5740
  else if ( sorting.length && sorting[0][0] == colIdx ) {
5692
5741
  // Single column - already sorting on this column, modify the sort
@@ -9337,6 +9386,8 @@ _api_register( 'destroy()', function ( remove ) {
9337
9386
  jqTable.append( tfoot );
9338
9387
  }
9339
9388
 
9389
+ settings.colgroup.remove();
9390
+
9340
9391
  settings.aaSorting = [];
9341
9392
  settings.aaSortingFixed = [];
9342
9393
  _fnSortingClasses( settings );
@@ -9436,7 +9487,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9436
9487
  * @type string
9437
9488
  * @default Version number
9438
9489
  */
9439
- DataTable.version = "2.0.0";
9490
+ DataTable.version = "2.0.1";
9440
9491
 
9441
9492
  /**
9442
9493
  * Private data store, containing all of the settings objects that are
@@ -12181,7 +12232,7 @@ $.extend( true, DataTable.ext.renderer, {
12181
12232
  } );
12182
12233
 
12183
12234
  // Common function to remove new lines, strip HTML and diacritic control
12184
- var _filterString = function (stripHtml, diacritics) {
12235
+ var _filterString = function (stripHtml, normalize) {
12185
12236
  return function (str) {
12186
12237
  if (_empty(str) || typeof str !== 'string') {
12187
12238
  return str;
@@ -12193,8 +12244,8 @@ var _filterString = function (stripHtml, diacritics) {
12193
12244
  str = _stripHtml(str);
12194
12245
  }
12195
12246
 
12196
- if (diacritics) {
12197
- str = _normalize(str, true);
12247
+ if (normalize) {
12248
+ str = _normalize(str, false);
12198
12249
  }
12199
12250
 
12200
12251
  return str;
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.0",
7
+ "version": "2.0.1",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",