2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 14:17:45 +00:00

Cleanup white space, update code styling and naming.

This commit is contained in:
Tomas Kirda 2014-08-26 13:42:06 -05:00
parent da54bac1ed
commit dc34d70831

View File

@ -138,8 +138,7 @@
suggestionSelector = '.' + that.classes.suggestion, suggestionSelector = '.' + that.classes.suggestion,
selected = that.classes.selected, selected = that.classes.selected,
options = that.options, options = that.options,
container, container;
noSuggestionsContainer;
// Remove autocomplete attribute to prevent native suggestions: // Remove autocomplete attribute to prevent native suggestions:
that.element.setAttribute('autocomplete', 'off'); that.element.setAttribute('autocomplete', 'off');
@ -276,34 +275,37 @@
if (orientation == 'auto') { if (orientation == 'auto') {
var viewPortHeight = $(window).height(), var viewPortHeight = $(window).height(),
scrollTop = $(window).scrollTop(), scrollTop = $(window).scrollTop(),
top_overflow = -scrollTop + offset.top - containerHeight, topOverflow = -scrollTop + offset.top - containerHeight,
bottom_overflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight); bottomOverflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight);
if (Math.max(top_overflow, bottom_overflow) === top_overflow) orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow)
orientation = 'top'; ? 'top'
else : 'bottom';
orientation = 'bottom';
} }
if (orientation === 'top') if (orientation === 'top') {
styles.top += -containerHeight; styles.top += -containerHeight;
else } else {
styles.top += height; styles.top += height;
}
// If container is not positioned to body, // If container is not positioned to body,
// correct its position using offset parent offset // correct its position using offset parent offset
if(containerParent !== document.body) { if(containerParent !== document.body) {
var opacity = $container.css('opacity'), var opacity = $container.css('opacity'),
parentOffsetDiff; parentOffsetDiff;
if (!that.visible)
$container.css('opacity', 0).show(); if (!that.visible){
$container.css('opacity', 0).show();
}
parentOffsetDiff = $container.offsetParent().offset(); parentOffsetDiff = $container.offsetParent().offset();
styles.top -= parentOffsetDiff.top; styles.top -= parentOffsetDiff.top;
styles.left -= parentOffsetDiff.left; styles.left -= parentOffsetDiff.left;
if (!that.visible) if (!that.visible){
$container.css('opacity', opacity).hide(); $container.css('opacity', opacity).hide();
}
} }
// -2px to account for suggestions border. // -2px to account for suggestions border.
@ -611,8 +613,7 @@
noSuggestionsContainer = $(that.noSuggestionsContainer), noSuggestionsContainer = $(that.noSuggestionsContainer),
beforeRender = options.beforeRender, beforeRender = options.beforeRender,
html = '', html = '',
index, index;
width;
if (options.triggerSelectOnValidInput) { if (options.triggerSelectOnValidInput) {
index = that.findSuggestionIndex(value); index = that.findSuggestionIndex(value);
@ -731,10 +732,12 @@
validateOrientation: function(orientation, fallback) { validateOrientation: function(orientation, fallback) {
orientation = $.trim(orientation || '').toLowerCase(); orientation = $.trim(orientation || '').toLowerCase();
if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){ if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){
orientation = fallback; orientation = fallback;
} }
return orientation
return orientation;
}, },
processResponse: function (result, originalQuery, cacheKey) { processResponse: function (result, originalQuery, cacheKey) {