* AuthenticationRequest::$required is now changed from REQUIRED to PRIMARY_REQUIRED
on requests needed by primary providers even if all primaries need them.
Primary providers are discouraged from returning multiple REQUIRED requests.
+* OOjs UI PHP widgets constructed with the `'infusable' => true` config option
+ will no longer be automatically infused. You should call `OO.ui.infuse()`
+ on them yourself from your JavaScript code.
== Compatibility ==
'infusable' => $infusable,
];
+ if ( $infusable && $this->shouldInfuseOOUI() ) {
+ $this->mParent->getOutput()->addModules( 'oojs-ui-core' );
+ $config['classes'][] = 'mw-htmlform-field-autoinfuse';
+ }
+
// the element could specify, that the label doesn't need to be added
$label = $this->getLabel();
if ( $label ) {
return new OOUI\FieldLayout( $inputField, $config );
}
+ /**
+ * Whether the field should be automatically infused. Note that all OOjs UI HTMLForm fields are
+ * infusable (you can call OO.ui.infuse() on them), but not all are infused by default, since
+ * there is no benefit in doing it e.g. for buttons and it's a small performance hit on page load.
+ *
+ * @return bool
+ */
+ protected function shouldInfuseOOUI() {
+ // Always infuse fields with help text, since the interface for it is nicer with JS
+ return $this->getHelpText() !== null;
+ }
+
/**
* Get the complete raw fields for the input, including help text,
* labels, and whatever.
'disabled' => $disabled,
] + $attribs );
}
+
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
}
) );
}
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
+
function formatOptions( $options, $value ) {
global $wgUseMediaWikiUIEverywhere;
'disabled' => $disabled,
] + $attribs );
}
+
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
}
'includeAllValue' => $this->mAllValue,
] );
}
+
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
}
return new TitleInputWidget( $params );
}
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
+
public function getInputHtml( $value ) {
// add mw-searchInput class to enable search suggestions for non-OOUI, too
$this->mClass .= 'mw-searchInput';
return new UserInputWidget( $params );
}
+ protected function shouldInfuseOOUI() {
+ return true;
+ }
+
public function getInputHtml( $value ) {
// add the required module and css class for user suggestions in non-OOUI mode
$this->mParent->getOutput()->addModules( 'mediawiki.userSuggest' );
'help' => new OOUI\HtmlSnippet( $this->msg( 'movepagetalktext' )->parseAsBlock() ),
'align' => 'inline',
'infusable' => true,
+ 'id' => 'wpMovetalk-field',
]
);
}
'scripts' => [
'resources/src/mediawiki/htmlform/htmlform.js',
'resources/src/mediawiki/htmlform/autocomplete.js',
+ 'resources/src/mediawiki/htmlform/autoinfuse.js',
'resources/src/mediawiki/htmlform/checkmatrix.js',
'resources/src/mediawiki/htmlform/cloner.js',
'resources/src/mediawiki/htmlform/hide-if.js',
* JavaScript for Special:MovePage
*/
jQuery( function () {
+ // Infuse for pretty dropdown
OO.ui.infuse( 'wpNewTitle' );
+ // Limit to 255 bytes, not characters
OO.ui.infuse( 'wpReason' ).$input.byteLimit();
+ // Infuse for nicer "help" popup
+ OO.ui.infuse( 'wpMovetalk-field' );
} );
--- /dev/null
+/*
+ * HTMLForm enhancements:
+ * Infuse some OOjs UI HTMLForm fields (those which benefit from always being infused).
+ */
+( function ( mw ) {
+
+ mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
+ var $oouiNodes, modules;
+
+ $oouiNodes = $root.find( '.mw-htmlform-field-autoinfuse' );
+ if ( $oouiNodes.length ) {
+ // The modules are preloaded (added server-side in HTMLFormField, and the individual fields
+ // which need extra ones), but this module doesn't depend on them. Wait until they're loaded.
+ modules = [ 'oojs-ui-core' ];
+ if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLTitleTextField' ).length ) {
+ // FIXME: TitleInputWidget should be in its own module
+ modules.push( 'mediawiki.widgets' );
+ }
+ if ( $oouiNodes.filter( '.mw-htmlform-field-HTMLUserTextField' ).length ) {
+ modules.push( 'mediawiki.widgets.UserInputWidget' );
+ }
+ if (
+ $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespace' ).length ||
+ $oouiNodes.filter( '.mw-htmlform-field-HTMLSelectNamespaceWithButton' ).length
+ ) {
+ // FIXME: NamespaceInputWidget should be in its own module (probably?)
+ modules.push( 'mediawiki.widgets' );
+ }
+ mw.loader.using( modules ).done( function () {
+ $oouiNodes.each( function () {
+ OO.ui.infuse( this );
+ } );
+ } );
+ }
+
+ } );
+
+}( mediaWiki ) );
// Things outside the wikipage content
$( function () {
- var $nodes, $oouiNodes;
+ var $nodes;
if ( !supportsPlaceholder ) {
// Exclude content to avoid hitting it twice for the (first) wikipage content
// Add accesskey hints to the tooltips
$( '[accesskey]' ).updateTooltipAccessKeys();
- // Infuse OOUI widgets, if any are present
- $oouiNodes = $( '[data-ooui]' );
- if ( $oouiNodes.length ) {
- // FIXME: We should only load the widgets that are being infused
- mw.loader.using( [
- 'mediawiki.widgets',
- 'mediawiki.widgets.UserInputWidget',
- 'mediawiki.widgets.SearchInputWidget'
- ] ).done( function () {
- $oouiNodes.each( function () {
- OO.ui.infuse( this );
- } );
- } );
- }
-
$nodes = $( '.catlinks[data-mw="interface"]' );
if ( $nodes.length ) {
/**