Merge "Setting Urdu translations of some magic words and special pages"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.SearchInputWidget.js
index ae30283..c25ab45 100644 (file)
@@ -14,7 +14,7 @@
         *
         * @constructor
         * @param {Object} [config] Configuration options
-        * @cfg {boolean} [pushPending=true] Visually mark the input field as "pending", while
+        * @cfg {boolean} [pushPending=false] Visually mark the input field as "pending", while
         *  requesting suggestions.
         * @cfg {boolean} [performSearchOnClick=true] If true, the script will start a search when-
         *  ever a user hits a suggestion. If false, the text of the suggestion is inserted into the
@@ -33,8 +33,7 @@
                        icon: 'search',
                        maxLength: undefined,
                        performSearchOnClick: true,
-                       dataLocation: 'header',
-                       namespace: 0
+                       dataLocation: 'header'
                }, config );
 
                // Parent constructor
                        } );
                }.bind( this ) );
 
+               this.connect( this, {
+                       change: 'onChange'
+               } );
+
                this.$element.addClass( 'oo-ui-textInputWidget-type-search' );
                this.updateSearchIndicator();
                this.connect( this, {
         * @see OO.ui.SearchInputWidget#onChange
         */
        mw.widgets.SearchInputWidget.prototype.onChange = function () {
-               mw.widgets.SearchInputWidget.parent.prototype.onChange.call( this );
                this.updateSearchIndicator();
        };
 
         */
        mw.widgets.SearchInputWidget.prototype.getOptionsFromData = function ( data ) {
                var items = [],
+                       titles = data.data[ 1 ],
+                       descriptions = data.data[ 2 ],
+                       urls = data.data[ 3 ],
                        self = this;
 
-               // mw.widgets.TitleWidget does a lot more work here, because the TitleOptionWidgets can
-               // differ a lot, depending on the returned data from the request. With the request used here
-               // we get only the search results.
-               $.each( data.data[ 1 ], function ( i, result ) {
+               $.each( titles, function ( i, result ) {
                        items.push( new mw.widgets.TitleOptionWidget(
-                               // data[ 3 ][ i ] is the link for this result
-                               self.getOptionWidgetData( result, null, data.data[ 3 ][ i ] )
+                               self.getOptionWidgetData(
+                                       result,
+                                       // Create a result object that looks like the one from
+                                       // the parent's API query.
+                                       {
+                                               data: result,
+                                               url: urls[ i ],
+                                               imageUrl: null, // The JSON 'opensearch' API doesn't have images
+                                               description: descriptions[ i ],
+                                               missing: false,
+                                               redirect: false,
+                                               disambiguation: false
+                                       }
+                               )
                        ) );
                } );
 
                return items;
        };
 
-       /**
-        * @inheritdoc mw.widgets.TitleWidget
-        *
-        * @param {string} title
-        * @param {Object} data
-        * @param {string} url The Url to the result
-        */
-       mw.widgets.SearchInputWidget.prototype.getOptionWidgetData = function ( title, data, url ) {
-               // the values used in mw.widgets-TitleWidget doesn't exist here, that's why
-               // the values are hard-coded here
-               return {
-                       data: title,
-                       url: url,
-                       imageUrl: null,
-                       description: null,
-                       missing: false,
-                       redirect: false,
-                       disambiguation: false,
-                       query: this.getQueryValue()
-               };
-       };
-
        /**
         * @inheritdoc
         */