2 * TableSorter for MediaWiki
4 * Written 2011 Leo Koppelkamm
5 * Based on tablesorter.com plugin, written (c) 2007 Christian Bach.
7 * Dual licensed under the MIT and GPL licenses:
8 * http://www.opensource.org/licenses/mit-license.php
9 * http://www.gnu.org/licenses/gpl.html
11 * Depends on mw.config (wgDigitTransformTable, wgMonthNames, wgMonthNamesShort,
12 * wgDefaultDateFormat, wgContentLanguage)
13 * Uses 'tableSorterCollation' in mw.config (if available)
17 * @description Create a sortable table with multi-column sorting capabilitys
19 * @example $( 'table' ).tablesorter();
20 * @desc Create a simple tablesorter interface.
22 * @example $( 'table' ).tablesorter( { sortList: [ { 0: 'desc' }, { 1: 'asc' } ] } );
23 * @desc Create a tablesorter interface initially sorting on the first and second column.
25 * @option String cssHeader ( optional ) A string of the class name to be appended
26 * to sortable tr elements in the thead of the table. Default value:
29 * @option String cssAsc ( optional ) A string of the class name to be appended to
30 * sortable tr elements in the thead on a ascending sort. Default value:
33 * @option String cssDesc ( optional ) A string of the class name to be appended
34 * to sortable tr elements in the thead on a descending sort. Default
35 * value: "headerSortDown"
37 * @option String sortInitialOrder ( optional ) A string of the inital sorting
38 * order can be asc or desc. Default value: "asc"
40 * @option String sortMultisortKey ( optional ) A string of the multi-column sort
41 * key. Default value: "shiftKey"
43 * @option Boolean sortLocaleCompare ( optional ) Boolean flag indicating whatever
44 * to use String.localeCampare method or not. Set to false.
46 * @option Boolean cancelSelection ( optional ) Boolean flag indicating if
47 * tablesorter should cancel selection of the table headers text.
50 * @option Array sortList ( optional ) An array containing objects specifying sorting.
51 * By passing more than one object, multi-sorting will be applied. Object structure:
52 * { <Integer column index>: <String 'asc' or 'desc'> }
55 * @option Boolean debug ( optional ) Boolean flag indicating if tablesorter
56 * should display debuging information usefull for development.
58 * @event sortEnd.tablesorter: Triggered as soon as any sorting has been applied.
64 * @cat Plugins/Tablesorter
66 * @author Christian Bach/christian.bach@polyester.se
69 ( function ( $, mw
) {
70 /*jshint onevar:false */
77 /* Parser utility functions */
79 function getParserById( name
) {
80 var len
= parsers
.length
;
81 for ( var i
= 0; i
< len
; i
++ ) {
82 if ( parsers
[i
].id
.toLowerCase() === name
.toLowerCase() ) {
89 function getElementText( node
) {
90 var $node
= $( node
),
91 // Use data-sort-value attribute.
92 // Use data() instead of attr() so that live value changes
93 // are processed as well (bug 38152).
94 data
= $node
.data( 'sortValue' );
96 if ( data
!== null && data
!== undefined ) {
97 // Cast any numbers or other stuff to a string, methods
98 // like charAt, toLowerCase and split are expected.
99 return String( data
);
105 function getTextFromRowAndCellIndex( rows
, rowIndex
, cellIndex
) {
106 if ( rows
[rowIndex
] && rows
[rowIndex
].cells
[cellIndex
] ) {
107 return $.trim( getElementText( rows
[rowIndex
].cells
[cellIndex
] ) );
113 function detectParserForColumn( table
, rows
, cellIndex
) {
114 var l
= parsers
.length
,
116 // Start with 1 because 0 is the fallback parser
120 needed
= ( rows
.length
> 4 ) ? 5 : rows
.length
;
123 nodeValue
= getTextFromRowAndCellIndex( rows
, rowIndex
, cellIndex
);
124 if ( nodeValue
!== '') {
125 if ( parsers
[i
].is( nodeValue
, table
) ) {
128 if ( concurrent
>= needed
) {
129 // Confirmed the parser for multiple cells, let's return it
133 // Check next parser, reset rows
141 if ( rowIndex
> rows
.length
) {
148 // 0 is always the generic parser (text)
152 function buildParserCache( table
, $headers
) {
153 var rows
= table
.tBodies
[0].rows
,
159 var cells
= rows
[0].cells
,
163 for ( i
= 0; i
< len
; i
++ ) {
165 sortType
= $headers
.eq( i
).data( 'sortType' );
166 if ( sortType
!== undefined ) {
167 parser
= getParserById( sortType
);
170 if ( parser
=== false ) {
171 parser
= detectParserForColumn( table
, rows
, i
);
174 parsers
.push( parser
);
180 /* Other utility functions */
182 function buildCache( table
) {
183 var totalRows
= ( table
.tBodies
[0] && table
.tBodies
[0].rows
.length
) || 0,
184 totalCells
= ( table
.tBodies
[0].rows
[0] && table
.tBodies
[0].rows
[0].cells
.length
) || 0,
185 parsers
= table
.config
.parsers
,
191 for ( var i
= 0; i
< totalRows
; ++i
) {
193 // Add the table data to main data array
194 var $row
= $( table
.tBodies
[0].rows
[i
] ),
197 // if this is a child row, add it to the last row's children and
198 // continue to the next row
199 if ( $row
.hasClass( table
.config
.cssChildRow
) ) {
200 cache
.row
[cache
.row
.length
- 1] = cache
.row
[cache
.row
.length
- 1].add( $row
);
201 // go to the next for loop
205 cache
.row
.push( $row
);
207 for ( var j
= 0; j
< totalCells
; ++j
) {
208 cols
.push( parsers
[j
].format( getElementText( $row
[0].cells
[j
] ), table
, $row
[0].cells
[j
] ) );
211 cols
.push( cache
.normalized
.length
); // add position for rowCache
212 cache
.normalized
.push( cols
);
219 function appendToTable( table
, cache
) {
221 normalized
= cache
.normalized
,
222 totalRows
= normalized
.length
,
223 checkCell
= ( normalized
[0].length
- 1 ),
224 fragment
= document
.createDocumentFragment();
226 for ( var i
= 0; i
< totalRows
; i
++ ) {
227 var pos
= normalized
[i
][checkCell
];
229 var l
= row
[pos
].length
;
231 for ( var j
= 0; j
< l
; j
++ ) {
232 fragment
.appendChild( row
[pos
][j
] );
236 table
.tBodies
[0].appendChild( fragment
);
238 $( table
).trigger( 'sortEnd.tablesorter' );
242 * Find all header rows in a thead-less table and put them in a <thead> tag.
243 * This only treats a row as a header row if it contains only <th>s (no <td>s)
244 * and if it is preceded entirely by header rows. The algorithm stops when
245 * it encounters the first non-header row.
247 * After this, it will look at all rows at the bottom for footer rows
248 * And place these in a tfoot using similar rules.
249 * @param $table jQuery object for a <table>
251 function emulateTHeadAndFoot( $table
) {
252 var $rows
= $table
.find( '> tbody > tr' );
253 if( !$table
.get(0).tHead
) {
254 var $thead
= $( '<thead>' );
255 $rows
.each( function () {
256 if ( $(this).children( 'td' ).length
> 0 ) {
257 // This row contains a <td>, so it's not a header row
261 $thead
.append( this );
263 $table
.find(' > tbody:first').before( $thead
);
265 if( !$table
.get(0).tFoot
) {
266 var $tfoot
= $( '<tfoot>' );
267 var len
= $rows
.length
;
268 for ( var i
= len
-1; i
>= 0; i
-- ) {
269 if( $( $rows
[i
] ).children( 'td' ).length
> 0 ){
272 $tfoot
.prepend( $( $rows
[i
] ));
274 $table
.append( $tfoot
);
278 function buildHeaders( table
, msg
) {
282 $tableHeaders
= $( 'thead:eq(0) > tr', table
);
283 if ( $tableHeaders
.length
> 1 ) {
284 $tableHeaders
.each( function () {
285 if ( this.cells
.length
> maxSeen
) {
286 maxSeen
= this.cells
.length
;
290 $tableHeaders
= $( longest
);
292 $tableHeaders
= $tableHeaders
.children( 'th' ).each( function ( index
) {
293 this.column
= realCellIndex
;
295 var colspan
= this.colspan
;
296 colspan
= colspan
? parseInt( colspan
, 10 ) : 1;
297 realCellIndex
+= colspan
;
302 if ( $( this ).is( '.unsortable' ) ) {
303 this.sortDisabled
= true;
306 if ( !this.sortDisabled
) {
307 $( this ).addClass( table
.config
.cssHeader
).attr( 'title', msg
[1] );
310 // add cell to headerList
311 table
.config
.headerList
[index
] = this;
314 return $tableHeaders
;
318 function isValueInArray( v
, a
) {
320 for ( var i
= 0; i
< l
; i
++ ) {
321 if ( a
[i
][0] === v
) {
328 function setHeadersCss( table
, $headers
, list
, css
, msg
) {
329 // Remove all header information and reset titles to default message
330 $headers
.removeClass( css
[0] ).removeClass( css
[1] ).attr( 'title', msg
[1] );
333 $headers
.each( function () {
334 if ( !this.sortDisabled
) {
335 h
[this.column
] = $( this );
340 for ( var i
= 0; i
< l
; i
++ ) {
341 h
[ list
[i
][0] ].addClass( css
[ list
[i
][1] ] ).attr( 'title', msg
[ list
[i
][1] ] );
345 function sortText( a
, b
) {
346 return ( (a
< b
) ? -1 : ((a
> b
) ? 1 : 0) );
349 function sortTextDesc( a
, b
) {
350 return ( (b
< a
) ? -1 : ((b
> a
) ? 1 : 0) );
353 function multisort( table
, sortList
, cache
) {
355 var len
= sortList
.length
;
356 for ( var i
= 0; i
< len
; i
++ ) {
357 sortFn
[i
] = ( sortList
[i
][1] ) ? sortTextDesc
: sortText
;
359 cache
.normalized
.sort( function ( array1
, array2
) {
361 for ( var i
= 0; i
< len
; i
++ ) {
362 col
= sortList
[i
][0];
363 ret
= sortFn
[i
].call( this, array1
[col
], array2
[col
] );
368 // Fall back to index number column to ensure stable sort
369 return sortText
.call( this, array1
[array1
.length
- 1], array2
[array2
.length
- 1] );
374 function buildTransformTable() {
375 var digits
= '0123456789,.'.split( '' );
376 var separatorTransformTable
= mw
.config
.get( 'wgSeparatorTransformTable' );
377 var digitTransformTable
= mw
.config
.get( 'wgDigitTransformTable' );
378 if ( separatorTransformTable
=== null || ( separatorTransformTable
[0] === '' && digitTransformTable
[2] === '' ) ) {
379 ts
.transformTable
= false;
381 ts
.transformTable
= {};
383 // Unpack the transform table
384 var ascii
= separatorTransformTable
[0].split( '\t' ).concat( digitTransformTable
[0].split( '\t' ) );
385 var localised
= separatorTransformTable
[1].split( '\t' ).concat( digitTransformTable
[1].split( '\t' ) );
387 // Construct regex for number identification
388 for ( var i
= 0; i
< ascii
.length
; i
++ ) {
389 ts
.transformTable
[localised
[i
]] = ascii
[i
];
390 digits
.push( $.escapeRE( localised
[i
] ) );
393 var digitClass
= '[' + digits
.join( '', digits
) + ']';
395 // We allow a trailing percent sign, which we just strip. This works fine
396 // if percents and regular numbers aren't being mixed.
397 ts
.numberRegex
= new RegExp('^(' + '[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?' + // Fortran-style scientific
398 '|' + '[-+\u2212]?' + digitClass
+ '+[\\s\\xa0]*%?' + // Generic localised
402 function buildDateTable() {
406 for ( var i
= 1; i
< 13; i
++ ) {
407 var name
= mw
.config
.get( 'wgMonthNames' )[i
].toLowerCase();
408 ts
.monthNames
[name
] = i
;
409 regex
.push( $.escapeRE( name
) );
410 name
= mw
.config
.get( 'wgMonthNamesShort' )[i
].toLowerCase().replace( '.', '' );
411 ts
.monthNames
[name
] = i
;
412 regex
.push( $.escapeRE( name
) );
415 // Build piped string
416 regex
= regex
.join( '|' );
419 // Any date formated with . , ' - or /
420 ts
.dateRegex
[0] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i);
422 // Written Month name, dmy
423 ts
.dateRegex
[1] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]*(' + regex
+ ')' + '[\\,\\.\\-\\/\'\\s]*(\\d{2,4})\\s*$', 'i' );
425 // Written Month name, mdy
426 ts
.dateRegex
[2] = new RegExp( '^\\s*(' + regex
+ ')' + '[\\,\\.\\-\\/\'\\s]*(\\d{1,2})[\\,\\.\\-\\/\'\\s]*(\\d{2,4})\\s*$', 'i' );
430 function explodeRowspans( $table
) {
431 // Split multi row cells into multiple cells with the same content
432 $table
.find( '> tbody > tr > [rowspan]' ).each(function () {
433 var rowSpan
= this.rowSpan
;
435 var cell
= $( this );
436 var next
= cell
.parent().nextAll();
437 for ( var i
= 0; i
< rowSpan
- 1; i
++ ) {
438 var td
= next
.eq( i
).children( 'td' );
440 next
.eq( i
).append( cell
.clone() );
441 } else if ( this.cellIndex
=== 0 ) {
442 td
.eq( this.cellIndex
).before( cell
.clone() );
444 td
.eq( this.cellIndex
- 1 ).after( cell
.clone() );
450 function buildCollationTable() {
451 ts
.collationTable
= mw
.config
.get( 'tableSorterCollation' );
452 ts
.collationRegex
= null;
453 if ( ts
.collationTable
) {
456 // Build array of key names
457 for ( var key
in ts
.collationTable
) {
458 if ( ts
.collationTable
.hasOwnProperty(key
) ) { //to be safe
463 ts
.collationRegex
= new RegExp( '[' + keys
.join( '' ) + ']', 'ig' );
468 function cacheRegexs() {
474 new RegExp( /^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/)
477 new RegExp( /(^[£$€¥]|[£$€¥]$)/),
478 new RegExp( /[£$€¥]/g)
481 new RegExp( /^(https?|ftp|file):\/\/$/),
482 new RegExp( /(https?|ftp|file):\/\//)
485 new RegExp( /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/)
488 new RegExp( /^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)
491 new RegExp( /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/)
497 * Converts sort objects [ { Integer: String }, ... ] to the internally used nested array
498 * structure [ [ Integer , Integer ], ... ]
500 * @param sortObjects {Array} List of sort objects.
501 * @return {Array} List of internal sort definitions.
504 function convertSortList( sortObjects
) {
506 $.each( sortObjects
, function( i
, sortObject
) {
507 $.each ( sortObject
, function( columnIndex
, order
) {
508 var orderIndex
= ( order
=== 'desc' ) ? 1 : 0;
509 sortList
.push( [columnIndex
, orderIndex
] );
520 cssHeader
: 'headerSort',
521 cssAsc
: 'headerSortUp',
522 cssDesc
: 'headerSortDown',
523 cssChildRow
: 'expand-child',
524 sortInitialOrder
: 'asc',
525 sortMultiSortKey
: 'shiftKey',
526 sortLocaleCompare
: false,
530 cancelSelection
: true,
533 selectorHeaders
: 'thead tr:eq(0) th',
541 * @param $tables {jQuery}
542 * @param settings {Object} (optional)
544 construct: function ( $tables
, settings
) {
545 return $tables
.each( function ( i
, table
) {
546 // Declare and cache.
547 var $headers
, cache
, config
,
552 if ( !table
.tBodies
) {
555 if ( !table
.tHead
) {
556 // No thead found. Look for rows with <th>s and
557 // move them into a <thead> tag or a <tfoot> tag
558 emulateTHeadAndFoot( $table
);
560 // Still no thead? Then quit
561 if ( !table
.tHead
) {
565 $table
.addClass( 'jquery-tablesorter' );
567 // FIXME config should probably not be stored in the plain table node
568 // New config object.
572 config
= $.extend( table
.config
, $.tablesorter
.defaultOptions
, settings
);
574 // Save the settings where they read
575 $.data( table
, 'tablesorter', { config
: config
} );
577 // Get the CSS class names, could be done else where.
578 var sortCSS
= [ config
.cssDesc
, config
.cssAsc
];
579 var sortMsg
= [ mw
.msg( 'sort-descending' ), mw
.msg( 'sort-ascending' ) ];
582 $headers
= buildHeaders( table
, sortMsg
);
584 // Grab and process locale settings
585 buildTransformTable();
587 buildCollationTable();
589 // Precaching regexps can bring 10 fold
590 // performance improvements in some browsers.
593 function setupForFirstSort() {
596 // Legacy fix of .sortbottoms
597 // Wrap them inside inside a tfoot (because that's what they actually want to be) &
598 // and put the <tfoot> at the end of the <table>
599 var $sortbottoms
= $table
.find( '> tbody > tr.sortbottom' );
600 if ( $sortbottoms
.length
) {
601 var $tfoot
= $table
.children( 'tfoot' );
602 if ( $tfoot
.length
) {
603 $tfoot
.eq(0).prepend( $sortbottoms
);
605 $table
.append( $( '<tfoot>' ).append( $sortbottoms
) );
609 explodeRowspans( $table
);
611 // try to auto detect column type, and store in tables config
612 table
.config
.parsers
= buildParserCache( table
, $headers
);
615 // Apply event handling to headers
616 // this is too big, perhaps break it out?
617 $headers
.filter( ':not(.unsortable)' ).click( function ( e
) {
618 if ( e
.target
.nodeName
.toLowerCase() === 'a' ) {
619 // The user clicked on a link inside a table header
620 // Do nothing and let the default link click action continue
628 // Build the cache for the tbody cells
629 // to share between calculations for this sort action.
630 // Re-calculated each time a sort action is performed due to possiblity
631 // that sort values change. Shouldn't be too expensive, but if it becomes
632 // too slow an event based system should be implemented somehow where
633 // cells get event .change() and bubbles up to the <table> here
634 cache
= buildCache( table
);
636 var totalRows
= ( $table
[0].tBodies
[0] && $table
[0].tBodies
[0].rows
.length
) || 0;
637 if ( !table
.sortDisabled
&& totalRows
> 0 ) {
639 // Get current column index
642 // Get current column sort order
643 this.order
= this.count
% 2;
646 // User only wants to sort on one column
647 if ( !e
[config
.sortMultiSortKey
] ) {
648 // Flush the sort list
649 config
.sortList
= [];
650 // Add column to sort list
651 config
.sortList
.push( [i
, this.order
] );
653 // Multi column sorting
655 // The user has clicked on an already sorted column.
656 if ( isValueInArray( i
, config
.sortList
) ) {
657 // Reverse the sorting direction for all tables.
658 for ( var j
= 0; j
< config
.sortList
.length
; j
++ ) {
659 var s
= config
.sortList
[j
],
660 o
= config
.headerList
[s
[0]];
668 // Add column to sort list array
669 config
.sortList
.push( [i
, this.order
] );
673 // Set CSS for headers
674 setHeadersCss( $table
[0], $headers
, config
.sortList
, sortCSS
, sortMsg
);
676 $table
[0], multisort( $table
[0], config
.sortList
, cache
)
679 // Stop normal event by returning false
684 } ).mousedown( function () {
685 if ( config
.cancelSelection
) {
686 this.onselectstart = function () {
694 * Sorts the table. If no sorting is specified by passing a list of sort
695 * objects, the table is sorted according to the initial sorting order.
696 * Passing an empty array will reset sorting (basically just reset the headers
697 * making the table appear unsorted).
699 * @param sortList {Array} (optional) List of sort objects.
701 $table
.data( 'tablesorter' ).sort = function( sortList
) {
707 if ( sortList
=== undefined ) {
708 sortList
= config
.sortList
;
709 } else if ( sortList
.length
> 0 ) {
710 sortList
= convertSortList( sortList
);
713 // re-build the cache for the tbody cells
714 cache
= buildCache( table
);
716 // set css for headers
717 setHeadersCss( table
, $headers
, sortList
, sortCSS
, sortMsg
);
719 // sort the table and append it to the dom
720 appendToTable( table
, multisort( table
, sortList
, cache
) );
724 if ( config
.sortList
.length
> 0 ) {
726 config
.sortList
= convertSortList( config
.sortList
);
727 $table
.data( 'tablesorter' ).sort();
733 addParser: function ( parser
) {
734 var l
= parsers
.length
,
736 for ( var i
= 0; i
< l
; i
++ ) {
737 if ( parsers
[i
].id
.toLowerCase() === parser
.id
.toLowerCase() ) {
742 parsers
.push( parser
);
746 formatDigit: function ( s
) {
748 if ( ts
.transformTable
!== false ) {
750 for ( p
= 0; p
< s
.length
; p
++ ) {
752 if ( c
in ts
.transformTable
) {
753 out
+= ts
.transformTable
[c
];
760 i
= parseFloat( s
.replace( /[, ]/g, '' ).replace( '\u2212', '-' ) );
761 return isNaN( i
) ? 0 : i
;
764 formatFloat: function ( s
) {
765 var i
= parseFloat(s
);
766 return isNaN( i
) ? 0 : i
;
769 formatInt: function ( s
) {
770 var i
= parseInt( s
, 10 );
771 return isNaN( i
) ? 0 : i
;
774 clearTableBody: function ( table
) {
775 $( table
.tBodies
[0] ).empty();
782 // Register as jQuery prototype method
783 $.fn
.tablesorter = function ( settings
) {
784 return ts
.construct( this, settings
);
787 // Add default parsers
793 format: function ( s
) {
794 s
= $.trim( s
.toLowerCase() );
795 if ( ts
.collationRegex
) {
796 var tsc
= ts
.collationTable
;
797 s
= s
.replace( ts
.collationRegex
, function ( match
) {
798 var r
= tsc
[match
] ? tsc
[match
] : tsc
[match
.toUpperCase()];
799 return r
.toLowerCase();
810 return ts
.rgx
.IPAddress
[0].test(s
);
812 format: function ( s
) {
813 var a
= s
.split( '.' ),
816 for ( var i
= 0; i
< l
; i
++ ) {
818 if ( item
.length
=== 1 ) {
820 } else if ( item
.length
=== 2 ) {
826 return $.tablesorter
.formatFloat(r
);
834 return ts
.rgx
.currency
[0].test(s
);
836 format: function ( s
) {
837 return $.tablesorter
.formatDigit( s
.replace( ts
.rgx
.currency
[1], '' ) );
845 return ts
.rgx
.url
[0].test(s
);
847 format: function ( s
) {
848 return $.trim( s
.replace( ts
.rgx
.url
[1], '' ) );
856 return ts
.rgx
.isoDate
[0].test(s
);
858 format: function ( s
) {
859 return $.tablesorter
.formatFloat((s
!== '') ? new Date(s
.replace(
860 new RegExp( /-/g), '/')).getTime() : '0' );
868 return ts.rgx.usLongDate[0].test(s);
870 format: function ( s ) {
871 return $.tablesorter.formatFloat( new Date(s).getTime() );
879 return ( ts.dateRegex[0].test(s) || ts.dateRegex[1].test(s) || ts.dateRegex[2].test(s ));
881 format: function ( s ) {
883 s = $.trim( s.toLowerCase() );
885 if ( ( match = s.match( ts.dateRegex[0] ) ) !== null ) {
886 if ( mw.config.get( 'wgDefaultDateFormat
' ) === 'mdy
' || mw.config.get( 'wgContentLanguage
' ) === 'en
' ) {
887 s = [ match[3], match[1], match[2] ];
888 } else if ( mw.config.get( 'wgDefaultDateFormat
' ) === 'dmy
' ) {
889 s = [ match[3], match[2], match[1] ];
891 // If we get here, we don't know which order the dd
-dd
-dddd
892 // date is in. So return something not entirely invalid.
895 } else if ( ( match
= s
.match( ts
.dateRegex
[1] ) ) !== null ) {
896 s
= [ match
[3], '' + ts
.monthNames
[match
[2]], match
[1] ];
897 } else if ( ( match
= s
.match( ts
.dateRegex
[2] ) ) !== null ) {
898 s
= [ match
[3], '' + ts
.monthNames
[match
[1]], match
[2] ];
900 // Should never get here
905 if ( s
[1].length
=== 1 ) {
908 if ( s
[2].length
=== 1 ) {
913 if ( ( y
= parseInt( s
[0], 10) ) < 100 ) {
914 // Guestimate years without centuries
921 while ( s
[0].length
< 4 ) {
924 return parseInt( s
.join( '' ), 10 );
932 return ts
.rgx
.time
[0].test(s
);
934 format: function ( s
) {
935 return $.tablesorter
.formatFloat( new Date( '2000/01/01 ' + s
).getTime() );
943 return $.tablesorter
.numberRegex
.test( $.trim( s
));
945 format: function ( s
) {
946 return $.tablesorter
.formatDigit(s
);
951 }( jQuery
, mediaWiki
) );