X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.searchSuggest.js;h=e7859cf75a13bddc0fce3334d15c1e86a2bbfedf;hp=bcb6c339dfb2670e7e8cfcb0270e8b408706e899;hb=5fa4cdf860c79b32ab6ef034c6d9420c2727f695;hpb=24dc5218b18bfa065a101057523f39a9c046d046 diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js b/resources/src/mediawiki/mediawiki.searchSuggest.js index bcb6c339df..e7859cf75a 100644 --- a/resources/src/mediawiki/mediawiki.searchSuggest.js +++ b/resources/src/mediawiki/mediawiki.searchSuggest.js @@ -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'; } /** @@ -252,8 +258,7 @@ 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!