diff --git a/bower.json b/bower.json index 3aada1c..44218e3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "devbridge-autocomplete", - "version": "1.2.10", + "version": "1.2.11", "homepage": "https://github.com/devbridge/jQuery-Autocomplete", "authors": [ "Tomas Kirda" diff --git a/dist/jquery.autocomplete.js b/dist/jquery.autocomplete.js index e19863d..c2634c0 100644 --- a/dist/jquery.autocomplete.js +++ b/dist/jquery.autocomplete.js @@ -1,5 +1,5 @@ /** -* Ajax Autocomplete for jQuery, version 1.2.10 +* Ajax Autocomplete for jQuery, version 1.2.11 * (c) 2014 Tomas Kirda * * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. @@ -723,9 +723,10 @@ }, validateOrientation: function(orientation, fallback) { - orientation = orientation.trim().toLowerCase(); - if(['auto', 'bottom', 'top'].indexOf(orientation) == '-1') + orientation = $.trim(orientation || '').toLowerCase(); + if($.inArray(orientation, ['auto', 'bottom', 'top']) === -1){ orientation = fallback; + } return orientation }, diff --git a/dist/jquery.autocomplete.min.js b/dist/jquery.autocomplete.min.js index 6da7c9d..f424d3c 100644 --- a/dist/jquery.autocomplete.min.js +++ b/dist/jquery.autocomplete.min.js @@ -1,5 +1,5 @@ /** -* Ajax Autocomplete for jQuery, version 1.2.10 +* Ajax Autocomplete for jQuery, version 1.2.11 * (c) 2014 Tomas Kirda * * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. @@ -24,8 +24,8 @@ c.currentRequest=d.ajax({url:f,data:h,type:e.type,dataType:e.dataType}).done(fun this.signalHint(null)},suggest:function(){if(0===this.suggestions.length)this.options.showNoSuggestionNotice?this.noSuggestions():this.hide();else{var a=this.options,b=a.formatResult,c=this.getQuery(this.currentValue),e=this.classes.suggestion,f=this.classes.selected,h=d(this.suggestionsContainer),g=d(this.noSuggestionsContainer),k=a.beforeRender,l="",m;if(a.triggerSelectOnValidInput&&(m=this.findSuggestionIndex(c),-1!==m)){this.select(m);return}d.each(this.suggestions,function(a,d){l+='
'+b(d,c)+"
"});this.adjustContainerWidth();g.detach();h.html(l);a.autoSelectFirst&&(this.selectedIndex=0,h.children().first().addClass(f));d.isFunction(k)&&k.call(this.element,h);this.fixPosition();h.show();this.visible=!0;this.findBestHint()}},noSuggestions:function(){var a=d(this.suggestionsContainer),b=d(this.noSuggestionsContainer);this.adjustContainerWidth();b.detach();a.empty();a.append(b);this.fixPosition();a.show();this.visible=!0},adjustContainerWidth:function(){var a= this.options,b=d(this.suggestionsContainer);"auto"===a.width&&(a=this.el.outerWidth()-2,b.width(0this.selectedIndex?(a=e.get(this.selectedIndex),d(a).addClass(b),a):null},selectHint:function(){var a=d.inArray(this.hint,this.suggestions);this.select(a)},select:function(a){this.hide();this.onSelect(a)},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(d(this.suggestionsContainer).children().first().removeClass(this.classes.selected), +"string"===typeof a[0]?d.map(a,function(a){return{value:a,data:null}}):a},validateOrientation:function(a,b){a=d.trim(a||"").toLowerCase();-1===d.inArray(a,["auto","bottom","top"])&&(a=b);return a},processResponse:function(a,b,c){var d=this.options;a.suggestions=this.verifySuggestionsFormat(a.suggestions);d.noCache||(this.cachedResponse[c]=a,d.preventBadQueries&&0===a.suggestions.length&&this.badQueries.push(b));b===this.getQuery(this.currentValue)&&(this.suggestions=a.suggestions,this.suggest())}, +activate:function(a){var b=this.classes.selected,c=d(this.suggestionsContainer),e=c.children();c.children("."+b).removeClass(b);this.selectedIndex=a;return-1!==this.selectedIndex&&e.length>this.selectedIndex?(a=e.get(this.selectedIndex),d(a).addClass(b),a):null},selectHint:function(){var a=d.inArray(this.hint,this.suggestions);this.select(a)},select:function(a){this.hide();this.onSelect(a)},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(d(this.suggestionsContainer).children().first().removeClass(this.classes.selected), this.selectedIndex=-1,this.el.val(this.currentValue),this.findBestHint()):this.adjustScroll(this.selectedIndex-1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(a){var b=this.activate(a),c,e;b&&(b=b.offsetTop,c=d(this.suggestionsContainer).scrollTop(),e=c+this.options.maxHeight-25,be&&d(this.suggestionsContainer).scrollTop(b-this.options.maxHeight+25),this.el.val(this.getValue(this.suggestions[a].value)), this.signalHint(null))},onSelect:function(a){var b=this.options.onSelect;a=this.suggestions[a];this.currentValue=this.getValue(a.value);this.currentValue!==this.el.val()&&this.el.val(this.currentValue);this.signalHint(null);this.suggestions=[];this.selection=a;d.isFunction(b)&&b.call(this.element,a)},getValue:function(a){var b=this.options.delimiter,c;if(!b)return a;c=this.currentValue;b=c.split(b);return 1===b.length?a:c.substr(0,c.length-b[b.length-1].length)+a},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete"); this.disableKillerFn();d(window).off("resize.autocomplete",this.fixPositionCapture);d(this.suggestionsContainer).remove()}};d.fn.autocomplete=function(a,b){return 0===arguments.length?this.first().data("autocomplete"):this.each(function(){var c=d(this),e=c.data("autocomplete");if("string"===typeof a){if(e&&"function"===typeof e[a])e[a](b)}else e&&e.dispose&&e.dispose(),e=new k(this,a),c.data("autocomplete",e)})}}); \ No newline at end of file diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 5b573a1..6647124 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -1,5 +1,5 @@ /** -* Ajax Autocomplete for jQuery, version 1.2.10 +* Ajax Autocomplete for jQuery, version 1.2.11 * (c) 2014 Tomas Kirda * * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.