Merge "jquery.suggestions: Load initial suggestions only when focused"
[lhc/web/wiklou.git] / resources / src / jquery / jquery.suggestions.js
index 25f57ef..3083b0f 100644 (file)
@@ -78,7 +78,7 @@
  *
  * @param {string} [options.expandFrom=auto] Which direction to offset the suggestion box from.
  *  Values 'start' and 'end' translate to left and right respectively depending on the directionality
- *   of the current document, according to `$( 'html' ).css( 'direction' )`.
+ *   of the current document, according to `$( document.documentElement ).css( 'direction' )`.
  *   Valid values: "left", "right", "start", "end", and "auto".
  *
  * @param {boolean} [options.positionFromLeft] Sets `expandFrom=left`, for backwards
                                                // Process expandFrom, after this it is set to left or right.
                                                context.config.expandFrom = ( function ( expandFrom ) {
                                                        var regionWidth, docWidth, regionCenter, docCenter,
-                                                               docDir = $( document.documentElement ).css( 'direction' ),
+                                                               isRTL = $( document.documentElement ).css( 'direction' ) === 'rtl',
                                                                $region = context.config.$region;
 
                                                        // Backwards compatible
                                                        }
 
                                                        if ( expandFrom === 'start' ) {
-                                                               expandFrom = docDir === 'rtl' ? 'right' : 'left';
+                                                               expandFrom = isRTL ? 'right' : 'left';
 
                                                        } else if ( expandFrom === 'end' ) {
-                                                               expandFrom = docDir === 'rtl' ? 'left' : 'right';
+                                                               expandFrom = isRTL ? 'left' : 'right';
                                                        }
 
                                                        return expandFrom;
                                        } );
                                // Load suggestions if the value is changed because there are already
                                // typed characters before the JavaScript is loaded.
-                               if ( this.value !== this.defaultValue ) {
+                               if ( $( this ).is( ':focus' ) && this.value !== this.defaultValue ) {
                                        update( context, false );
                                }
                        }