Gerrit Patch Uploader has uploaded a new change for review.
https://gerrit.wikimedia.org/r/222752
Change subject: mediawiki.searchSuggest: Allow multiple suggestion fields
......................................................................
mediawiki.searchSuggest: Allow multiple suggestion fields
Store result of render cache in context instead of a single private variable.
Bug: T104763
Change-Id: I9c8827eab1e074cf2b5a573942cf983dbda07149
---
M resources/src/mediawiki/mediawiki.searchSuggest.js
1 file changed, 10 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/52/222752/1
diff --git a/resources/src/mediawiki/mediawiki.searchSuggest.js
b/resources/src/mediawiki/mediawiki.searchSuggest.js
index 1f3b123..8890529 100644
--- a/resources/src/mediawiki/mediawiki.searchSuggest.js
+++ b/resources/src/mediawiki/mediawiki.searchSuggest.js
@@ -3,7 +3,7 @@
*/
( function ( mw, $ ) {
$( function () {
- var api, map, resultRenderCache, searchboxesSelectors,
+ var api, map, 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.
@@ -86,18 +86,18 @@
// The function used to render the suggestions.
function renderFunction( text, context ) {
- if ( !resultRenderCache ) {
- resultRenderCache = computeResultRenderCache(
context );
+ if ( !context.cache ) {
+ context.cache = computeResultRenderCache(
context );
}
// linkParams object is modified and reused
- resultRenderCache.linkParams[
resultRenderCache.textParam ] = text;
+ context.cache.linkParams[ context.cache.textParam ] =
text;
// this is the container <div>, jQueryfied
this.text( text )
.wrap(
$( '<a>' )
- .attr( 'href',
resultRenderCache.baseHref + $.param( resultRenderCache.linkParams ) )
+ .attr( 'href',
context.cache.baseHref + $.param( context.cache.linkParams ) )
.attr( 'title', text )
.addClass(
'mw-searchSuggest-link' )
);
@@ -121,12 +121,12 @@
function specialRenderFunction( query, context ) {
var $el = this;
- if ( !resultRenderCache ) {
- resultRenderCache = computeResultRenderCache(
context );
+ if ( !context.cache ) {
+ context.cache = computeResultRenderCache(
context );
}
// linkParams object is modified and reused
- resultRenderCache.linkParams[
resultRenderCache.textParam ] = query;
+ context.cache.linkParams[ context.cache.textParam ] =
query;
if ( $el.children().length === 0 ) {
$el
@@ -145,11 +145,11 @@
}
if ( $el.parent().hasClass( 'mw-searchSuggest-link' ) )
{
- $el.parent().attr( 'href',
resultRenderCache.baseHref + $.param( resultRenderCache.linkParams ) +
'&fulltext=1' );
+ $el.parent().attr( 'href',
context.cache.baseHref + $.param( context.cache.linkParams ) + '&fulltext=1' );
} else {
$el.wrap(
$( '<a>' )
- .attr( 'href',
resultRenderCache.baseHref + $.param( resultRenderCache.linkParams ) +
'&fulltext=1' )
+ .attr( 'href',
context.cache.baseHref + $.param( context.cache.linkParams ) + '&fulltext=1' )
.addClass(
'mw-searchSuggest-link' )
);
}
--
To view, visit https://gerrit.wikimedia.org/r/222752
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c8827eab1e074cf2b5a573942cf983dbda07149
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits