jquery-tablesorter 1.19.1 → 1.19.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- /*! TableSorter (FORK) v2.24.3 *//*
1
+ /*! TableSorter (FORK) v2.24.4 *//*
2
2
  * Client-side table sorting with ease!
3
3
  * @requires jQuery v1.2.6+
4
4
  *
@@ -21,7 +21,7 @@
21
21
  'use strict';
22
22
  var ts = $.tablesorter = {
23
23
 
24
- version : '2.24.3',
24
+ version : '2.24.4',
25
25
 
26
26
  parsers : [],
27
27
  widgets : [],
@@ -139,12 +139,13 @@
139
139
 
140
140
  // labels applied to sortable headers for accessibility (aria) support
141
141
  language : {
142
- sortAsc : 'Ascending sort applied, ',
143
- sortDesc : 'Descending sort applied, ',
144
- sortNone : 'No sort applied, ',
145
- nextAsc : 'activate to apply an ascending sort',
146
- nextDesc : 'activate to apply a descending sort',
147
- nextNone : 'activate to remove the sort'
142
+ sortAsc : 'Ascending sort applied, ',
143
+ sortDesc : 'Descending sort applied, ',
144
+ sortNone : 'No sort applied, ',
145
+ sortDisabled : 'sorting is disabled',
146
+ nextAsc : 'activate to apply an ascending sort',
147
+ nextDesc : 'activate to apply a descending sort',
148
+ nextNone : 'activate to remove the sort'
148
149
  },
149
150
 
150
151
  regex : {
@@ -993,7 +994,7 @@
993
994
  ▀████▀ ██ █████▀ ██ ██ ██ ██████
994
995
  */
995
996
  setHeadersCss : function( c ) {
996
- var $sorted, header, indx, column, $header, nextSort, txt, tmp,
997
+ var $sorted, indx, column,
997
998
  list = c.sortList,
998
999
  len = list.length,
999
1000
  none = ts.css.sortNone + ' ' + c.cssNone,
@@ -1061,50 +1062,62 @@
1061
1062
  }
1062
1063
  // add verbose aria labels
1063
1064
  len = c.$headers.length;
1064
- $headers = c.$headers.not( '.sorter-false' );
1065
1065
  for ( indx = 0; indx < len; indx++ ) {
1066
- $header = $headers.eq( indx );
1067
- if ( $header.length ) {
1068
- header = $headers[ indx ];
1069
- column = parseInt( $header.attr( 'data-column' ), 10 );
1070
- nextSort = c.sortVars[ column ].order[ ( c.sortVars[ column ].count + 1 ) % ( c.sortReset ? 3 : 2 ) ];
1066
+ ts.setColumnAriaLabel( c, c.$headers.eq( indx ) );
1067
+ }
1068
+ },
1069
+
1070
+ // nextSort (optional), lets you disable next sort text
1071
+ setColumnAriaLabel : function( c, $header, nextSort ) {
1072
+ if ( $header.length ) {
1073
+ var column = parseInt( $header.attr( 'data-column' ), 10 ),
1071
1074
  tmp = $header.hasClass( ts.css.sortAsc ) ?
1072
1075
  'sortAsc' :
1073
- $header.hasClass( ts.css.sortDesc ) ? 'sortDesc' : 'sortNone';
1074
- txt = $.trim( $header.text() ) + ': ' +
1075
- ts.language[ tmp ] +
1076
- ts.language[ nextSort === 0 ? 'nextAsc' : nextSort === 1 ? 'nextDesc' : 'nextNone' ];
1077
- $header.attr( 'aria-label', txt );
1076
+ $header.hasClass( ts.css.sortDesc ) ? 'sortDesc' : 'sortNone',
1077
+ txt = $.trim( $header.text() ) + ': ' + ts.language[ tmp ];
1078
+ if ( $header.hasClass( 'sorter-false' ) || nextSort === false ) {
1079
+ txt += ts.language.sortDisabled;
1080
+ } else {
1081
+ nextSort = c.sortVars[ column ].order[ ( c.sortVars[ column ].count + 1 ) % ( c.sortReset ? 3 : 2 ) ];
1082
+ // if nextSort
1083
+ txt += ts.language[ nextSort === 0 ? 'nextAsc' : nextSort === 1 ? 'nextDesc' : 'nextNone' ];
1078
1084
  }
1085
+ $header.attr( 'aria-label', txt );
1079
1086
  }
1080
1087
  },
1081
1088
 
