wiki.techinc.nl/includes/widget/SearchInputWidget.php
Florian 18c6615d01 MediaWiki Widgets: Add new SearchInputWidget
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
2016-03-03 16:29:40 +00:00

52 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 );
}
}