Skip to content

Commit dc34d70

Browse files
author
Tomas Kirda
committed
Cleanup white space, update code styling and naming.
1 parent da54bac commit dc34d70

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/jquery.autocomplete.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@
138138
suggestionSelector = '.' + that.classes.suggestion,
139139
selected = that.classes.selected,
140140
options = that.options,
141-
container,
142-
noSuggestionsContainer;
141+
container;
143142

144143
// Remove autocomplete attribute to prevent native suggestions:
145144
that.element.setAttribute('autocomplete', 'off');
@@ -276,34 +275,37 @@
276275
if (orientation == 'auto') {
277276
var viewPortHeight = $(window).height(),
278277
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);
281280

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';
286284
}
287285

288-
if (orientation === 'top')
286+
if (orientation === 'top') {
289287
styles.top += -containerHeight;
290-
else
291-
styles.top += height;
288+
} else {
289+
styles.top += height;
290+
}
292291

293292
// If container is not positioned to body,
294293
// correct its position using offset parent offset
295294
if(containerParent !== document.body) {
296295
var opacity = $container.css('opacity'),
297296
parentOffsetDiff;
298-
if (!that.visible)
299-
$container.css('opacity', 0).show();
297+
298+
if (!that.visible){
299+
$container.css('opacity', 0).show();
300+
}
300301

301302
parentOffsetDiff = $container.offsetParent().offset();
302303
styles.top -= parentOffsetDiff.top;
303304
styles.left -= parentOffsetDiff.left;
304305

305-
if (!that.visible)
306+
if (!that.visible){
306307
$container.css('opacity', opacity).hide();
308+
}
307309
}
308310

309311
// -2px to account for suggestions border.
@@ -611,8 +613,7 @@
611613
noSuggestionsContainer = $(that.noSuggestionsContainer),
612614
beforeRender = options.beforeRender,
613615
html = '',
614-
index,
615-
width;
616+
index;
616617

617618
if (options.triggerSelectOnValidInput) {
618619
index = that.findSuggestionIndex(value);
@@ -731,10 +732,12 @@
731732

732733
validateOrientation: function(orientation, fallback) {
733734
orientation = $.trim(orientation || '').toLowerCase();
735+
734736
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
735737
orientation = fallback;
736738
}
737-
return orientation
739+
740+
return orientation;
738741
},
739742

740743
processResponse: function (result, originalQuery, cacheKey) {

0 commit comments

Comments
 (0)