* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
- * Depends on mw.config (wgDigitTransformTable, wgMonthNames, wgMonthNamesShort,
- * wgDefaultDateFormat, wgContentLanguage)
+ * Depends on mw.config (wgDigitTransformTable, wgDefaultDateFormat, wgContentLanguage)
+ * and mw.language.months.
+ *
* Uses 'tableSorterCollation' in mw.config (if available)
*/
/**
this.order = 0;
this.count = 0;
- if ( $( this ).is( '.unsortable' ) ) {
+ if ( $( this ).hasClass( table.config.unsortableClass ) ) {
this.sortDisabled = true;
}
if ( !this.sortDisabled ) {
- $( this ).addClass( table.config.cssHeader ).attr( 'title', msg[1] );
+ $( this )
+ .addClass( table.config.cssHeader )
+ .prop( 'tabIndex', 0 )
+ .attr( {
+ role: 'columnheader button',
+ title: msg[1]
+ } );
}
// add cell to headerList
var regex = [];
ts.monthNames = {};
- for ( var i = 1; i < 13; i++ ) {
- var name = mw.config.get( 'wgMonthNames' )[i].toLowerCase();
- ts.monthNames[name] = i;
+ for ( var i = 0; i < 12; i++ ) {
+ var name = mw.language.months.names[i].toLowerCase();
+ ts.monthNames[name] = i + 1;
regex.push( $.escapeRE( name ) );
- name = mw.config.get( 'wgMonthNamesShort' )[i].toLowerCase().replace( '.', '' );
- ts.monthNames[name] = i;
+ name = mw.language.months.genitive[i].toLowerCase().replace( '.', '' );
+ ts.monthNames[name] = i + 1;
+ regex.push( $.escapeRE( name ) );
+ name = mw.language.months.abbrev[i].toLowerCase();
+ ts.monthNames[name] = i + 1;
regex.push( $.escapeRE( name ) );
}
sortInitialOrder: 'asc',
sortMultiSortKey: 'shiftKey',
sortLocaleCompare: false,
+ unsortableClass: 'unsortable',
parsers: {},
widgets: [],
headers: {},
// Build headers
$headers = buildHeaders( table, sortMsg );
- // Grab and process locale settings
+ // Grab and process locale settings.
buildTransformTable();
buildDateTable();
- buildCollationTable();
// Precaching regexps can bring 10 fold
// performance improvements in some browsers.
function setupForFirstSort() {
firstTime = false;
+ // Defer buildCollationTable to first sort. As user and site scripts
+ // may customize tableSorterCollation but load after $.ready(), other
+ // scripts may call .tablesorter() before they have done the
+ // tableSorterCollation customizations.
+ buildCollationTable();
+
// Legacy fix of .sortbottoms
// Wrap them inside inside a tfoot (because that's what they actually want to be) &
// and put the <tfoot> at the end of the <table>
// Apply event handling to headers
// this is too big, perhaps break it out?
- $headers.filter( ':not(.unsortable)' ).click( function ( e ) {
- if ( e.target.nodeName.toLowerCase() === 'a' ) {
- // The user clicked on a link inside a table header
- // Do nothing and let the default link click action continue
+ $headers.not( '.' + table.config.unsortableClass ).on( 'keypress click', function ( e ) {
+ if ( e.type === 'click' && e.target.nodeName.toLowerCase() === 'a' ) {
+ // The user clicked on a link inside a table header.
+ // Do nothing and let the default link click action continue.
+ return true;
+ }
+
+ if ( e.type === 'keypress' && e.which !== 13 ) {
+ // Only handle keypresses on the "Enter" key.
return true;
}