From: Erik Bernhardson Date: Tue, 1 Sep 2015 19:52:29 +0000 (-0700) Subject: Expose the ability to change suggestion api's X-Git-Tag: 1.31.0-rc.0~10143^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=a6e585ed4a7b9d0f473888de8f30e70b835a09d5;p=lhc%2Fweb%2Fwiklou.git Expose the ability to change suggestion api's We want to run some tests with alternate suggestions algorithms. This allows code in the WikimediaEvents repository to replace the api call with its own method of generating suggestions. Related WikimediaEvents patch: I595db33 Bug: T111091 Change-Id: I1fab57ea3c0506b9b6183d214a29b978a388bc29 --- diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js b/resources/src/mediawiki/mediawiki.searchSuggest.js index 5292e807ce..a20d7f077d 100644 --- a/resources/src/mediawiki/mediawiki.searchSuggest.js +++ b/resources/src/mediawiki/mediawiki.searchSuggest.js @@ -2,6 +2,20 @@ * Add search suggestions to the search form. */ ( function ( mw, $ ) { + mw.searchSuggest = { + request: function ( api, query, response, maxRows ) { + return api.get( { + action: 'opensearch', + search: query, + namespace: 0, + limit: maxRows, + suggest: '' + } ).done( function ( data ) { + response( data[ 1 ] ); + } ); + } + }; + $( function () { var api, map, searchboxesSelectors, // Region where the suggestions box will appear directly below @@ -172,15 +186,7 @@ api = api || new mw.Api(); - $.data( node, 'request', api.get( { - action: 'opensearch', - search: query, - namespace: 0, - limit: maxRows, - suggest: '' - } ).done( function ( data ) { - response( data[ 1 ] ); - } ) ); + $.data( node, 'request', mw.searchSuggest.request( api, query, response, maxRows ) ); }, cancel: function () { var node = this[0],