|
1 | 1 | /** |
2 | | -* Ajax Autocomplete for jQuery, version 1.2.14 |
| 2 | +* Ajax Autocomplete for jQuery, version 1.2.15 |
3 | 3 | * (c) 2014 Tomas Kirda |
4 | 4 | * |
5 | 5 | * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. |
6 | 6 | * For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete |
7 | 7 | */ |
8 | 8 |
|
9 | | -/*jslint browser: true, white: true, plusplus: true */ |
10 | | -/*global define, window, document, jQuery, exports */ |
| 9 | +/*jslint browser: true, white: true, plusplus: true, vars: true */ |
| 10 | +/*global define, window, document, jQuery, exports, require */ |
11 | 11 |
|
12 | 12 | // Expose plugin as an AMD module if AMD loader is present: |
13 | 13 | (function (factory) { |
|
265 | 265 | containerParent = $container.parent().get(0); |
266 | 266 | // Fix position automatically when appended to body. |
267 | 267 | // In other cases force parameter must be given. |
268 | | - if (containerParent !== document.body && !that.options.forceFixPosition) |
| 268 | + if (containerParent !== document.body && !that.options.forceFixPosition) { |
269 | 269 | return; |
| 270 | + } |
270 | 271 |
|
271 | 272 | // Choose orientation |
272 | 273 | var orientation = that.options.orientation, |
|
275 | 276 | offset = that.el.offset(), |
276 | 277 | styles = { 'top': offset.top, 'left': offset.left }; |
277 | 278 |
|
278 | | - if (orientation == 'auto') { |
| 279 | + if (orientation === 'auto') { |
279 | 280 | var viewPortHeight = $(window).height(), |
280 | 281 | scrollTop = $(window).scrollTop(), |
281 | 282 | topOverflow = -scrollTop + offset.top - containerHeight, |
|
386 | 387 | that.selectHint(); |
387 | 388 | return; |
388 | 389 | } |
389 | | - /* falls through */ |
390 | | - case keys.RETURN: |
391 | 390 | if (that.selectedIndex === -1) { |
392 | 391 | that.hide(); |
393 | 392 | return; |
394 | 393 | } |
395 | 394 | that.select(that.selectedIndex); |
396 | | - if (e.which === keys.TAB && that.options.tabDisabled === false) { |
| 395 | + if (that.options.tabDisabled === false) { |
397 | 396 | return; |
398 | 397 | } |
399 | 398 | break; |
| 399 | + case keys.RETURN: |
| 400 | + if (that.selectedIndex === -1) { |
| 401 | + that.hide(); |
| 402 | + return; |
| 403 | + } |
| 404 | + that.select(that.selectedIndex); |
| 405 | + break; |
400 | 406 | case keys.UP: |
401 | 407 | that.moveUp(); |
402 | 408 | break; |
|
535 | 541 | return; |
536 | 542 | } |
537 | 543 |
|
538 | | - if ($.isFunction(that.lookup)){ |
539 | | - that.lookup(q, function (data) { |
| 544 | + if ($.isFunction(options.lookup)){ |
| 545 | + options.lookup(q, function (data) { |
540 | 546 | that.suggestions = data.suggestions; |
541 | 547 | that.suggest(); |
542 | 548 | options.onSearchComplete.call(that.element, q, data.suggestions); |
|
0 commit comments