3 * MediaWiki Widgets – SearchInputWidget class.
5 * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
6 * @license The MIT License (MIT); see LICENSE.txt
8 namespace MediaWiki\Widget
;
11 * Search input widget.
13 class SearchInputWidget
extends TitleInputWidget
{
15 protected $pushPending = false;
16 protected $performSearchOnClick = true;
17 protected $validateTitle = false;
18 protected $highlightFirst = false;
21 * @param array $config Configuration options
22 * @param int|null $config['pushPending'] Whether the input should be visually marked as
23 * "pending", while requesting suggestions (default: true)
24 * @param boolean|null $config['performSearchOnClick'] If true, the script will start a search
25 * whenever a user hits a suggestion. If false, the text of the suggestion is inserted into the
26 * text field only (default: true)
28 public function __construct( array $config = [] ) {
29 $config = array_merge( [
34 'dataLocation' => 'content',
38 parent
::__construct( $config );
40 // Properties, which are ignored in PHP and just shipped back to JS
41 if ( isset( $config['pushPending'] ) ) {
42 $this->pushPending
= $config['pushPending'];
45 if ( isset( $config['performSearchOnClick'] ) ) {
46 $this->performSearchOnClick
= $config['performSearchOnClick'];
49 if ( $config['dataLocation'] ) {
50 // identifies the location of the search bar for tracking purposes
51 $this->dataLocation
= $config['dataLocation'];
55 $this->addClasses( [ 'mw-widget-searchInputWidget' ] );
58 protected function getJavaScriptClassName() {
59 return 'mw.widgets.SearchInputWidget';
62 public function getConfig( &$config ) {
63 $config['pushPending'] = $this->pushPending
;
64 $config['performSearchOnClick'] = $this->performSearchOnClick
;
65 if ( $this->dataLocation
) {
66 $config['dataLocation'] = $this->dataLocation
;
68 return parent
::getConfig( $config );