1082
1089
  updateHeader : function( c ) {
1083
- var index, isDisabled, $th, col,
1090
+ var index, isDisabled, $header, col,
1084
1091
  table = c.table,
1085
1092
  len = c.$headers.length;
1086
1093
  for ( index = 0; index < len; index++ ) {
1087
- $th = c.$headers.eq( index );
1094
+ $header = c.$headers.eq( index );
1088
1095
  col = ts.getColumnData( table, c.headers, index, true );
1089
1096
  // add 'sorter-false' class if 'parser-false' is set
1090
- isDisabled = ts.getData( $th, col, 'sorter' ) === 'false' || ts.getData( $th, col, 'parser' ) === 'false';
1091
- $th[ 0 ].sortDisabled = isDisabled;
1092
- $th[ isDisabled ? 'addClass' : 'removeClass' ]( 'sorter-false' ).attr( 'aria-disabled', '' + isDisabled );
1093
- // disable tab index on disabled cells
1094
- if ( c.tabIndex ) {
1095
- if ( isDisabled ) {
1096
- $th.removeAttr( 'tabindex' );
1097
- } else {
1098
- $th.attr( 'tabindex', '0' );
1099
- }
1097
+ isDisabled = ts.getData( $header, col, 'sorter' ) === 'false' || ts.getData( $header, col, 'parser' ) === 'false';
1098
+ ts.setColumnSort( c, $header, isDisabled );
1099
+ }
1100
+ },
1101
+
1102
+ setColumnSort : function( c, $header, isDisabled ) {
1103
+ var id = c.table.id;
1104
+ $header[ 0 ].sortDisabled = isDisabled;
1105
+ $header[ isDisabled ? 'addClass' : 'removeClass' ]( 'sorter-false' )
1106
+ .attr( 'aria-disabled', '' + isDisabled );
1107
+ // disable tab index on disabled cells
1108
+ if ( c.tabIndex ) {
1109
+ if ( isDisabled ) {
1110
+ $header.removeAttr( 'tabindex' );
1111
+ } else {
1112
+ $header.attr( 'tabindex', '0' );
1100
1113
  }
1101
- // aria-controls - requires table ID
1102
- if ( table.id ) {
1103
- if ( isDisabled ) {
1104
- $th.removeAttr( 'aria-controls' );
1105
- } else {
1106
- $th.attr( 'aria-controls', table.id );
1107
- }
1114
+ }
1115
+ // aria-controls - requires table ID
1116
+ if ( id ) {
1117
+ if ( isDisabled ) {
1118
+ $header.removeAttr( 'aria-controls' );
1119
+ } else {
1120
+ $header.attr( 'aria-controls', id );
1108
1121
  }
1109
1122
  }
1110
1123
  },
@@ -1402,13 +1415,12 @@
1402
1415
  event[ c.sortResetKey ] ? 2 : ( c.sortVars[ col ].count + 1 ) % ( c.sortReset ? 3 : 2 );
1403
1416
  // reset all sorts on non-current column - issue #30
1404
1417
  if ( c.sortRestart ) {
1405
- tmp = cell;
1406
1418
  for ( headerIndx = 0; headerIndx < len; headerIndx++ ) {
1407
1419
  $header = c.$headers.eq( headerIndx );
1420
+ tmp = parseInt( $header.attr( 'data-column' ), 10 );
1408
1421
  // only reset counts on columns that weren't just clicked on and if not included in a multisort
1409
- if ( $header[ 0 ] !== tmp &&
1410
- ( notMultiSort || $header.hasClass( ts.css.sortNone ) ) ) {
1411
- c.sortVars[ $header.attr( 'data-column' ) ].count = -1;
1422
+ if ( col !== tmp && ( notMultiSort || $header.hasClass( ts.css.sortNone ) ) ) {
1423
+ c.sortVars[ tmp ].count = -1;
1412
1424
  }
1413
1425
  }
1414
1426
  }
@@ -2167,14 +2179,14 @@
2167
2179
 
2168
2180
  // *** Process table ***
2169
2181
  // add processing indicator
2170
- isProcessing : function( $table, toggle, $ths ) {
2182
+ isProcessing : function( $table, toggle, $headers ) {
2171
2183
  $table = $( $table );
2172
2184
  var c = $table[ 0 ].config,
2173
2185
  // default to all headers
2174
- $header = $ths || $table.find( '.' + ts.css.header );
2186
+ $header = $headers || $table.find( '.' + ts.css.header );
2175
2187
  if ( toggle ) {
2176
- // don't use sortList if custom $ths used
2177
- if ( typeof $ths !== 'undefined' && c.sortList.length > 0 ) {
2188
+ // don't use sortList if custom $headers used
2189
+ if ( typeof $headers !== 'undefined' && c.sortList.length > 0 ) {
2178
2190
  // get headers from the sortList
2179
2191
  $header = $header.filter( function() {
2180
2192
  // get data-column from attr to keep compatibility with jQuery 1.2.6