X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.searchSuggest.js;h=e7859cf75a13bddc0fce3334d15c1e86a2bbfedf;hb=31495b9e60e01438f5906cb24d484599e4930e66;hp=fa1a78c5cb665fdfddeb8c1cc26317df48f48589;hpb=c8d361a38027ef5d808225b8a83f15417248aa67;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js b/resources/src/mediawiki/mediawiki.searchSuggest.js index fa1a78c5cb..e7859cf75a 100644 --- a/resources/src/mediawiki/mediawiki.searchSuggest.js +++ b/resources/src/mediawiki/mediawiki.searchSuggest.js @@ -2,14 +2,20 @@ * 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 ) { + request: function ( api, query, response, maxRows, namespace ) { return api.get( { formatversion: 2, action: 'opensearch', search: query, - namespace: 0, + namespace: namespace || searchNS, limit: maxRows, suggest: true } ).done( function ( data, jqXHR ) { @@ -22,7 +28,7 @@ }; $( function () { - var api, map, searchboxesSelectors, + var api, searchboxesSelectors, // Region where the suggestions box will appear directly below // (using the same width). Can be a container element or the input // itself, depending on what suits best in the environment. @@ -34,23 +40,6 @@ $searchInput = $( '#searchInput' ), previousSearchText = $searchInput.val(); - // Compatibility map - map = { - // SimpleSearch is broken in Opera < 9.6 - opera: [ [ '>=', 9.6 ] ], - // Older Konquerors are unable to position the suggestions correctly (bug 50805) - konqueror: [ [ '>=', '4.11' ] ], - docomo: false, - blackberry: false, - // Support for iOS 6 or higher. It has not been tested on iOS 5 or lower - ipod: [ [ '>=', 6 ] ], - iphone: [ [ '>=', 6 ] ] - }; - - if ( !$.client.test( map ) ) { - return; - } - // Compute form data for search suggestions functionality. function getFormData( context ) { var $form, baseHref, linkParams; @@ -104,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'; } /** @@ -269,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!