Merge "HTMLFormField: Use Codex TextArea for multiselect fields"
This commit is contained in:
commit
23728ecc4e
3 changed files with 64 additions and 0 deletions
|
|
@ -122,6 +122,11 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
|
|||
return [ 'mediawiki.widgets.NamespacesMultiselectWidget' ];
|
||||
}
|
||||
|
||||
public function getInputCodex( $value, $hasErrors ) {
|
||||
$textAreaField = new HTMLTextAreaField( $this->mParams );
|
||||
return $textAreaField->getInputCodex( $value, $hasErrors );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @deprecated since 1.42 */
|
||||
|
|
|
|||
|
|
@ -163,6 +163,60 @@ class HTMLTextAreaField extends HTMLFormField {
|
|||
'rows' => $this->getRows(),
|
||||
] + $attribs );
|
||||
}
|
||||
|
||||
public function getInputCodex( $value, $hasErrors ) {
|
||||
$textareaClasses = [ 'cdx-text-area__textarea' ];
|
||||
if ( $this->mClass !== '' ) {
|
||||
$textareaClasses[] = $this->mClass;
|
||||
}
|
||||
if ( $this->mUseEditFont ) {
|
||||
$userOptionsLookup = MediaWikiServices::getInstance()
|
||||
->getUserOptionsLookup();
|
||||
// The following classes can be used here:
|
||||
// * mw-editfont-monospace
|
||||
// * mw-editfont-sans-serif
|
||||
// * mw-editfont-serif
|
||||
$textareaClasses[] =
|
||||
'mw-editfont-' .
|
||||
$userOptionsLookup->getOption( $this->mParent->getUser(), 'editfont' );
|
||||
$this->mParent->getOutput()->addModuleStyles( 'mediawiki.editfont.styles' );
|
||||
}
|
||||
|
||||
$textareaAttribs = [
|
||||
'id' => $this->mID,
|
||||
'cols' => $this->getCols(),
|
||||
'rows' => $this->getRows(),
|
||||
'spellcheck' => $this->getSpellCheck(),
|
||||
'class' => $textareaClasses
|
||||
] + $this->getTooltipAndAccessKey();
|
||||
|
||||
if ( $this->mPlaceholder !== '' ) {
|
||||
$textareaAttribs['placeholder'] = $this->mPlaceholder;
|
||||
}
|
||||
|
||||
$allowedParams = [
|
||||
'maxlength',
|
||||
'minlength',
|
||||
'tabindex',
|
||||
'disabled',
|
||||
'readonly',
|
||||
'required',
|
||||
'autofocus'
|
||||
];
|
||||
$textareaAttribs += $this->getAttributes( $allowedParams );
|
||||
|
||||
$textarea = Html::textarea( $this->mName, $value, $textareaAttribs );
|
||||
|
||||
$wrapperAttribs = [ 'class' => [ 'cdx-text-area' ] ];
|
||||
if ( $hasErrors ) {
|
||||
$wrapperAttribs['class'][] = 'cdx-text-area--status-error';
|
||||
}
|
||||
return Html::rawElement(
|
||||
'div',
|
||||
$wrapperAttribs,
|
||||
$textarea
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated since 1.42 */
|
||||
|
|
|
|||
|
|
@ -146,6 +146,11 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField {
|
|||
return [ 'mediawiki.widgets.TitlesMultiselectWidget' ];
|
||||
}
|
||||
|
||||
public function getInputCodex( $value, $hasErrors ) {
|
||||
$textAreaField = new HTMLTextAreaField( $this->mParams );
|
||||
return $textAreaField->getInputCodex( $value, $hasErrors );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @deprecated since 1.42 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue