Skip to content

Commit

Permalink
Merge pull request #11 from AParks/typeahead-min-length
Browse files Browse the repository at this point in the history
feat(typeahead): handles min-length of 0
  • Loading branch information
AParks authored Aug 2, 2017
2 parents bd147f2 + 64306da commit f423ceb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "MIT",
"ignore": [],
"description": "Native AngularJS (Angular) directives for Bootstrap.",
"version": "0.12.1-7",
"version": "0.12.1-8",
"main": ["./ui-bootstrap-tpls.js"],
"dependencies": {
"angular": ">=1 <1.3.0"
Expand Down
10 changes: 5 additions & 5 deletions ui-bootstrap-tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3555,9 +3555,9 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
//SUPPORTED ATTRIBUTES (OPTIONS)

//minimal no of characters that needs to be entered before typeahead kicks-in
var minSearch = originalScope.$eval(attrs.typeaheadMinLength);
if (!minSearch && minSearch !== 0) {
minSearch = 1;
var minLength = originalScope.$eval(attrs.typeaheadMinLength);
if (!minLength && minLength !== 0) {
minLength = 1;
}

//minimal wait time after last character typed before typehead kicks-in
Expand Down Expand Up @@ -3710,7 +3710,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

hasFocus = true;

if (inputValue && inputValue.length >= minSearch) {
if (minLength === 0 || inputValue && inputValue.length >= minLength) {
if (waitTime > 0) {
cancelPreviousTimeout();
scheduleSearchWithTimeout(inputValue);
Expand Down Expand Up @@ -3825,7 +3825,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

element.bind('focus', function (evt) {
hasFocus = true;
if (minSearch === 0 && !modelCtrl.$viewValue) {
if (minLength === 0 && !modelCtrl.$viewValue) {
$timeout(function() {
getMatchesAsync(modelCtrl.$viewValue, evt);
}, 0);
Expand Down
10 changes: 5 additions & 5 deletions ui-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3554,9 +3554,9 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
//SUPPORTED ATTRIBUTES (OPTIONS)

//minimal no of characters that needs to be entered before typeahead kicks-in
var minSearch = originalScope.$eval(attrs.typeaheadMinLength);
if (!minSearch && minSearch !== 0) {
minSearch = 1;
var minLength = originalScope.$eval(attrs.typeaheadMinLength);
if (!minLength && minLength !== 0) {
minLength = 1;
}

//minimal wait time after last character typed before typehead kicks-in
Expand Down Expand Up @@ -3709,7 +3709,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

hasFocus = true;

if (inputValue && inputValue.length >= minSearch) {
if (minLength === 0 || inputValue && inputValue.length >= minLength) {
if (waitTime > 0) {
cancelPreviousTimeout();
scheduleSearchWithTimeout(inputValue);
Expand Down Expand Up @@ -3824,7 +3824,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

element.bind('focus', function (evt) {
hasFocus = true;
if (minSearch === 0 && !modelCtrl.$viewValue) {
if (minLength === 0 && !modelCtrl.$viewValue) {
$timeout(function() {
getMatchesAsync(modelCtrl.$viewValue, evt);
}, 0);
Expand Down

0 comments on commit f423ceb

Please sign in to comment.