$htmlForm
->setMethod( 'get' )
->setAction( wfScript() )
+ ->setCollapsible( true )
->setId( 'mw-history-searchform' )
->setSubmitText( $this->msg( 'historyaction-submit' )->text() )
->setWrapperAttributes( [ 'id' => 'mw-history-search' ] )
*/
protected $mAction = false;
+ /**
+ * Whether the HTML form can be collapsed
+ * @since 1.33
+ * @var bool
+ */
+ protected $mCollapsible = false;
+
+ /**
+ * Whether the HTML form IS collapsed by default
+ * @since 1.33
+ * @var bool
+ */
+ protected $mCollapsed = false;
+
/**
* Form attribute autocomplete. A typical value is "off". null does not set the attribute
* @since 1.27
return '' . $this->mPre . $html . $this->mPost;
}
+ /**
+ * Make the form collapsible
+ * @since 1.33
+ * @param bool $collapsed whether it should be by default
+ * @return HTMLForm $this for chaining calls (since 1.20)
+ */
+ public function setCollapsible( $collapsed = false ) {
+ $this->mCollapsible = true;
+ $this->mCollapsed = $collapsed;
+ return $this;
+ }
+
/**
* Get HTML attributes for the `<form>` tag.
* @return array
public function wrapForm( $html ) {
if ( is_string( $this->mWrapperLegend ) ) {
+ $classes = $this->mCollapsible ? [ 'mw-collapsible' ] : [];
+ if ( $this->mCollapsed ) {
+ $classes[] = 'mw-collapsed';
+ }
$content = new OOUI\FieldsetLayout( [
'label' => $this->mWrapperLegend,
- 'items' => [
- new OOUI\Widget( [
- 'content' => new OOUI\HtmlSnippet( $html )
- ] ),
- ],
+ 'classes' => $classes,
+ 'group' => new OOUI\StackLayout( [
+ 'expanded' => false,
+ 'classes' => [ 'oo-ui-fieldsetLayout-group mw-collapsible-content' ],
+ 'items' => [
+ new OOUI\Widget( [
+ 'content' => new OOUI\HtmlSnippet( $html )
+ ] ),
+ ],
+ ] ),
] + OOUI\Element::configFromHtmlAttributes( $this->mWrapperAttributes ) );
} else {
$content = new OOUI\HtmlSnippet( $html );
}
+ $classes = [ 'mw-htmlform', 'mw-htmlform-ooui' ];
$form = new OOUI\FormLayout( $this->getFormAttributes() + [
- 'classes' => [ 'mw-htmlform', 'mw-htmlform-ooui' ],
+ 'classes' => $classes,
'content' => $content,
] );
],
],
'mediawiki.action.history' => [
+ 'dependencies' => [ 'jquery.makeCollapsible' ],
'scripts' => 'resources/src/mediawiki.action/mediawiki.action.history.js',
'styles' => 'resources/src/mediawiki.action/mediawiki.action.history.css',
],
}
}
+fieldset.mw-collapsible .mw-collapsible-toggle {
+ position: absolute;
+ right: 0;
+ z-index: 1;
+}
+
// special treatment for list items to match above
// !important necessary to override overly-specific float left and right above.
ol.mw-collapsible:not( @{exclude} ):before,
/* Basic styles for the history page */
-@import 'mediawiki.mixins';
-
-/* Visually hide repeating text, but leave in for better form navigation on screen readers. */
-.action-history .mw-htmlform-ooui .oo-ui-fieldsetLayout:first-child .oo-ui-fieldsetLayout-header {
- .mixin-screen-reader-text();
-}
#pagehistory .history-user {
margin-left: 0.4em;