datatables.net 2.1.0 → 2.1.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.1.0
1
+ /*! DataTables 2.1.2
2
2
  * © SpryMedia Ltd - datatables.net/license
3
3
  */
4
4
 
@@ -4689,14 +4689,16 @@ function _fnInitialise ( settings )
4689
4689
  return;
4690
4690
  }
4691
4691
 
4692
- /* Build and draw the header / footer for the table */
4692
+ // Build the header / footer for the table
4693
4693
  _fnBuildHead( settings, 'header' );
4694
4694
  _fnBuildHead( settings, 'footer' );
4695
- _fnDrawHead( settings, settings.aoHeader );
4696
- _fnDrawHead( settings, settings.aoFooter );
4697
4695
 
4698
- // Load the table's state (if needed) and then render around it and draw draw
4696
+ // Load the table's state (if needed) and then render around it and draw
4699
4697
  _fnLoadState( settings, init, function () {
4698
+ // Then draw the header / footer
4699
+ _fnDrawHead( settings, settings.aoHeader );
4700
+ _fnDrawHead( settings, settings.aoFooter );
4701
+
4700
4702
  // Local data load
4701
4703
  // Check if there is data passing into the constructor
4702
4704
  if ( init.aaData ) {
@@ -9749,7 +9751,7 @@ _api_register( 'i18n()', function ( token, def, plural ) {
9749
9751
  * @type string
9750
9752
  * @default Version number
9751
9753
  */
9752
- DataTable.version = "2.1.0";
9754
+ DataTable.version = "2.1.2";
9753
9755
 
9754
9756
  /**
9755
9757
  * Private data store, containing all of the settings objects that are
@@ -12676,6 +12678,7 @@ $.extend( true, DataTable.ext.renderer, {
12676
12678
  return; // table, not a nested one
12677
12679
  }
12678
12680
 
12681
+ var i;
12679
12682
  var orderClasses = classes.order;
12680
12683
  var columns = ctx.api.columns( cell );
12681
12684
  var col = settings.aoColumns[columns.flatten()[0]];
@@ -12684,14 +12687,7 @@ $.extend( true, DataTable.ext.renderer, {
12684
12687
  var indexes = columns.indexes();
12685
12688
  var sortDirs = columns.orderable(true).flatten();
12686
12689
  var sorting = ctx.sortDetails;
12687
- var orderedColumns = ',' + sorting
12688
- .filter( function (sort) {
12689
- // Filter to just the visible columns
12690
- return ctx.aoColumns[sort.col].bVisible;
12691
- } )
12692
- .map( function (sort) {
12693
- return sort.col;
12694
- } ).join(',') + ',';
12690
+ var orderedColumns = _pluck(sorting, 'col');
12695
12691
 
12696
12692
  cell
12697
12693
  .removeClass(
@@ -12702,10 +12698,17 @@ $.extend( true, DataTable.ext.renderer, {
12702
12698
  .toggleClass( orderClasses.canAsc, orderable && sortDirs.includes('asc') )
12703
12699
  .toggleClass( orderClasses.canDesc, orderable && sortDirs.includes('desc') );
12704
12700
 
12705
- // Get the index of this cell in the sort array
12706
- var sortIdx = orderedColumns.indexOf( ',' + indexes.toArray().join(',') + ',' );
12701
+ // Determine if all of the columns that this cell covers are included in the
12702
+ // current ordering
12703
+ var isOrdering = true;
12704
+
12705
+ for (i=0; i<indexes.length; i++) {
12706
+ if (! orderedColumns.includes(indexes[i])) {
12707
+ isOrdering = false;
12708
+ }
12709
+ }
12707
12710
 
12708
- if ( sortIdx !== -1 ) {
12711
+ if ( isOrdering ) {
12709
12712
  // Get the ordering direction for the columns under this cell
12710
12713
  // Note that it is possible for a cell to be asc and desc sorting
12711
12714
  // (column spanning cells)
@@ -12717,8 +12720,19 @@ $.extend( true, DataTable.ext.renderer, {
12717
12720
  );
12718
12721
  }
12719
12722
 
12720
- // The ARIA spec says that only one column should be marked with aria-sort
12721
- if ( sortIdx === 0 ) {
12723
+ // Find the first visible column that has ordering applied to it - it get's
12724
+ // the aria information, as the ARIA spec says that only one column should
12725
+ // be marked with aria-sort
12726
+ var firstVis = -1; // column index
12727
+
12728
+ for (i=0; i<orderedColumns.length; i++) {
12729
+ if (settings.aoColumns[orderedColumns[i]].bVisible) {
12730
+ firstVis = orderedColumns[i];
12731
+ break;
12732
+ }
12733
+ }
12734
+
12735
+ if (indexes[0] == firstVis) {
12722
12736
  var firstSort = sorting[0];
12723
12737
  var sortOrder = col.asSorting;
12724
12738
 
@@ -12736,6 +12750,7 @@ $.extend( true, DataTable.ext.renderer, {
12736
12750
  : col.ariaTitle
12737
12751
  );
12738
12752
 
12753
+ // Make the headers tab-able for keyboard navigation
12739
12754
  if (orderable) {
12740
12755
  cell.find('.dt-column-title').attr('role', 'button');
12741
12756
  cell.attr('tabindex', 0)
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.1.0",
7
+ "version": "2.1.2",
8
8
  "files": [
9
9
  "js/**/*.js",
10
10
  "js/**/*.mjs",