SearchInputWidget is similar to a TitleInputWidget, but doesn't has a visible loading indication, doesn't highlight the first result and uses the opensearch api endpoint for suggestions, instead of prefixsearch. Extra points: * Improve documentation of mw.widgets.TitleInputWidget's configuration option validateTitle Bug: T118443 Change-Id: I8b8098041fe2971389fa908d007d2e77255829ec
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
||
/**
|
||
* MediaWiki Widgets – SearchInputWidget class.
|
||
*
|
||
* @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
|
||
* @license The MIT License (MIT); see LICENSE.txt
|
||
*/
|
||
namespace MediaWiki\Widget;
|
||
|
||
/**
|
||
* Search input widget.
|
||
*/
|
||
class SearchInputWidget extends TitleInputWidget {
|
||
|
||
protected $pushPending = false;
|
||
protected $validateTitle = false;
|
||
protected $highlightFirst = false;
|
||
|
||
/**
|
||
* @param array $config Configuration options
|
||
* @param int|null $config['pushPending'] Whether the input should be visually marked as
|
||
* "pending", while requesting suggestions (default: true)
|
||
*/
|
||
public function __construct( array $config = [] ) {
|
||
// Parent constructor
|
||
parent::__construct(
|
||
array_merge( [
|
||
'infusable' => true,
|
||
'maxLength' => null,
|
||
'type' => 'search',
|
||
'icon' => 'search'
|
||
], $config )
|
||
);
|
||
|
||
// Properties, which are ignored in PHP and just shipped back to JS
|
||
if ( isset( $config['pushPending'] ) ) {
|
||
$this->pushPending = $config['pushPending'];
|
||
}
|
||
|
||
// Initialization
|
||
$this->addClasses( [ 'mw-widget-searchInputWidget' ] );
|
||
}
|
||
|
||
protected function getJavaScriptClassName() {
|
||
return 'mw.widgets.SearchInputWidget';
|
||
}
|
||
|
||
public function getConfig( &$config ) {
|
||
$config['pushPending'] = $this->pushPending;
|
||
return parent::getConfig( $config );
|
||
}
|
||
}
|