Core: Remove tabindex when sort is disabled

See http://stackoverflow.com/a/16827628/145346
This commit is contained in:
Rob Garrison 2015-10-03 22:11:02 -05:00
parent f540158ca7
commit abb5646eb1

View File

@ -513,19 +513,27 @@
}
function updateHeader(table) {
var index, s, $th, col,
var index, isDisabled, $th, col,
c = table.config,
len = c.$headers.length;
for ( index = 0; index < len; index++ ) {
$th = c.$headers.eq( index );
col = ts.getColumnData( table, c.headers, index, true );
// add 'sorter-false' class if 'parser-false' is set
s = ts.getData( $th, col, 'sorter' ) === 'false' || ts.getData( $th, col, 'parser' ) === 'false';
$th[0].sortDisabled = s;
$th[ s ? 'addClass' : 'removeClass' ]('sorter-false').attr('aria-disabled', '' + s);
isDisabled = ts.getData( $th, col, 'sorter' ) === 'false' || ts.getData( $th, col, 'parser' ) === 'false';
$th[0].sortDisabled = isDisabled;
$th[ isDisabled ? 'addClass' : 'removeClass' ]( 'sorter-false' ).attr( 'aria-disabled', '' + isDisabled );
// disable tab index on disabled cells
if ( c.tabIndex ) {
if ( isDisabled ) {
$th.removeAttr( 'tabindex' );
} else {
$th.attr( 'tabindex', '0' );
}
}
// aria-controls - requires table ID
if (table.id) {
if (s) {
if ( isDisabled ) {
$th.removeAttr('aria-controls');
} else {
$th.attr('aria-controls', table.id);