|
138 | 138 | suggestionSelector = '.' + that.classes.suggestion,
|
139 | 139 | selected = that.classes.selected,
|
140 | 140 | options = that.options,
|
141 |
| - container, |
142 |
| - noSuggestionsContainer; |
| 141 | + container; |
143 | 142 |
|
144 | 143 | // Remove autocomplete attribute to prevent native suggestions:
|
145 | 144 | that.element.setAttribute('autocomplete', 'off');
|
|
276 | 275 | if (orientation == 'auto') {
|
277 | 276 | var viewPortHeight = $(window).height(),
|
278 | 277 | scrollTop = $(window).scrollTop(),
|
279 |
| - top_overflow = -scrollTop + offset.top - containerHeight, |
280 |
| - bottom_overflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight); |
| 278 | + topOverflow = -scrollTop + offset.top - containerHeight, |
| 279 | + bottomOverflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight); |
281 | 280 |
|
282 |
| - if (Math.max(top_overflow, bottom_overflow) === top_overflow) |
283 |
| - orientation = 'top'; |
284 |
| - else |
285 |
| - orientation = 'bottom'; |
| 281 | + orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow) |
| 282 | + ? 'top' |
| 283 | + : 'bottom'; |
286 | 284 | }
|
287 | 285 |
|
288 |
| - if (orientation === 'top') |
| 286 | + if (orientation === 'top') { |
289 | 287 | styles.top += -containerHeight;
|
290 |
| - else |
291 |
| - styles.top += height; |
| 288 | + } else { |
| 289 | + styles.top += height; |
| 290 | + } |
292 | 291 |
|
293 | 292 | // If container is not positioned to body,
|
294 | 293 | // correct its position using offset parent offset
|
295 | 294 | if(containerParent !== document.body) {
|
296 | 295 | var opacity = $container.css('opacity'),
|
297 | 296 | parentOffsetDiff;
|
298 |
| - if (!that.visible) |
299 |
| - $container.css('opacity', 0).show(); |
| 297 | + |
| 298 | + if (!that.visible){ |
| 299 | + $container.css('opacity', 0).show(); |
| 300 | + } |
300 | 301 |
|
301 | 302 | parentOffsetDiff = $container.offsetParent().offset();
|
302 | 303 | styles.top -= parentOffsetDiff.top;
|
303 | 304 | styles.left -= parentOffsetDiff.left;
|
304 | 305 |
|
305 |
| - if (!that.visible) |
| 306 | + if (!that.visible){ |
306 | 307 | $container.css('opacity', opacity).hide();
|
| 308 | + } |
307 | 309 | }
|
308 | 310 |
|
309 | 311 | // -2px to account for suggestions border.
|
|
611 | 613 | noSuggestionsContainer = $(that.noSuggestionsContainer),
|
612 | 614 | beforeRender = options.beforeRender,
|
613 | 615 | html = '',
|
614 |
| - index, |
615 |
| - width; |
| 616 | + index; |
616 | 617 |
|
617 | 618 | if (options.triggerSelectOnValidInput) {
|
618 | 619 | index = that.findSuggestionIndex(value);
|
|
731 | 732 |
|
732 | 733 | validateOrientation: function(orientation, fallback) {
|
733 | 734 | orientation = $.trim(orientation || '').toLowerCase();
|
| 735 | + |
734 | 736 | if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
|
735 | 737 | orientation = fallback;
|
736 | 738 | }
|
737 |
| - return orientation |
| 739 | + |
| 740 | + return orientation; |
738 | 741 | },
|
739 | 742 |
|
740 | 743 | processResponse: function (result, originalQuery, cacheKey) {
|
|
0 commit comments