Skip to content

Commit

Permalink
Core: Update external header icons on sort. Fixes #1483
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Nov 25, 2017
1 parent b856688 commit 85d5cdc
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions js/jquery.tablesorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,15 @@
css = [ ts.css.sortAsc + ' ' + c.cssAsc, ts.css.sortDesc + ' ' + c.cssDesc ],
cssIcon = [ c.cssIconAsc, c.cssIconDesc, c.cssIconNone ],
aria = [ 'ascending', 'descending' ],
updateColumnSort = function($el, index) {
$el
.removeClass( none )
.addClass( css[ index ] )
.attr( 'aria-sort', aria[ index ] )
.find( '.' + ts.css.icon )
.removeClass( cssIcon[ 2 ] )
.addClass( cssIcon[ index ] );
},
// find the footer
$extras = c.$table
.find( 'tfoot tr' )
Expand Down Expand Up @@ -1134,26 +1143,18 @@
$sorted = $sorted
.not( '.sorter-false' )
.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) );
if ( $extras.length ) {
}
if ( $sorted.length ) {
for ( column = 0; column < $sorted.length; column++ ) {
if ( !$sorted[ column ].sortDisabled ) {
$sorted
.eq( column )
.removeClass( none )
.addClass( css[ list[ indx ][ 1 ] ] )
.attr( 'aria-sort', aria[ list[ indx ][ 1 ] ] )
.find( '.' + ts.css.icon )
.removeClass( cssIcon[ 2 ] )
.addClass( cssIcon[ list[ indx ][ 1 ] ] );
updateColumnSort( $sorted.eq( column ) , list[ indx ][ 1 ] );
}
}
// add sorted class to footer & extra headers, if they exist
if ( $extras.length ) {
$extras
.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' )
.removeClass( none )
.addClass( css[ list[ indx ][ 1 ] ] );
}
}
// add sorted class to footer & extra headers, if they exist
if ( $extras.length ) {
updateColumnSort( $extras.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ), list[ indx ][ 1 ] );
}
}
}
Expand Down

0 comments on commit 85d5cdc

Please sign in to comment.