jenkins-bot has submitted this change and it was merged. Change subject: Use OOUI checkboxes ......................................................................
Use OOUI checkboxes Bug: T148252 Change-Id: I8636f32330e23814ba3b4c0f5e22e55aaf77883e --- M includes/HTMLFeatureField.php M includes/NewHTMLCheckField.php M resources/betafeatures.nojs.less M tests/phpunit/HTMLFeatureFieldTest.php M tests/phpunit/NewHTMLCheckFieldTest.php 5 files changed, 52 insertions(+), 69 deletions(-) Approvals: Bartosz Dziewoński: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/HTMLFeatureField.php b/includes/HTMLFeatureField.php index fdc62eb..f8c42e9 100644 --- a/includes/HTMLFeatureField.php +++ b/includes/HTMLFeatureField.php @@ -28,9 +28,6 @@ const OPTION_ENABLED = '1'; const OPTION_DISABLED = '0'; - // suppress labels (see getHeaderHTML) - protected $includeLabel = false; - function __construct( $options ) { // We need the new checkbox style to have a sane-looking field $options['mw-ui'] = true; @@ -42,13 +39,21 @@ 'class' => 'mw-ui-feature-header', ) ); + $attrs = $this->getTooltipAndAccessKey(); + $attrs['id'] = $this->mID; + $attrs['class'] = 'mw-ui-feature-toggle'; + + if ( isset( $this->mParams['disabled'] ) && + $this->mParams['disabled'] === true ) { + $attrs['disabled'] = true; + } + + $html .= Html::openElement( 'div', array( 'class' => 'mw-ui-feature-title-contain', ) ); - $html .= Html::rawElement( 'div', array( - 'class' => 'mw-ui-feature-title', - ), $this->getPostCheckboxLabelHTML() ); + $html .= $this->getCheckboxHTML( $value, $attrs ); // Close -title-contain $html .= Html::closeElement( 'div' ); @@ -267,10 +272,6 @@ function getInputHTML( $value ) { $html = ''; - $attrs = $this->getTooltipAndAccessKey(); - $attrs['id'] = $this->mID; - $attrs['class'] = 'mw-ui-feature-toggle'; - $divClasses = array( 'mw-ui-feature-field', ); @@ -280,16 +281,9 @@ $divClasses[] = $this->mClass; } - if ( isset( $this->mParams['disabled'] ) && - $this->mParams['disabled'] === true ) { - $attrs['disabled'] = true; - } - $html .= Html::openElement( 'div', array( 'class' => implode( ' ', $divClasses ), ) ); - - $html .= $this->getCheckboxHTML( $value, $attrs ); $html .= Html::openElement( 'div', array( 'class' => 'mw-ui-feature-contain', diff --git a/includes/NewHTMLCheckField.php b/includes/NewHTMLCheckField.php index d4e6998..c754495 100644 --- a/includes/NewHTMLCheckField.php +++ b/includes/NewHTMLCheckField.php @@ -42,47 +42,29 @@ $value = !$value; } - $containerClasses = array( 'mw-ui-checkbox' ); - $labelAttrs = array( 'for' => $this->mID ); - - if ( $value ) { - $containerClasses[] = 'mw-ui-checked'; - } - - if ( $attr === null ) { - $attr = $this->getTooltipAndAccessKey(); - } - - $attr['id'] = $this->mID; - - $classes = array(); - - if ( isset( $attr['class'] ) ) { - $classes[] = $attr['class']; - } - - if ( isset( $this->mParams['disabled'] ) && $this->mParams['disabled'] === true ) { - $attr['disabled'] = 'disabled'; - } - - if ( $this->mClass !== '' ) { - $classes[] = $this->mClass; - } - - if ( $classes ) { - $attr['class'] = implode( ' ', $classes ); - } - $out = $this->mParent->getOutput(); // @todo Ew, these should be split into checkbox styles and preferences page styles $out->addModules( 'ext.betaFeatures' ); $out->addModuleStyles( 'ext.betaFeatures.styles' ); - $out->addModuleStyles( 'mediawiki.ui.checkbox' ); - $labelHtml = $this->includeLabel ? $this->getPostCheckboxLabelHTML() : ''; - return Html::openElement( 'div', array( 'class' => $containerClasses ) ) . - Xml::check( $this->mName, $value, $attr ) . - Html::rawElement( 'label', $labelAttrs ) . - $labelHtml . + $out->enableOOUI(); + + // TODO: Support $this->getTooltipAndAccessKey? + + return Html::openElement( 'div', array( 'class' => 'mw-ui-feature-checkbox' ) ) . + new OOUI\FieldLayout( + new OOUI\CheckboxInputWidget( [ + 'name' => $this->mName, + 'selected' => $value, + 'value' => 1, + 'classes' => $this->mClass ? [ $this->mClass ] : [], + 'disabled' => isset( $this->mParams['disabled'] ) && + $this->mParams['disabled'] === true, + ] ), + [ + 'align' => 'inline', + 'label' => $this->includeLabel ? $this->mLabel : '', + ] + ) . Html::closeElement( 'div' ); } diff --git a/resources/betafeatures.nojs.less b/resources/betafeatures.nojs.less index a1cf991..5cfa140 100644 --- a/resources/betafeatures.nojs.less +++ b/resources/betafeatures.nojs.less @@ -34,13 +34,6 @@ padding-top: 10px; } -.mw-ui-feature-title { - margin: 0; - padding: 0; - font-size: 24px; - line-height: 36px; -} - .mw-ui-feature-header { width: 100%; border-bottom: 1px solid #e5e5e5; @@ -56,6 +49,7 @@ .mw-ui-feature-info-links, .mw-ui-feature-title-contain { display: inline-block; + vertical-align: bottom; } .mw-ui-feature-screenshot-contain, @@ -119,12 +113,25 @@ margin: 1em 0 0 0; } -#mw-prefsection-betafeatures { - .mw-ui-checkbox { - float: left; +.mw-ui-feature-title-contain { + margin-left: -42px; + margin-right: 42px; + margin-bottom: -10px +} + +.mw-ui-feature-checkbox { + float: left; + + .oo-ui-fieldLayout.oo-ui-fieldLayout-align-inline { + margin-bottom: 0; } } +.mw-ui-feature-title-contain .oo-ui-labelElement-label { + font-size: 24px; + line-height: 36px; +} + .mw-htmlform-field-HTMLTextBlockField .mw-input { padding-bottom: 15px; } diff --git a/tests/phpunit/HTMLFeatureFieldTest.php b/tests/phpunit/HTMLFeatureFieldTest.php index 850f07b..e7776ba 100644 --- a/tests/phpunit/HTMLFeatureFieldTest.php +++ b/tests/phpunit/HTMLFeatureFieldTest.php @@ -45,11 +45,11 @@ 'message' => 'Table row with class name not found.', ), array( - 'pattern' => '#<div class="mw-ui-checkbox"><input name="wpblahblahblah" type="checkbox" value="1" id="mw-input-wpblahblahblah" class="mw-ui-feature-toggle" /><label for="mw-input-wpblahblahblah"></label>#', - 'message' => 'Styled checkbox label and input not found.', + 'pattern' => "#<input type='checkbox' tabindex='0' aria-disabled='false' name='wpblahblahblah' value='1' class='oo-ui-inputWidget-input'>#", + 'message' => 'Styled checkbox input not found.', ), array( - 'pattern' => '#<label for="mw-input-wpblahblahblah" class="mw-ui-text-check-label">blah blah blah</label>#', + 'pattern' => "#<span class='oo-ui-labelElement-label'>blah blah blah</span>#", 'message' => 'Checkbox label not found.', ), array( diff --git a/tests/phpunit/NewHTMLCheckFieldTest.php b/tests/phpunit/NewHTMLCheckFieldTest.php index e32fd72..9d02a6e 100644 --- a/tests/phpunit/NewHTMLCheckFieldTest.php +++ b/tests/phpunit/NewHTMLCheckFieldTest.php @@ -38,7 +38,7 @@ $html = $form->getHTML( false ); $this->assertRegExp( '#<tr class="mw-htmlform-field-NewHTMLCheckField">#', $html, 'Table row with class name not found.' ); - $this->assertRegExp( '#<div class="mw-ui-checkbox mw-ui-checked"><input name="wpblahblahblah" type="checkbox" value="1" checked="checked" id="mw-input-wpblahblahblah" /><label for="mw-input-wpblahblahblah"></label><label for="mw-input-wpblahblahblah" class="mw-ui-text-check-label">blah blah blah</label>#', $html, 'Styled checkbox label and input not found.' ); - $this->assertRegExp( '#<label for="mw-input-wpblahblahblah" class="mw-ui-text-check-label">blah blah blah</label>#', $html, 'Checkbox label not found.' ); + $this->assertRegExp( "#<input type='checkbox' tabindex='0' aria-disabled='false' name='wpblahblahblah' value='1' checked='checked' class='oo-ui-inputWidget-input'>#", $html, 'Styled input not found.' ); + $this->assertRegExp( "#<span class='oo-ui-labelElement-label'>blah blah blah</span>#", $html, 'Checkbox label not found.' ); } } -- To view, visit https://gerrit.wikimedia.org/r/315850 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8636f32330e23814ba3b4c0f5e22e55aaf77883e Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/BetaFeatures Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: MarkTraceur <mholmqu...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits