Index: branches/REL1_18/phase3/resources/jquery/jquery.tablesorter.js |
— | — | @@ -223,19 +223,36 @@ |
224 | 224 | * This only treats a row as a header row if it contains only <th>s (no <td>s) |
225 | 225 | * and if it is preceded entirely by header rows. The algorithm stops when |
226 | 226 | * 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. |
227 | 230 | * @param $table jQuery object for a <table> |
228 | 231 | */ |
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 | + } |
240 | 257 | } |
241 | 258 | |
242 | 259 | function buildHeaders( table, msg ) { |
— | — | @@ -531,8 +548,8 @@ |
532 | 549 | } |
533 | 550 | if ( !table.tHead ) { |
534 | 551 | // 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 ); |
537 | 554 | |
538 | 555 | // Still no thead? Then quit |
539 | 556 | if ( !table.tHead ) { |
— | — | @@ -578,7 +595,12 @@ |
579 | 596 | // and put the <tfoot> at the end of the <table> |
580 | 597 | var $sortbottoms = $table.find( 'tr.sortbottom' ); |
581 | 598 | 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 | + } |
583 | 605 | } |
584 | 606 | |
585 | 607 | explodeRowspans( $table ); |
— | — | @@ -645,6 +667,10 @@ |
646 | 668 | }; |
647 | 669 | return false; |
648 | 670 | } |
| 671 | + } ) |
| 672 | + // Allow links in headers to be clicked |
| 673 | + .find( 'a' ).click( function( e ) { |
| 674 | + e.stopPropagation(); |
649 | 675 | } ); |
650 | 676 | |
651 | 677 | } ); |
Property changes on: branches/REL1_18/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
652 | 678 | Merged /trunk/phase3:r98669,99031,99321,99994,100391 |