Merge "Set initial language and variant user preferences to user's preferred variant...
[lhc/web/wiklou.git] / resources / jquery / jquery.suggestions.js
index 303b18f..44382f0 100644 (file)
@@ -79,13 +79,16 @@ $.suggestions = {
         * @param {Boolean} delayed Whether or not to delay this by the currently configured amount of time
         */
        update: function ( context, delayed ) {
-               // Only fetch if the value in the textbox changed and is not empty
+               // Only fetch if the value in the textbox changed and is not empty, or if the results were hidden
                // if the textbox is empty then clear the result div, but leave other settings intouched
                function maybeFetch() {
                        if ( context.data.$textbox.val().length === 0 ) {
                                context.data.$container.hide();
                                context.data.prevText = '';
-                       } else if ( context.data.$textbox.val() !== context.data.prevText ) {
+                       } else if (
+                               context.data.$textbox.val() !== context.data.prevText ||
+                               !context.data.$container.is( ':visible' )
+                       ) {
                                if ( typeof context.config.fetch === 'function' ) {
                                        context.data.prevText = context.data.$textbox.val();
                                        context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() );
@@ -306,11 +309,11 @@ $.suggestions = {
                var selected = context.data.$container.find( '.suggestions-result-current' );
                if ( !result.get || selected.get( 0 ) !== result.get( 0 ) ) {
                        if ( result === 'prev' ) {
-                               if( selected.is( '.suggestions-special' ) ) {
+                               if( selected.hasClass( 'suggestions-special' ) ) {
                                        result = context.data.$container.find( '.suggestions-result:last' );
                                } else {
                                        result = selected.prev();
-                                       if ( !( result.length && result.hasClass( '.suggestions-result' ) ) ) {
+                                       if ( !( result.length && result.hasClass( 'suggestions-result' ) ) ) {
                                                // there is something in the DOM between selected element and the wrapper, bypass it
                                                result = selected.parents( '.suggestions-results > *' ).prev().find( '.suggestions-result' ).eq(0);
                                        }
@@ -334,12 +337,12 @@ $.suggestions = {
                                        }
                                } else {
                                        result = selected.next();
-                                       if ( !( result.length && result.hasClass( '.suggestions-result' ) ) ) {
+                                       if ( !( result.length && result.hasClass( 'suggestions-result' ) ) ) {
                                                // there is something in the DOM between selected element and the wrapper, bypass it
                                                result = selected.parents( '.suggestions-results > *' ).next().find( '.suggestions-result' ).eq(0);
                                        }
 
-                                       if ( selected.is( '.suggestions-special' ) ) {
+                                       if ( selected.hasClass( 'suggestions-special' ) ) {
                                                result = $( [] );
                                        } else if (
                                                result.length === 0 &&