Core: Update external header icons on sort. Fixes #1483

This commit is contained in:
Rob Garrison 2017-11-25 17:50:20 -06:00
parent b85668819e
commit 85d5cdcb18

View File

@ -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' )
@ -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 ] );
}
}
}