From: Volker E Date: Fri, 16 Nov 2018 01:53:59 +0000 (-0800) Subject: CheckMatrixWidget: Re-instate HTMLForm CheckMatrix styling X-Git-Tag: 1.34.0-rc.0~3484^2~2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=50c878ca79104a4789cf436e0f47be6c0e39ce8f;p=lhc%2Fweb%2Fwiklou.git CheckMatrixWidget: Re-instate HTMLForm CheckMatrix styling Adding `tbody` with extra class and add additional `thead`. Bug: T209667 Change-Id: I3f707f667df11e9bfd5ce1fcc51ccde0cd12e9be --- diff --git a/includes/widget/CheckMatrixWidget.php b/includes/widget/CheckMatrixWidget.php index 8038c548af..017e616571 100644 --- a/includes/widget/CheckMatrixWidget.php +++ b/includes/widget/CheckMatrixWidget.php @@ -58,7 +58,11 @@ class CheckMatrixWidget extends \OOUI\Widget { // Build the table $table = new \OOUI\Tag( 'table' ); + $table->addClasses( [ 'mw-htmlform-matrix mw-widget-checkMatrixWidget-matrix' ] ); + $thead = new \OOUI\Tag( 'thead' ); + $table->appendContent( $thead ); $tr = new \OOUI\Tag( 'tr' ); + // Build the header $tr->appendContent( $this->getCellTag( "\u{00A0}" ) ); foreach ( $this->columns as $columnLabel => $columnTag ) { @@ -66,11 +70,13 @@ class CheckMatrixWidget extends \OOUI\Widget { $this->getCellTag( new \OOUI\HtmlSnippet( $columnLabel ) ) ); } - $table->appendContent( $tr ); + $thead->appendContent( $tr ); // Build the options matrix + $tbody = new \OOUI\Tag( 'tbody' ); + $table->appendContent( $tbody ); foreach ( $this->rows as $rowLabel => $rowTag ) { - $table->appendContent( + $tbody->appendContent( $this->getTableRow( $rowLabel, $rowTag ) ); } diff --git a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js index 01165ca082..73ee8404bf 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js @@ -21,6 +21,8 @@ mw.widgets.CheckMatrixWidget = function MWWCheckMatrixWidget( config ) { var $headRow = $( '' ), $table = $( '' ), + $thead = $( '' ), + $tbody = $( '' ), widget = this; config = config || {}; @@ -44,7 +46,7 @@ $.each( this.columns, function ( columnLabel ) { $headRow.append( $( '
' ).html( columnLabel ) ); } ); - $table.append( $headRow ); + $thead.append( $headRow ); // Build table // eslint-disable-next-line no-restricted-properties @@ -78,8 +80,11 @@ $row.append( $( '' ).append( checkbox.$element ) ); } ); - $table.append( $row ); + $tbody.append( $row ); } ); + $table + .addClass( 'mw-htmlform-matrix mw-widget-checkMatrixWidget-matrix' ) + .append( $thead, $tbody ); this.$element .addClass( 'mw-widget-checkMatrixWidget' )