r101202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101201‎ | r101202 | r101203 >
Date:21:14, 28 October 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
REL1_18 MFT r98669, r99031, r99321, r99994
Modified paths:
  • /branches/REL1_18/phase3 (modified) (history)
  • /branches/REL1_18/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/resources/jquery/jquery.tablesorter.js
@@ -223,19 +223,36 @@
224224 * This only treats a row as a header row if it contains only <th>s (no <td>s)
225225 * and if it is preceded entirely by header rows. The algorithm stops when
226226 * it encounters the first non-header row.
 227+ *
 228+ * After this, it will look at all rows at the bottom for footer rows
 229+ * And place these in a tfoot using similar rules.
227230 * @param $table jQuery object for a <table>
228231 */
229 - function emulateTHead( $table ) {
230 - var $thead = $( '<thead>' );
231 - $table.find( 'tr' ).each( function() {
232 - if ( $(this).children( 'td' ).length > 0 ) {
233 - // This row contains a <td>, so it's not a header row
234 - // Stop here
235 - return false;
236 - }
237 - $thead.append( this );
238 - } );
239 - $table.prepend( $thead );
 232+ function emulateTHeadAndFoot( $table ) {
 233+ var $rows = $table.find( 'tr' );
 234+ if( !$table.get(0).tHead ) {
 235+ var $thead = $( '<thead>' );
 236+ $rows.each( function() {
 237+ if ( $(this).children( 'td' ).length > 0 ) {
 238+ // This row contains a <td>, so it's not a header row
 239+ // Stop here
 240+ return false;
 241+ }
 242+ $thead.append( this );
 243+ } );
 244+ $table.prepend( $thead );
 245+ }
 246+ if( !$table.get(0).tFoot ) {
 247+ var $tfoot = $( '<tfoot>' );
 248+ var len = $rows.length;
 249+ for ( var i = len-1; i >= 0; i-- ) {
 250+ if( $( $rows[i] ).children( 'td' ).length > 0 ){
 251+ break;
 252+ }
 253+ $tfoot.prepend( $( $rows[i] ));
 254+ }
 255+ $table.append( $tfoot );
 256+ }
240257 }
241258
242259 function buildHeaders( table, msg ) {
@@ -531,8 +548,8 @@
532549 }
533550 if ( !table.tHead ) {
534551 // No thead found. Look for rows with <th>s and
535 - // move them into a <thead> tag
536 - emulateTHead( $table );
 552+ // move them into a <thead> tag or a <tfoot> tag
 553+ emulateTHeadAndFoot( $table );
537554
538555 // Still no thead? Then quit
539556 if ( !table.tHead ) {
@@ -578,7 +595,12 @@
579596 // and put the <tfoot> at the end of the <table>
580597 var $sortbottoms = $table.find( 'tr.sortbottom' );
581598 if ( $sortbottoms.length ) {
582 - $table.append( $( '<tfoot>' ).append( $sortbottoms ) )
 599+ var $tfoot = $table.find( 'tfoot' );
 600+ if( $tfoot.length ) {
 601+ $tfoot.eq(0).prepend( $sortbottoms );
 602+ } else {
 603+ $table.append( $( '<tfoot>' ).append( $sortbottoms ) )
 604+ }
583605 }
584606
585607 explodeRowspans( $table );
@@ -645,6 +667,10 @@
646668 };
647669 return false;
648670 }
 671+ } )
 672+ // Allow links in headers to be clicked
 673+ .find( 'a' ).click( function( e ) {
 674+ e.stopPropagation();
649675 } );
650676
651677 } );
Property changes on: branches/REL1_18/phase3
___________________________________________________________________
Modified: svn:mergeinfo
652678 Merged /trunk/phase3:r98669,99031,99321,99994,100391

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98669Add tfoot emulation to tablesorter. Fixes part of the complaints in bug 31060hartman11:58, 2 October 2011
r99031Fix the bug reported on w:en:WP:VP/T where clicking on links in sortable tabl...catrope19:27, 5 October 2011
r99321Check if there is a prexisting tfoot, before creating a new one....hartman19:28, 8 October 2011
r99994Fix broken test by r99321krinkle22:33, 16 October 2011
r100391QUnit test cases for bug 31847: will trigger a fail on IE 6/7/8...brion22:50, 20 October 2011

Comments

#Comment by Reedy (talk | contribs)   21:14, 28 October 2011

Also merged for tablesorter from r100391

Status & tagging log