jenkins-bot has submitted this change and it was merged.

Change subject: TitleInputWidget: Allow suppressing search suggestions
......................................................................


TitleInputWidget: Allow suppressing search suggestions

Needed for Ice69df851137e3454ae2c9f4c75494b18cf8a75a.

Change-Id: Ibc7846bb08abdd1ebf271dfce526dd935f38e111
---
M includes/widget/TitleInputWidget.php
M resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
2 files changed, 13 insertions(+), 3 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/widget/TitleInputWidget.php 
b/includes/widget/TitleInputWidget.php
index d3e2851..8b8010e 100644
--- a/includes/widget/TitleInputWidget.php
+++ b/includes/widget/TitleInputWidget.php
@@ -14,11 +14,13 @@
 
        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,9 +30,11 @@
                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
@@ -48,6 +52,9 @@
                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 66b009f..4e3228f 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;
        };

-- 
To view, visit https://gerrit.wikimedia.org/r/230841
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc7846bb08abdd1ebf271dfce526dd935f38e111
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: Edokter <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to