From: Bartosz DziewoƄski Date: Tue, 11 Aug 2015 18:29:05 +0000 (+0200) Subject: TitleInputWidget: Allow suppressing search suggestions X-Git-Tag: 1.31.0-rc.0~9920^2~3 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=fab41453ccd10f33b27ead047848be6bb23f3d8c;p=lhc%2Fweb%2Fwiklou.git TitleInputWidget: Allow suppressing search suggestions Needed for Ice69df851137e3454ae2c9f4c75494b18cf8a75a. Change-Id: Ibc7846bb08abdd1ebf271dfce526dd935f38e111 --- diff --git a/includes/widget/TitleInputWidget.php b/includes/widget/TitleInputWidget.php index d3e2851982..8b8010e4df 100644 --- a/includes/widget/TitleInputWidget.php +++ b/includes/widget/TitleInputWidget.php @@ -14,11 +14,13 @@ class TitleInputWidget extends \OOUI\TextInputWidget { protected $namespace = null; protected $relative = null; + protected $suggestions = null; /** * @param array $config Configuration options * @param int|null $config['namespace'] Namespace to prepend to queries * @param bool|null $config['relative'] If a namespace is set, return a title relative to it (default: true) + * @param bool|null $config['suggestions'] Display search suggestions (default: true) */ public function __construct( array $config = array() ) { // Parent constructor @@ -28,10 +30,12 @@ class TitleInputWidget extends \OOUI\TextInputWidget { if ( isset( $config['namespace'] ) ) { $this->namespace = $config['namespace']; } - if ( isset( $config['relative'] ) ) { $this->relative = $config['relative']; } + if ( isset( $config['suggestions'] ) ) { + $this->suggestions = $config['suggestions']; + } // Initialization $this->addClasses( array( 'mw-widget-titleInputWidget' ) ); @@ -48,6 +52,9 @@ class TitleInputWidget extends \OOUI\TextInputWidget { if ( $this->relative !== null ) { $config['relative'] = $this->relative; } + if ( $this->suggestions !== null ) { + $config['suggestions'] = $this->suggestions; + } return parent::getConfig( $config ); } } diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js index 66b009f3c5..4e3228f70c 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js @@ -18,6 +18,7 @@ * @cfg {number} [limit=10] Number of results to show * @cfg {number} [namespace] Namespace to prepend to queries * @cfg {boolean} [relative=true] If a namespace is set, return a title relative to it + * @cfg {boolean} [suggestions=true] Display search suggestions * @cfg {boolean} [showRedirectTargets=true] Show the targets of redirects * @cfg {boolean} [showRedlink] Show red link to exact match if it doesn't exist * @cfg {boolean} [showImages] Show page images @@ -40,6 +41,7 @@ this.limit = config.limit || 10; this.namespace = config.namespace !== undefined ? config.namespace : null; this.relative = config.relative !== undefined ? config.relative : true; + this.suggestions = config.suggestions !== undefined ? config.suggestions : true; this.showRedirectTargets = config.showRedirectTargets !== false; this.showRedlink = !!config.showRedlink; this.showImages = !!config.showImages; @@ -55,6 +57,7 @@ if ( this.showDescriptions ) { this.lookupMenu.$element.addClass( 'mw-widget-titleInputWidget-menu-withDescriptions' ); } + this.setLookupsDisabled( !this.suggestions ); this.interwikiPrefixes = []; this.interwikiPrefixesPromise = new mw.Api().get( { @@ -82,7 +85,7 @@ this.closeLookupMenu(); this.setLookupsDisabled( true ); this.setValue( item.getData() ); - this.setLookupsDisabled( false ); + this.setLookupsDisabled( !this.suggestions ); }; /** @@ -97,7 +100,7 @@ // Parent method retval = mw.widgets.TitleInputWidget.parent.prototype.focus.apply( this, arguments ); - this.setLookupsDisabled( false ); + this.setLookupsDisabled( !this.suggestions ); return retval; };