[MediaWiki-commits] [Gerrit] jquery.makeCollapsible: Tables with more header rows and tfoot - change (mediawiki/core)
MatthiasDD has uploaded a new change for review. https://gerrit.wikimedia.org/r/291569 Change subject: jquery.makeCollapsible: Tables with more header rows and tfoot .. jquery.makeCollapsible: Tables with more header rows and tfoot Make collapsible on tables with more than one header row and footer row. Hide all rows except the first if $defaultToggle in it. Bug: T114607 Change-Id: I1b5cf084d56d7eac093a04e8301e426f5d5d5d28 --- M resources/src/jquery/jquery.makeCollapsible.js M tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js 2 files changed, 49 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/69/291569/1 diff --git a/resources/src/jquery/jquery.makeCollapsible.js b/resources/src/jquery/jquery.makeCollapsible.js index bdb5ce8..85a7e45 100644 --- a/resources/src/jquery/jquery.makeCollapsible.js +++ b/resources/src/jquery/jquery.makeCollapsible.js @@ -54,12 +54,7 @@ if ( !options.plainMode && $collapsible.is( 'table' ) ) { // Tables - // If there is a caption, hide all rows; otherwise, only hide body rows - if ( $collapsible.find( '> caption' ).length ) { - $containers = $collapsible.find( '> * > tr' ); - } else { - $containers = $collapsible.find( '> tbody > tr' ); - } + $containers = $collapsible.find( '> * > tr' ); if ( $defaultToggle ) { // Exclude table row containing togglelink $containers = $containers.not( $defaultToggle.closest( 'tr' ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js index c51e409..1e1d4b8 100644 --- a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js @@ -113,6 +113,51 @@ test.clock.tick( 500 ); } ); + QUnit.test( 'basic operation () with and ', 13, function ( assert ) { + var test = this, + $collapsible = prepareCollapsible( + '' + + '' + loremIpsum + '' + + ' ' + loremIpsum + '' + loremIpsum + '' + + '' + loremIpsum + '' + loremIpsum + '' + + ' ' + loremIpsum + '' + loremIpsum + '' + + '' + loremIpsum + '' + loremIpsum + '' + + '' + ), + $headerRow1 = $collapsible.find( 'tr:eq(0)' ), + $headerRow2 = $collapsible.find( 'tr:eq(1)' ), + $contentRow = $collapsible.find( 'tr:eq(2)' ), + $footerRow = $collapsible.find( 'tr:last' ), + $toggle = $headerRow1.find( '.mw-collapsible-toggle' ); + + assert.equal( $toggle.length, 1, 'toggle is added to the cell of first row' ); + + assert.assertTrue( $headerRow1.is( ':visible' ), 'headerRow1 is visible' ); + assert.assertTrue( $headerRow2.is( ':visible' ), 'headerRow2 is visible' ); + assert.assertTrue( $contentRow.is( ':visible' ), 'contentRow is visible' ); + assert.assertTrue( $footerRow.is( ':visible' ), 'footerRow is visible' ); + + $collapsible.on( 'afterCollapse.mw-collapsible', function () { + assert.assertTrue( $headerRow1.is( ':visible' ), 'after collapsing: headerRow1 is still visible' ); + assert.assertTrue( $headerRow2.is( ':hidden' ), 'after collapsing: headerRow2 is hidden' ); + assert.assertTrue( $contentRow.is( ':hidden' ), 'after collapsing: contentRow is hidden' ); + assert.assertTrue( $footerRow.is( ':hidden' ), 'after collapsing: footerRow is hidden' ); + + $collapsible.on( 'afterExpand.mw-collapsible', function () { + assert.assertTrue( $headerRow1.is( ':visible' ), 'after expanding: headerRow1 is still visible' ); + assert.assertTrue( $headerRow2.is( ':visible' ), 'after expanding: headerRow2 is visible' ); + assert.assertTrue( $contentRow.is( ':visible' ), 'after expanding: contentRow is visible' ); + assert.assertTrue( $footerRow.is( ':visible' ), 'after expanding: footerRow is visible' ); + } ); + + $toggle.trigger( 'click' ); + test.cloc
[MediaWiki-commits] [Gerrit] jquery.tablesorter: Rowspan td until footer row - change (mediawiki/core)
MatthiasDD has uploaded a new change for review. https://gerrit.wikimedia.org/r/291342 Change subject: jquery.tablesorter: Rowspan td until footer row .. jquery.tablesorter: Rowspan td until footer row If a with rowspan span until a footer row, this row can not be a footer row. Bug: T114604 Change-Id: I76b574586e690767cd32e96352a19a394b1c4c85 --- M resources/src/jquery/jquery.tablesorter.js M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 2 files changed, 25 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/42/291342/1 diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 50bfa87..6f69af7 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -250,7 +250,8 @@ */ function emulateTHeadAndFoot( $table ) { var $thead, $tfoot, i, len, - $rows = $table.find( '> tbody > tr' ); + $rows = $table.find( '> tbody > tr' ), + lastRowWithTd = 0; if ( !$table.get( 0 ).tHead ) { $thead = $( '' ); $rows.each( function () { @@ -266,7 +267,11 @@ if ( !$table.get( 0 ).tFoot ) { $tfoot = $( '' ); len = $rows.length; - for ( i = len - 1; i >= 0; i-- ) { + // Calculate the last row that a span, this row can not be a footer row + $rows.find( '> td[rowspan]' ).each( function ( i, cell ) { + lastRowWithTd = Math.max( lastRowWithTd, cell.parentElement.rowIndex + cell.rowSpan - 1 ); + } ); + for ( i = len - 1; i > lastRowWithTd; i-- ) { if ( $( $rows[ i ] ).children( 'td' ).length ) { break; } diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index b09bb28..8533164 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -1390,6 +1390,24 @@ ] ); + QUnit.test( 'bug T114604 - Rowspan td until footer row', 1, function ( assert ) { + var $table, parsers; + $table = $( + '' + + 'ABC' + + 'a1b1-3c1-2' + + 'a2' + + 'a3c3' + + '' + ); + $table.tablesorter(); + assert.equal( + $table.find( 'tbody > tr' ).length + '+' + $table.find( 'tfoot > tr' ).length, + '3+0', + 'body have 3 rows and no footer row' + ); + } ); + QUnit.test( 'bug 105731 - incomplete rows in table body', 3, function ( assert ) { var $table, parsers; $table = $( -- To view, visit https://gerrit.wikimedia.org/r/291342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I76b574586e690767cd32e96352a19a394b1c4c85 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MatthiasDD ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] jquery.tablesorter: Improve detection and handling of isoDate - change (mediawiki/core)
MatthiasDD has uploaded a new change for review. https://gerrit.wikimedia.org/r/287449 Change subject: jquery.tablesorter: Improve detection and handling of isoDate .. jquery.tablesorter: Improve detection and handling of isoDate * Detect years 0...99 correct. * Short forms possible: , -MM, MM, MMTT QUnit Test sorts now with parser 'isoDate' (because of 2009 former test sorts with parser 'text') * Prefix and postfix allowed. * Between date and time a 'T' or 'any white space' is allowed (Bug: T126886) Change-Id: I664b4cc9d5fb472ea0bc0e36a3c209f04048e769 --- M resources/src/jquery/jquery.tablesorter.js M tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 3 files changed, 70 insertions(+), 41 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/49/287449/1 diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 50bfa87..7f639e4 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -90,6 +90,7 @@ config = $( table ).data( 'tablesorter' ).config, cellIndex, nodeValue, + nextRow = false, // Start with 1 because 0 is the fallback parser i = 1, lastRowIndex = -1, @@ -113,24 +114,34 @@ if ( nodeValue !== '' ) { if ( parsers[ i ].is( nodeValue, table ) ) { concurrent++; - rowIndex++; + nextRow = true; if ( concurrent >= needed ) { // Confirmed the parser for multiple cells, let's return it return parsers[ i ]; } + } else if ( parsers[ i ].id.match(/isoDate/) && /^\D*(\d{1,4}) ?(\[.+\])?$/.test( nodeValue ) ) { + //For 1-4 digits and maybe reference(s) parser "isoDate", "date" or "number" is possible, check next row + empty++; + nextRow = true; } else { // Check next parser, reset rows i++; rowIndex = 0; concurrent = 0; empty = 0; + nextRow = false; } } else { // Empty cell empty++; + nextRow = true; + } + + if( nextRow ) { + nextRow = false; rowIndex++; if ( rowIndex >= rows.length ) { - if ( concurrent >= rows.length - empty ) { + if ( concurrent > 0 && concurrent >= rows.length - empty ) { // Confirmed the parser for all filled cells return parsers[ i ]; } @@ -722,8 +733,8 @@ new RegExp( /(https?|ftp|file):\/\// ) ], isoDate: [ - new RegExp( /^([-+]?\d{1,4})-([01]\d)-([0-3]\d)([T\s]((([01]\d|2[0-3])(:?[0-5]\d)?|24:?00)?(:?([0-5]\d|60))?([.,]\d+)?)([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?/ ), - new RegExp( /^([-+]?\d{1,4})-([01]\d)-([0-3]\d)/ ) + new RegExp( /^[^-\d]*(-?\d{1,4})-(0\d|1[0-2])(-([0-3]\d))?([T\s]([01]\d|2[0-4]):?(([0-5]\d):?(([0-5]\d|60)([.,]\d{1,3})?)?)?([zZ]|([-+])([01]\d|2[0-3]):?([0-5]\d)?)?)?/ ), + new RegExp( /^[^-\d]*(-?\d{1,4})-?(\d\d)?(-?(\d\d))?([T\s](\d\d):?((\d\d)?:?((\d\d)?([.,]\d{1,3})?)?)?([zZ]|([-+])(\d\d):?(\d\d)?)?)?/ ) ], usLongDate: [ 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)))$/ ) @@ -1128,22 +1139,34 @@ return ts.rgx.isoDate[ 0 ].test( s ); }, format: function ( s ) { - var isodate, matches; -
[MediaWiki-commits] [Gerrit] jquery.tablesorter: use of expand-child class - change (mediawiki/core)
MatthiasDD has uploaded a new change for review. https://gerrit.wikimedia.org/r/244940 Change subject: jquery.tablesorter: use of expand-child class .. jquery.tablesorter: use of expand-child class Rows with class expand-child are now scipped in detectParserForColumn(). This is necessary after change I5180296. Add a test for expand-child class. Bug: T114721 Change-Id: I88a01208889fbb461b1f42855ed6494d479440fa --- M resources/src/jquery/jquery.tablesorter.js M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 2 files changed, 39 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/40/244940/1 diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 0eefae6..4a78588 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -107,6 +107,7 @@ function detectParserForColumn( table, rows, column ) { var l = parsers.length, + config = $( table ).data( 'tablesorter' ).config, cellIndex, nodeValue, // Start with 1 because 0 is the fallback parser @@ -118,7 +119,8 @@ needed = ( rows.length > 4 ) ? 5 : rows.length; while ( i < l ) { - if ( rows[ rowIndex ] ) { + // if this is a child row, continue to the next row (as buildCache()) + if ( rows[ rowIndex ] && !$( rows[ rowIndex ] ).hasClass( config.cssChildRow ) ) { if ( rowIndex !== lastRowIndex ) { lastRowIndex = rowIndex; cellIndex = $( rows[ rowIndex ] ).data( 'columnToCell' )[ column ]; diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 6805eab..bc64809 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -1423,6 +1423,41 @@ 0, 'empty cell is sorted as number 0' ); - } ); + + QUnit.test( 'bug 114721 - use of expand-child class', 2, function ( assert ) { + var $table, parsers; + $table = $( + '' + + 'AB' + + 'b4' + + 'some text follow b' + + 'a2' + + 'some text follow a' + + 'more text' + + '' + ); + $table.tablesorter(); + $table.find( '.headerSort:eq(0)' ).click(); + + assert.deepEqual( + tableExtract( $table ), + [ + [ 'a', '2' ], + [ 'some text follow a' ], + [ 'more text' ], + [ 'b', '4' ], + [ 'some text follow b' ] + ], + 'row with expand-child class follow above row' + ); + + parsers = $table.data( 'tablesorter' ).config.parsers; + assert.equal( + parsers[ 1 ].id, + 'number', + 'detectParserForColumn() detect parser.id "number" for second column' + ); + } ); + }( jQuery, mediaWiki ) ); -- To view, visit https://gerrit.wikimedia.org/r/244940 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I88a01208889fbb461b1f42855ed6494d479440fa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MatthiasDD ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] jquery.tablesorter: Add ability for cells with colspan in tbody - change (mediawiki/core)
MatthiasDD has uploaded a new change for review. https://gerrit.wikimedia.org/r/233168 Change subject: jquery.tablesorter: Add ability for cells with colspan in tbody .. jquery.tablesorter: Add ability for cells with colspan in tbody * Add manageColspans() to handle colspaned cells in table body. Add config.columns - number of colums with extended colspan, inclusive unsortable columns buildParserCache() iterate for all columns (not only the first body row, Bug: T105731) buildCache() also (Bug: T74534) Rows with not enougth cells get after first click additional empty cells. * Add $.tablesorter.getParsers() for better table diagnosis. fix 3 litle bugs: * Improve multi column sorting with colspan in header (add columnToHeader[..] to s[0] ) * Unsortable headers get after sorting no title tag. ($headers contain only sortable headers) * Parser detection in tables with max. 5 rows and empty cells works now. Bug: T105731 Bug: T74534 Change-Id: I518029616d4c10a48eeaad8e92962f4e580f9413 --- M resources/src/jquery/jquery.tablesorter.js M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 2 files changed, 209 insertions(+), 88 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/68/233168/1 diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index 8efbb1c..c504de8 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -105,18 +105,25 @@ } } - function detectParserForColumn( table, rows, cellIndex ) { + function detectParserForColumn( table, rows, column ) { var l = parsers.length, + cellIndex, nodeValue, // Start with 1 because 0 is the fallback parser i = 1, + lastRowIndex = -1, rowIndex = 0, concurrent = 0, + empty = 0, needed = ( rows.length > 4 ) ? 5 : rows.length; while ( i < l ) { - if ( rows[rowIndex] && rows[rowIndex].cells[cellIndex] ) { - nodeValue = $.trim( getElementSortKey( rows[rowIndex].cells[cellIndex] ) ); + if ( rows[rowIndex] ) { + if ( rowIndex != lastRowIndex) { + lastRowIndex = rowIndex; + cellIndex = $(rows[rowIndex]).data( 'columnToCell' )[column]; + nodeValue = $.trim( getElementSortKey( rows[rowIndex].cells[cellIndex] ) ); + } } else { nodeValue = ''; } @@ -134,13 +141,22 @@ i++; rowIndex = 0; concurrent = 0; + empty = 0; } } else { // Empty cell + empty++; rowIndex++; - if ( rowIndex > rows.length ) { - rowIndex = 0; + if ( rowIndex >= rows.length ) { + if ( concurrent >= rows.length - empty) { + //Confirmed the parser for all filled cells + return parsers[i]; + } + // Check next parser, reset rows i++; + rowIndex = 0; + concurrent = 0; + empty = 0; } } } @@ -150,24 +166,23 @@ } function buildParserCache( table, $headers ) { - var sortType, cells, len, i, parser, + var sortType, len, j, parser, rows = table.tBodies[0].rows, + config = $(table).data( 'tablesorter' ).config, parsers = []; if ( rows[0] ) { - cells = rows[0].cells; - len = cells.length; - - for ( i = 0; i < len; i++ ) { + len = config.columns; + for ( j = 0; j < len; j++ ) { parser = false; - sortType = $headers.eq( i ).data( 'sortType' ); +