2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-30 00:33:55 +00:00

Added an option to open the container on top

This commit is contained in:
martinlechner1 2014-02-13 11:57:57 +01:00
parent 702bc0e9c3
commit 6830fc29ee

View File

@ -1,11 +1,12 @@
/** /**
* Ajax Autocomplete for jQuery, version 1.2.9 * Ajax Autocomplete for jQuery, version 1.2.9
* (c) 2013 Tomas Kirda * (c) 2013 Tomas Kirda
* *
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. *
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
* * For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
*/ *
*/
/*jslint browser: true, white: true, plusplus: true */ /*jslint browser: true, white: true, plusplus: true */
/*global define, window, document, jQuery */ /*global define, window, document, jQuery */
@ -77,6 +78,7 @@
currentRequest: null, currentRequest: null,
triggerSelectOnValidInput: true, triggerSelectOnValidInput: true,
preventBadQueries: true, preventBadQueries: true,
openOnTop : false,
lookupFilter: function (suggestion, originalQuery, queryLowerCase) { lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1; return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
}, },
@ -260,6 +262,10 @@
left: offset.left + 'px' left: offset.left + 'px'
}; };
if(!!that.options.openOnTop){
styles.top = $(document).height() - offset.top + 'px';
}
if (that.options.width === 'auto') { if (that.options.width === 'auto') {
styles.width = (that.el.outerWidth() - 2) + 'px'; styles.width = (that.el.outerWidth() - 2) + 'px';
} }
@ -336,7 +342,7 @@
that.selectHint(); that.selectHint();
return; return;
} }
// Fall through to RETURN // Fall through to RETURN
case keys.RETURN: case keys.RETURN:
if (that.selectedIndex === -1) { if (that.selectedIndex === -1) {
that.hide(); that.hide();
@ -506,14 +512,14 @@
type: options.type, type: options.type,
dataType: options.dataType dataType: options.dataType
}).done(function (data) { }).done(function (data) {
var result; var result;
that.currentRequest = null; that.currentRequest = null;
result = options.transformResult(data); result = options.transformResult(data);
that.processResponse(result, q, cacheKey); that.processResponse(result, q, cacheKey);
options.onSearchComplete.call(that.element, q, result.suggestions); options.onSearchComplete.call(that.element, q, result.suggestions);
}).fail(function (jqXHR, textStatus, errorThrown) { }).fail(function (jqXHR, textStatus, errorThrown) {
options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown); options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
}); });
} }
}, },