jenkins-bot has submitted this change and it was merged.

Change subject: $.wikibase.entitysearch: Set/Update link of "containing" item
......................................................................


$.wikibase.entitysearch: Set/Update link of "containing" item

By setting/updating the link of the "containing" item, the item becomes 
clickable with the
middle and right mouse button.

Change-Id: I597e3a36599178f9e25de3c4a703a578eea3b9e8
---
M repo/resources/wikibase.ui.entitysearch.js
1 file changed, 32 insertions(+), 10 deletions(-)

Approvals:
  Thiemo Mättig (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/resources/wikibase.ui.entitysearch.js 
b/repo/resources/wikibase.ui.entitysearch.js
index 0b8e177..6d62e58 100644
--- a/repo/resources/wikibase.ui.entitysearch.js
+++ b/repo/resources/wikibase.ui.entitysearch.js
@@ -2,7 +2,6 @@
  * Replacing the native MediaWiki search suggestions with Wikibase's entity 
selector widget.
  *
  * @license GNU GPL v2+
- * @author Jens Ohlig
  * @author H. Snater < [email protected] >
  */
 ( function( $, mw ) {
@@ -50,11 +49,34 @@
                        $hiddenInput = $( '<input type="hidden" 
name="search"/>' );
 
                /**
-                * Updates the suggestion list special item that triggers a 
full-text search.
+                * @param {jQuery} $form
+                * @return {string}
                 */
-               function updateSuggestionSpecial() {
+               function getHref( $form ) {
+                       var href = $form.attr( 'action' ),
+                               params = {};
+
+                       href += href.indexOf( '?' ) === -1 ? '?' : '&';
+
+                       $.each( $form.serializeArray(), function( i, param ) {
+                               params[param.name] = param.value;
+                       } );
+
+                       params.search = $input.val();
+
+                       return href + $.param( params );
+               }
+
+               /**
+                * Updates the suggestion list special item that triggers a 
full-text search.
+                *
+                * @param {jQuery.ui.ooMenu.CustomItem} searchContaining
+                */
+               function updateSuggestionSpecial( searchContaining ) {
                        var $suggestionsSpecial = $( 
'.wb-entitysearch-suggestions .suggestions-special' );
                        $suggestionsSpecial.find( '.special-query' ).text( 
$input.val() );
+
+                       searchContaining.setLink( getHref( $form ) + 
'&fulltext=1' );
                }
 
                /**
@@ -78,12 +100,12 @@
                                        .addClass( 'special-query' )
                        );
 
+               var searchContaining = new $.ui.ooMenu.CustomItem( 
$searchContaining, null, function() {
+                       $form.submit();
+               }, 'wb-entitysearch-suggestions' );
+
                var $searchMenu = $( '<ul/>' ).ooMenu( {
-                       customItems: [
-                               new $.ui.ooMenu.CustomItem( $searchContaining, 
null, function() {
-                                       $form.submit();
-                               }, 'wb-entitysearch-suggestions' )
-                       ]
+                       customItems: [searchContaining]
                } );
 
                $input
@@ -116,11 +138,11 @@
                        )
                } )
                .on( 'entityselectoropen', function( event ) {
-                       updateSuggestionSpecial();
+                       updateSuggestionSpecial( searchContaining );
                } )
                .on( 'eachchange', function( event, oldVal ) {
                        $hiddenInput.val( '' );
-                       updateSuggestionSpecial();
+                       updateSuggestionSpecial( searchContaining );
                } )
                .on( 'entityselectorselected', function( event, entityId ) {
                        $hiddenInput.val( entityId );

-- 
To view, visit https://gerrit.wikimedia.org/r/168989
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I597e3a36599178f9e25de3c4a703a578eea3b9e8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to