Convert SimpleCaptcha to OOUI

Change-Id: Ic904b53b2ac489be572f4b6096ddc8c92c482a59
This commit is contained in:
Ed Sanders 2018-12-07 13:23:39 -05:00
parent 7951ce701e
commit 423234cb77
3 changed files with 37 additions and 15 deletions

View file

@ -122,21 +122,30 @@ class SimpleCaptcha {
$index = $this->storeCaptcha( $captcha ); $index = $this->storeCaptcha( $captcha );
return [ return [
'html' => "<p><label for=\"wpCaptchaWord\">{$captcha['question']} = </label>" . 'html' =>
Xml::element( 'input', [ new OOUI\FieldLayout(
'name' => 'wpCaptchaWord', new OOUI\NumberInputWidget( [
'class' => 'mw-ui-input', 'name' => 'wpCaptchaWord',
'id' => 'wpCaptchaWord', 'classes' => [ 'simplecaptcha-answer' ],
'size' => 5, 'id' => 'wpCaptchaWord',
'autocomplete' => 'off', 'autocomplete' => 'off',
// tab in before the edit textarea // tab in before the edit textarea
'tabindex' => $tabIndex ] ) . 'tabIndex' => $tabIndex
"</p>\n" . ] ),
Xml::element( 'input', [ [
'type' => 'hidden', 'align' => 'left',
'name' => 'wpCaptchaId', 'label' => $captcha['question'] . ' = ',
'id' => 'wpCaptchaId', 'classes' => [ 'simplecaptcha-field' ],
'value' => $index ] ) ]
) .
new OOUI\HiddenInputWidget( [
'name' => 'wpCaptchaId',
'id' => 'wpCaptchaId',
'value' => $index
] ),
'modulestyles' => [
'ext.confirmEdit.simpleCaptcha'
]
]; ];
} }

View file

@ -0,0 +1,10 @@
.simplecaptcha-field .oo-ui-fieldLayout-header {
/* stylelint-disable declaration-no-important */
width: auto !important;
padding-right: 1em !important;
/* stylelint-enable declaration-no-important */
}
.simplecaptcha-answer.oo-ui-textInputWidget {
width: 5em;
}

View file

@ -73,6 +73,9 @@
}, },
"ext.confirmEdit.visualEditor": { "ext.confirmEdit.visualEditor": {
"scripts": "ve-confirmedit/ve.init.mw.CaptchaSaveErrorHandler.js" "scripts": "ve-confirmedit/ve.init.mw.CaptchaSaveErrorHandler.js"
},
"ext.confirmEdit.simpleCaptcha": {
"styles": "../SimpleCaptcha/resources/ext.confirmEdit.simpleCaptcha.css"
} }
}, },
"VisualEditorPluginModules": [ "VisualEditorPluginModules": [