|
1 | 1 | /** |
2 | | -* Ajax Autocomplete for jQuery, version 1.4.10 |
3 | | -* (c) 2017 Tomas Kirda |
4 | | -* |
5 | | -* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. |
6 | | -* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete |
7 | | -*/ |
| 2 | + * Ajax Autocomplete for jQuery, version %version% |
| 3 | + * (c) 2017 Tomas Kirda |
| 4 | + * |
| 5 | + * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. |
| 6 | + * For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete |
| 7 | + */ |
8 | 8 |
|
9 | 9 | /*jslint browser: true, white: true, single: true, this: true, multivar: true */ |
10 | 10 | /*global define, window, document, jQuery, exports, require */ |
|
89 | 89 | $.Autocomplete = Autocomplete; |
90 | 90 |
|
91 | 91 | Autocomplete.defaults = { |
92 | | - ajaxSettings: {}, |
93 | | - autoSelectFirst: false, |
94 | | - appendTo: 'body', |
95 | | - serviceUrl: null, |
96 | | - lookup: null, |
97 | | - onSelect: null, |
98 | | - width: 'auto', |
99 | | - minChars: 1, |
100 | | - maxHeight: 300, |
101 | | - deferRequestBy: 0, |
102 | | - params: {}, |
103 | | - formatResult: _formatResult, |
104 | | - formatGroup: _formatGroup, |
105 | | - delimiter: null, |
106 | | - zIndex: 9999, |
107 | | - type: 'GET', |
108 | | - noCache: false, |
109 | | - onSearchStart: noop, |
110 | | - onSearchComplete: noop, |
111 | | - onSearchError: noop, |
112 | | - preserveInput: false, |
113 | | - containerClass: 'autocomplete-suggestions', |
114 | | - tabDisabled: false, |
115 | | - dataType: 'text', |
116 | | - currentRequest: null, |
117 | | - triggerSelectOnValidInput: true, |
118 | | - preventBadQueries: true, |
119 | | - lookupFilter: _lookupFilter, |
120 | | - paramName: 'query', |
121 | | - transformResult: _transformResult, |
122 | | - showNoSuggestionNotice: false, |
123 | | - noSuggestionNotice: 'No results', |
124 | | - orientation: 'bottom', |
125 | | - forceFixPosition: false |
| 92 | + ajaxSettings: {}, |
| 93 | + autoSelectFirst: false, |
| 94 | + appendTo: 'body', |
| 95 | + serviceUrl: null, |
| 96 | + lookup: null, |
| 97 | + onSelect: null, |
| 98 | + width: 'auto', |
| 99 | + minChars: 1, |
| 100 | + maxHeight: 300, |
| 101 | + deferRequestBy: 0, |
| 102 | + params: {}, |
| 103 | + formatResult: _formatResult, |
| 104 | + formatGroup: _formatGroup, |
| 105 | + delimiter: null, |
| 106 | + zIndex: 9999, |
| 107 | + type: 'GET', |
| 108 | + noCache: false, |
| 109 | + onSearchStart: noop, |
| 110 | + onSearchComplete: noop, |
| 111 | + onSearchError: noop, |
| 112 | + preserveInput: false, |
| 113 | + containerClass: 'autocomplete-suggestions', |
| 114 | + tabDisabled: false, |
| 115 | + dataType: 'text', |
| 116 | + currentRequest: null, |
| 117 | + triggerSelectOnValidInput: true, |
| 118 | + preventBadQueries: true, |
| 119 | + lookupFilter: _lookupFilter, |
| 120 | + paramName: 'query', |
| 121 | + transformResult: _transformResult, |
| 122 | + showNoSuggestionNotice: false, |
| 123 | + noSuggestionNotice: 'No results', |
| 124 | + orientation: 'bottom', |
| 125 | + forceFixPosition: false |
126 | 126 | }; |
127 | 127 |
|
128 | 128 | function _lookupFilter(suggestion, originalQuery, queryLowerCase) { |
|
167 | 167 |
|
168 | 168 | // html() deals with many types: htmlString or Element or Array or jQuery |
169 | 169 | that.noSuggestionsContainer = $('<div class="autocomplete-no-suggestion"></div>') |
170 | | - .html(this.options.noSuggestionNotice).get(0); |
| 170 | + .html(this.options.noSuggestionNotice).get(0); |
171 | 171 |
|
172 | 172 | that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass); |
173 | 173 |
|
|
219 | 219 | onFocus: function () { |
220 | 220 | var that = this; |
221 | 221 |
|
| 222 | + if (that.disabled) { |
| 223 | + return; |
| 224 | + } |
| 225 | + |
222 | 226 | that.fixPosition(); |
223 | 227 |
|
224 | 228 | if (that.el.val().length >= that.options.minChars) { |
|
270 | 274 | 'z-index': options.zIndex |
271 | 275 | }); |
272 | 276 |
|
273 | | - this.options = options; |
| 277 | + this.options = options; |
274 | 278 | }, |
275 | 279 |
|
276 | 280 |
|
|
336 | 340 | var opacity = $container.css('opacity'), |
337 | 341 | parentOffsetDiff; |
338 | 342 |
|
339 | | - if (!that.visible){ |
340 | | - $container.css('opacity', 0).show(); |
341 | | - } |
| 343 | + if (!that.visible){ |
| 344 | + $container.css('opacity', 0).show(); |
| 345 | + } |
342 | 346 |
|
343 | 347 | parentOffsetDiff = $container.offsetParent().offset(); |
344 | 348 | styles.top -= parentOffsetDiff.top; |
|
654 | 658 | html = '', |
655 | 659 | category, |
656 | 660 | formatGroup = function (suggestion, index) { |
657 | | - var currentCategory = suggestion.data[groupBy]; |
| 661 | + var currentCategory = suggestion.data[groupBy]; |
658 | 662 |
|
659 | | - if (category === currentCategory){ |
660 | | - return ''; |
661 | | - } |
| 663 | + if (category === currentCategory){ |
| 664 | + return ''; |
| 665 | + } |
662 | 666 |
|
663 | | - category = currentCategory; |
| 667 | + category = currentCategory; |
664 | 668 |
|
665 | | - return options.formatGroup(suggestion, category); |
666 | | - }; |
| 669 | + return options.formatGroup(suggestion, category); |
| 670 | + }; |
667 | 671 |
|
668 | 672 | if (options.triggerSelectOnValidInput && that.isExactMatch(value)) { |
669 | 673 | that.select(0); |
|
703 | 707 | }, |
704 | 708 |
|
705 | 709 | noSuggestions: function() { |
706 | | - var that = this, |
707 | | - beforeRender = that.options.beforeRender, |
708 | | - container = $(that.suggestionsContainer), |
709 | | - noSuggestionsContainer = $(that.noSuggestionsContainer); |
| 710 | + var that = this, |
| 711 | + beforeRender = that.options.beforeRender, |
| 712 | + container = $(that.suggestionsContainer), |
| 713 | + noSuggestionsContainer = $(that.noSuggestionsContainer); |
710 | 714 |
|
711 | 715 | this.adjustContainerWidth(); |
712 | 716 |
|
|
0 commit comments