|
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;
|
|
0 commit comments