Skip to content

Commit 587414b

Browse files
author
Tomas Kirda
committed
Minify source during build. Fixes #255.
1 parent 75879a8 commit 587414b

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

dist/jquery.autocomplete.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@
281281
topOverflow = -scrollTop + offset.top - containerHeight,
282282
bottomOverflow = scrollTop + viewPortHeight - (offset.top + height + containerHeight);
283283

284-
orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow)
285-
? 'top'
286-
: 'bottom';
284+
orientation = (Math.max(topOverflow, bottomOverflow) === topOverflow) ? 'top' : 'bottom';
287285
}
288286

289287
if (orientation === 'top') {
@@ -388,7 +386,7 @@
388386
that.selectHint();
389387
return;
390388
}
391-
// Fall through to RETURN
389+
/* falls through */
392390
case keys.RETURN:
393391
if (that.selectedIndex === -1) {
394392
that.hide();
@@ -537,6 +535,15 @@
537535
return;
538536
}
539537

538+
if ($.isFunction(that.lookup)){
539+
that.lookup(q, function (data) {
540+
that.suggestions = data.suggestions;
541+
that.suggest();
542+
options.onSearchComplete.call(that.element, q, data.suggestions);
543+
});
544+
return;
545+
}
546+
540547
if (that.isLocal) {
541548
response = that.getSuggestionsLocal(q);
542549
} else {
@@ -607,7 +614,11 @@
607614

608615
suggest: function () {
609616
if (this.suggestions.length === 0) {
610-
this.options.showNoSuggestionNotice ? this.noSuggestions() : this.hide();
617+
if (this.options.showNoSuggestionNotice) {
618+
this.noSuggestions();
619+
} else {
620+
this.hide();
621+
}
611622
return;
612623
}
613624

@@ -658,21 +669,21 @@
658669
noSuggestionsContainer.detach();
659670
container.html(html);
660671

661-
// Select first value by default:
662-
if (options.autoSelectFirst) {
663-
that.selectedIndex = 0;
664-
container.children().first().addClass(classSelected);
665-
}
666-
667672
if ($.isFunction(beforeRender)) {
668673
beforeRender.call(that.element, container);
669674
}
670675

671676
that.fixPosition();
672-
673677
container.show();
674-
that.visible = true;
675678

679+
// Select first value by default:
680+
if (options.autoSelectFirst) {
681+
that.selectedIndex = 0;
682+
container.scrollTop(0);
683+
container.children().first().addClass(classSelected);
684+
}
685+
686+
that.visible = true;
676687
that.findBestHint();
677688
},
678689

@@ -851,16 +862,17 @@
851862

852863
adjustScroll: function (index) {
853864
var that = this,
854-
activeItem = that.activate(index),
855-
offsetTop,
856-
upperBound,
857-
lowerBound,
858-
heightDelta = 25;
865+
activeItem = that.activate(index);
859866

860867
if (!activeItem) {
861868
return;
862869
}
863870

871+
var offsetTop,
872+
upperBound,
873+
lowerBound,
874+
heightDelta = $(activeItem).outerHeight();
875+
864876
offsetTop = activeItem.offsetTop;
865877
upperBound = $(that.suggestionsContainer).scrollTop();
866878
lowerBound = upperBound + that.options.maxHeight - heightDelta;

0 commit comments

Comments
 (0)