Merge "DatabaseMssql: Don't duplicate body of makeList()"
[lhc/web/wiklou.git] / resources / src / jquery / jquery.suggestions.js
index 08ed5d9..f1b214e 100644 (file)
@@ -28,7 +28,7 @@
  * suggestions: Suggestions to display
  *             Type: Array of strings
  * maxRows: Maximum number of suggestions to display at one time
- *             Type: Number, Range: 1 - 100, Default: 7
+ *             Type: Number, Range: 1 - 100, Default: 10
  * delay: Number of ms to wait for the user to stop typing
  *             Type: Number, Range: 0 - 1200, Default: 120
  * cache: Whether to cache results from a fetch
@@ -125,6 +125,7 @@ $.suggestions = {
                                                context.data.$textbox,
                                                val,
                                                function ( suggestions ) {
+                                                       suggestions = suggestions.slice( 0, context.config.maxRows );
                                                        context.data.$textbox.suggestions( 'suggestions', suggestions );
                                                        if ( context.config.cache ) {
                                                                cache[ val ] = {
@@ -132,7 +133,8 @@ $.suggestions = {
                                                                        timestamp: +new Date()
                                                                };
                                                        }
-                                               }
+                                               },
+                                               context.config.maxRows
                                        );
                                }
                        }
@@ -225,7 +227,7 @@ $.suggestions = {
                                                                } else {
                                                                        regionWidth = $region.outerWidth();
                                                                        docWidth = $( document ).width();
-                                                                       if ( ( regionWidth / docWidth  ) > 0.85 ) {
+                                                                       if ( regionWidth > ( 0.85 * docWidth ) ) {
                                                                                // If the input size takes up more than 85% of the document horizontally
                                                                                // expand the suggestions to the writing direction's native end.
                                                                                expandFrom = 'start';
@@ -233,7 +235,7 @@ $.suggestions = {
                                                                                // Calculate the center points of the input and document
                                                                                regionCenter = $region.offset().left + regionWidth / 2;
                                                                                docCenter = docWidth / 2;
-                                                                               if ( Math.abs( regionCenter - docCenter ) / docCenter < 0.10 ) {
+                                                                               if ( Math.abs( regionCenter - docCenter ) < ( 0.10 * docCenter ) ) {
                                                                                        // If the input's center is within 10% of the document center
                                                                                        // use the writing direction's native end.
                                                                                        expandFrom = 'start';
@@ -474,8 +476,6 @@ $.suggestions = {
                                                }
                                        }
                                } else {
-                                       $.suggestions.highlight( context, selected, true );
-
                                        if ( typeof context.config.result.select === 'function' ) {
                                                // Allow the callback to decide whether to prevent default or not
                                                if ( context.config.result.select.call( selected, context.data.$textbox ) === true ) {
@@ -515,7 +515,7 @@ $.fn.suggestions = function () {
                                        result: {},
                                        $region: $( this ),
                                        suggestions: [],
-                                       maxRows: 7,
+                                       maxRows: 10,
                                        delay: 120,
                                        cache: false,
                                        cacheMaxAge: 60000,