Merge "registration: Only allow one extension to set a specific config setting"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.searchSuggest.js
index bcb6c33..e7859cf 100644 (file)
@@ -2,6 +2,12 @@
  * Add search suggestions to the search form.
  */
 ( function ( mw, $ ) {
+       var searchNS = $.map( mw.config.get( 'wgFormattedNamespaces' ), function ( nsName, nsID ) {
+               if ( nsID >= 0 && mw.user.options.get( 'searchNs' + nsID ) ) {
+                       // Cast string key to number
+                       return Number( nsID );
+               }
+       } );
        mw.searchSuggest = {
                // queries the wiki and calls response with the result
                request: function ( api, query, response, maxRows, namespace ) {
@@ -9,7 +15,7 @@
                                formatversion: 2,
                                action: 'opensearch',
                                search: query,
-                               namespace: namespace || 0,
+                               namespace: namespace || searchNS,
                                limit: maxRows,
                                suggest: true
                        } ).done( function ( data, jqXHR ) {
@@ -87,9 +93,9 @@
                 */
                function getInputLocation( context ) {
                        return context.config.$region
-                                       .closest( 'form' )
-                                       .find( '[data-search-loc]' )
-                                       .data( 'search-loc' ) || 'header';
+                               .closest( 'form' )
+                               .find( '[data-search-loc]' )
+                               .data( 'search-loc' ) || 'header';
                }
 
                /**
                                var $this = $( this );
                                $this
                                        .data( 'suggestions-context' )
-                                       .data.$container
-                                               .css( 'fontSize', $this.css( 'fontSize' ) );
+                                       .data.$container.css( 'fontSize', $this.css( 'fontSize' ) );
                        } );
 
                // Ensure that the thing is actually present!