* 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 ) {
formatversion: 2,
action: 'opensearch',
search: query,
- namespace: namespace || 0,
+ namespace: namespace || searchNS,
limit: maxRows,
suggest: true
} ).done( function ( data, jqXHR ) {
*/
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!