[MediaWiki-commits] [Gerrit] Update mediawiki.searchSuggest.custom.js to match upstream - change (mediawiki...Metrolook)
jenkins-bot has submitted this change and it was merged. Change subject: Update mediawiki.searchSuggest.custom.js to match upstream .. Update mediawiki.searchSuggest.custom.js to match upstream Change-Id: I048f617eae1aea57d21cf77fd4a291079bd2f97b --- M js/mediawiki.searchSuggest.custom.js M skin.json 2 files changed, 141 insertions(+), 30 deletions(-) Approvals: Paladox: Looks good to me, approved jenkins-bot: Verified diff --git a/js/mediawiki.searchSuggest.custom.js b/js/mediawiki.searchSuggest.custom.js index 977e542..04522b1 100644 --- a/js/mediawiki.searchSuggest.custom.js +++ b/js/mediawiki.searchSuggest.custom.js @@ -6,17 +6,19 @@ // queries the wiki and calls response with the result request: function ( api, query, response, maxRows ) { return api.get( { + formatversion: 2, action: 'opensearch', search: query, namespace: 0, limit: maxRows, suggest: true - } ).done( function ( data ) { - response( data[ 1 ] ); + } ).done( function ( data, jqXHR ) { + response( data[ 1 ], { + type: jqXHR.getResponseHeader( 'X-OpenSearch-Type' ), + query: query + } ); } ); - }, - // The name of the request api for event logging purposes - type: 'prefix' + } }; $( function () { @@ -82,11 +84,31 @@ var searchText = this.val(); if ( searchText && searchText !== previousSearchText ) { - mw.track( 'mediawiki.searchSuggest', 'skins.metrolook.js', { + mw.track( 'mediawiki.searchSuggest', { + action: 'session-start' + } ); + + mw.track( 'skins.metrolook.js', { action: 'session-start' } ); } previousSearchText = searchText; + } + + /** +* defines the location of autocomplete. Typically either +* header, which is in the top right of vector (for example) +* and content which identifies the main search bar on +* Special:Search. Defaults to header for skins that don't set +* explicitly. +* +* @ignore +*/ + function getInputLocation( context ) { + return context.config.$region + .closest( 'form' ) + .find( '[data-search-loc]' ) + .data( 'search-loc' ) || 'header'; } /** @@ -95,43 +117,82 @@ * * @ignore */ - function onAfterUpdate() { + function onAfterUpdate( metadata ) { var context = this.data( 'suggestionsContext' ); - mw.track( 'mediawiki.searchSuggest', 'skins.metrolook.js', { + mw.track( 'mediawiki.searchSuggest', { action: 'impression-results', numberOfResults: context.config.suggestions.length, - resultSetType: mw.searchSuggest.type + resultSetType: metadata.type || 'unknown', + query: metadata.query, + inputLocation: getInputLocation( context ) + } ); + + mw.track( 'skins.metrolook.js', { + action: 'impression-results', + numberOfResults: context.config.suggestions.length, + resultSetType: metadata.type || 'unknown', + query: metadata.query, + inputLocation: getInputLocation( context ) } ); } // The function used to render the suggestions. function renderFunction( text, context ) { - var formData = getFormData( context ); + var formData = getFormData( context ), + textboxConfig = context.data.$textbox.data( 'mw-searchsuggest' ) || {}; // linkParams object is modified and
[MediaWiki-commits] [Gerrit] Update mediawiki.searchSuggest.custom.js to match upstream - change (mediawiki...Metrolook)
Paladox has uploaded a new change for review. https://gerrit.wikimedia.org/r/297187 Change subject: Update mediawiki.searchSuggest.custom.js to match upstream .. Update mediawiki.searchSuggest.custom.js to match upstream Change-Id: I048f617eae1aea57d21cf77fd4a291079bd2f97b --- M js/mediawiki.searchSuggest.custom.js 1 file changed, 130 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Metrolook refs/changes/87/297187/1 diff --git a/js/mediawiki.searchSuggest.custom.js b/js/mediawiki.searchSuggest.custom.js index 977e542..b28b449 100644 --- a/js/mediawiki.searchSuggest.custom.js +++ b/js/mediawiki.searchSuggest.custom.js @@ -6,17 +6,19 @@ // queries the wiki and calls response with the result request: function ( api, query, response, maxRows ) { return api.get( { + formatversion: 2, action: 'opensearch', search: query, namespace: 0, limit: maxRows, suggest: true - } ).done( function ( data ) { - response( data[ 1 ] ); + } ).done( function ( data, jqXHR ) { + response( data[ 1 ], { + type: jqXHR.getResponseHeader( 'X-OpenSearch-Type' ), + query: query + } ); } ); - }, - // The name of the request api for event logging purposes - type: 'prefix' + } }; $( function () { @@ -82,12 +84,32 @@ var searchText = this.val(); if ( searchText && searchText !== previousSearchText ) { - mw.track( 'mediawiki.searchSuggest', 'skins.metrolook.js', { + mw.track( 'mediawiki.searchSuggest', { + action: 'session-start' + } ); + + mw.track( 'skins.metrolook.js', { action: 'session-start' } ); } previousSearchText = searchText; } + + /** +* defines the location of autocomplete. Typically either +* header, which is in the top right of vector (for example) +* and content which identifies the main search bar on +* Special:Search. Defaults to header for skins that don't set +* explicitly. +* +* @ignore +*/ +function getInputLocation( context ) { +return context.config.$region +.closest( 'form' ) +.find( '[data-search-loc]' ) +.data( 'search-loc' ) || 'header'; +} /** * Callback that's run when suggestions have been updated either from the cache or the API @@ -95,43 +117,82 @@ * * @ignore */ - function onAfterUpdate() { + function onAfterUpdate( metadata ) { var context = this.data( 'suggestionsContext' ); - mw.track( 'mediawiki.searchSuggest', 'skins.metrolook.js', { + mw.track( 'mediawiki.searchSuggest', { action: 'impression-results', numberOfResults: context.config.suggestions.length, - resultSetType: mw.searchSuggest.type + resultSetType: metadata.type || 'unknown', + query: metadata.query, + inputLocation: getInputLocation( context ) + } ); + + mw.track( 'skins.metrolook.js', { + action: 'impression-results', + numberOfResults: context.config.suggestions.length, + resultSetType: metadata.type || 'unknown', + query: metadata.query, + inputLocation: getInputLocation( context ) } ); } // The function used to render the suggestions. function renderFunction( text, context ) { - var formData = getFormData( context ); + var formData = getFormData( context ), +