Henning Snater has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/51661


Change subject: (bug 44674) "Full-text search" section for entity search
......................................................................

(bug 44674) "Full-text search" section for entity search

Change set depends on change Ia67b5aea6886bba460dff7535e2306234201624c in the
DataValues extension.
The entity selector replacing the native search box now will display an 
additional
section in the list of suggestions that allows triggering a full-text search.
For the moment, still, the list of suggestions will close when there are no
suggestions. This will be addressed in another commit since that behavior 
depends
on another change set.

Change-Id: I2d9c8554f3e531977997ebc8120621b79730a130
---
M lib/resources/jquery.ui/jquery.ui.suggester.js
M repo/resources/Resources.php
A repo/resources/themes/default/wikibase.ui.entitysearch.css
M repo/resources/wikibase.ui.entitysearch.js
4 files changed, 67 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/61/51661/1

diff --git a/lib/resources/jquery.ui/jquery.ui.suggester.js 
b/lib/resources/jquery.ui/jquery.ui.suggester.js
index f85ad69..9a59bc1 100644
--- a/lib/resources/jquery.ui/jquery.ui.suggester.js
+++ b/lib/resources/jquery.ui/jquery.ui.suggester.js
@@ -374,7 +374,13 @@
                                throw new Error( 'suggester: Custom list item 
is invalid.' );
                        }
 
-                       return $li.appendTo( this.menu.element );
+                       if ( this.menu.element.children( '.ui-suggester-custom' 
).length > 0 ) {
+                               // TODO: This is entity selector "more" button 
specific. There should be a method
+                               // to specify a position where to add the 
custom list item.
+                               return this.menu.element.children( 
'.ui-suggester-custom' ).first().before( $li );
+                       } else {
+                               return $li.appendTo( this.menu.element );
+                       }
                },
 
                /**
diff --git a/repo/resources/Resources.php b/repo/resources/Resources.php
index dac0f07..6f0a204 100644
--- a/repo/resources/Resources.php
+++ b/repo/resources/Resources.php
@@ -60,9 +60,16 @@
                        'scripts' => array(
                                'wikibase.ui.entitysearch.js',
                        ),
+                       'styles' => array(
+                               'themes/default/wikibase.ui.entitysearch.css',
+                       ),
                        'dependencies' => array(
+                               'jquery.eachchange',
                                'jquery.wikibase.entityselector',
                        ),
+                       'messages' => array(
+                               'searchsuggest-containing',
+                       )
                ),
 
                /* Wikibase special pages */
diff --git a/repo/resources/themes/default/wikibase.ui.entitysearch.css 
b/repo/resources/themes/default/wikibase.ui.entitysearch.css
new file mode 100644
index 0000000..3a52256
--- /dev/null
+++ b/repo/resources/themes/default/wikibase.ui.entitysearch.css
@@ -0,0 +1,26 @@
+/**
+ * Styles for the entity selector search box replacement.
+ *
+ * @since 0.4
+ * @file
+ * @ingroup WikibaseRepo
+ *
+ * @license GNU GPL v2+
+ * @author H. Snater < [email protected] >
+ */
+
+.ui-entityselector-list .wb-entitysearch-suggestions {
+       border-top: 1px solid #C9C9C9;
+}
+
+.ui-entityselector-list .wb-entitysearch-suggestions .suggestions-special {
+       display: block;
+       border: none;
+       background-color: transparent;
+       margin: 0;
+       padding: 0;
+}
+
+.ui-entityselector-list .wb-entitysearch-suggestions .ui-state-hover div {
+       color: #FFFFFF;
+}
diff --git a/repo/resources/wikibase.ui.entitysearch.js 
b/repo/resources/wikibase.ui.entitysearch.js
index 2858e0d..6ffb426 100644
--- a/repo/resources/wikibase.ui.entitysearch.js
+++ b/repo/resources/wikibase.ui.entitysearch.js
@@ -16,6 +16,14 @@
                        $input = $( '#searchInput' );
 
                /**
+                * Updates the suggestion list special item that triggers a 
full-text search.
+                */
+               function updateSuggestionSpecial() {
+                       var $suggestionsSpecial = $( 
'.wb-entitysearch-suggestions .suggestions-special' );
+                       $suggestionsSpecial.find( '.special-query' ).text( 
$input.val() );
+               }
+
+               /**
                 * Removes the native search box suggestion list.
                 *
                 * @param {Object} input Search box node
@@ -45,7 +53,25 @@
                .entityselector( {
                        url: mw.config.get( 'wgServer' ) + mw.config.get( 
'wgScriptPath' ) + '/api.php',
                        language: mw.config.get( 'wgUserLanguage' ),
-                       emulateSearch: true
+                       emulateSearch: true,
+                       customListItem: {
+                               content: $( '<div/>' ).addClass( 
'suggestions-special' )
+                                       .append( $( '<div/>' ).addClass( 
'special-label ' ).text(
+                                               mw.msg( 
'searchsuggest-containing' ) )
+                                       )
+                                       .append( $( '<div/>' ).addClass( 
'special-query' )
+                               ),
+                               action: function( event, entityselector ) {
+                                       $form.submit();
+                               },
+                               cssClass: 'wb-entitysearch-suggestions'
+                       }
+               } )
+               .on( 'entityselectoropen', function( event ) {
+                       updateSuggestionSpecial();
+               } )
+               .eachchange( function( event, oldVal ) {
+                       updateSuggestionSpecial();
                } );
 
                // TODO: Re-evaluate entity selector input (e.g. hitting "Go" 
after having hit "Search"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d9c8554f3e531977997ebc8120621b79730a130
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>

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

Reply via email to