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 ], css = [ ts.css.sortAsc + ' ' + c.cssAsc, ts.css.sortDesc + ' ' + c.cssDesc ],
cssIcon = [ c.cssIconAsc, c.cssIconDesc, c.cssIconNone ], cssIcon = [ c.cssIconAsc, c.cssIconDesc, c.cssIconNone ],
aria = [ 'ascending', 'descending' ], 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 // find the footer
$extras = c.$table $extras = c.$table
.find( 'tfoot tr' ) .find( 'tfoot tr' )
@ -1134,26 +1143,18 @@
$sorted = $sorted $sorted = $sorted
.not( '.sorter-false' ) .not( '.sorter-false' )
.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) ); .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) );
if ( $extras.length ) {
}
if ( $sorted.length ) { if ( $sorted.length ) {
for ( column = 0; column < $sorted.length; column++ ) { for ( column = 0; column < $sorted.length; column++ ) {
if ( !$sorted[ column ].sortDisabled ) { if ( !$sorted[ column ].sortDisabled ) {
$sorted updateColumnSort( $sorted.eq( column ) , list[ indx ][ 1 ] );
.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 ] ] );
} }
} }
// add sorted class to footer & extra headers, if they exist }
if ( $extras.length ) { // add sorted class to footer & extra headers, if they exist
$extras if ( $extras.length ) {
.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ) updateColumnSort( $extras.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ), list[ indx ][ 1 ] );
.removeClass( none )
.addClass( css[ list[ indx ][ 1 ] ] );
}
} }
} }
} }