r65875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65874‎ | r65875 | r65876 >
Date:20:37, 3 May 2010
Author:platonides
Status:ok
Tags:
Comment:
The previous code computing rowStart will fail when there are theads since tHead contents are also computed inside table.rows.
However, that code probably worked at some time, so perform a computation to ensure that table.rows isn't getting just the tBody contents.
Please cross browser test.
The last code version of this sortables is on http://yoast.com/articles/sortable-table/ and has changed quite a bit. Joost de Valk suggest
using the jQuery based tablesorter.com.
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -618,7 +618,15 @@
619619 // Work out a type for the column
620620 // Skip the first row if that's where the headings are
621621 var rowStart = ( table.tHead && table.tHead.rows.length > 0 ? 0 : 1 );
622 -
 622+ var bodyRows = 0;
 623+ if (rowStart == 0 && table.tBodies) {
 624+ for (var i=0; i < table.tBodies.length; i++ ) {
 625+ bodyRows += table.tBodies[i].rows.length;
 626+ }
 627+ if (bodyRows < table.rows.length)
 628+ rowStart = 1;
 629+ }
 630+
623631 var itm = '';
624632 for ( var i = rowStart; i < table.rows.length; i++ ) {
625633 if ( table.rows[i].cells.length > column ) {

Status & tagging log