|
127 | 127 | } |
128 | 128 |
|
129 | 129 | function _transformResult(response) { |
130 | | - return typeof response === 'string' ? $.parseJSON(response) : response; |
| 130 | + return typeof response === 'string' ? JSON.parse(response) : response; |
131 | 131 | } |
132 | 132 |
|
133 | 133 | function _formatResult(suggestion, currentValue) { |
|
526 | 526 | return value; |
527 | 527 | } |
528 | 528 | parts = value.split(delimiter); |
529 | | - return $.trim(parts[parts.length - 1]); |
| 529 | + return parts[parts.length - 1].trim(); |
530 | 530 | }, |
531 | 531 |
|
532 | 532 | getSuggestionsLocal: function (query) { |
|
567 | 567 |
|
568 | 568 | params = options.ignoreParams ? null : options.params; |
569 | 569 |
|
570 | | - if ($.isFunction(options.lookup)) { |
| 570 | + if (typeof options.lookup === 'function') { |
571 | 571 | options.lookup(q, function (data) { |
572 | 572 | that.suggestions = data.suggestions; |
573 | 573 | that.suggest(); |
|
579 | 579 | if (that.isLocal) { |
580 | 580 | response = that.getSuggestionsLocal(q); |
581 | 581 | } else { |
582 | | - if ($.isFunction(serviceUrl)) { |
| 582 | + if (typeof serviceUrl === 'function') { |
583 | 583 | serviceUrl = serviceUrl.call(that.element, q); |
584 | 584 | } |
585 | 585 | cacheKey = serviceUrl + '?' + $.param(params || {}); |
|
639 | 639 | var that = this, |
640 | 640 | container = $(that.suggestionsContainer); |
641 | 641 |
|
642 | | - if ($.isFunction(that.options.onHide) && that.visible) { |
| 642 | + if ((typeof that.options.onHide === 'function') && that.visible) { |
643 | 643 | that.options.onHide.call(that.element, container); |
644 | 644 | } |
645 | 645 |
|
|
710 | 710 | noSuggestionsContainer.detach(); |
711 | 711 | container.html(html); |
712 | 712 |
|
713 | | - if ($.isFunction(beforeRender)) { |
| 713 | + if (typeof beforeRender === 'function') { |
714 | 714 | beforeRender.call(that.element, container, that.suggestions); |
715 | 715 | } |
716 | 716 |
|
|
747 | 747 | container.empty(); |
748 | 748 | container.append(noSuggestionsContainer); |
749 | 749 |
|
750 | | - if ($.isFunction(beforeRender)) { |
| 750 | + if (typeof beforeRender === 'function') { |
751 | 751 | beforeRender.call(that.element, container, that.suggestions); |
752 | 752 | } |
753 | 753 |
|
|
807 | 807 | if (that.hintValue !== hintValue) { |
808 | 808 | that.hintValue = hintValue; |
809 | 809 | that.hint = suggestion; |
810 | | - if ($.isFunction(onHintCallback)) { |
| 810 | + if (typeof onHintCallback === 'function') { |
811 | 811 | onHintCallback.call(that.element, hintValue); |
812 | 812 | } |
813 | 813 | } |
|
825 | 825 | }, |
826 | 826 |
|
827 | 827 | validateOrientation: function (orientation, fallback) { |
828 | | - orientation = $.trim(orientation || '').toLowerCase(); |
| 828 | + orientation = (orientation || '').trim().toLowerCase(); |
829 | 829 |
|
830 | 830 | if ($.inArray(orientation, ['auto', 'bottom', 'top']) === -1) { |
831 | 831 | orientation = fallback; |
|
974 | 974 | that.suggestions = []; |
975 | 975 | that.selection = suggestion; |
976 | 976 |
|
977 | | - if ($.isFunction(onSelectCallback)) { |
| 977 | + if (typeof onSelectCallback === 'function') { |
978 | 978 | onSelectCallback.call(that.element, suggestion); |
979 | 979 | } |
980 | 980 | }, |
|
0 commit comments