Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
chore(typeahead): clean up code style
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleycho committed Sep 30, 2015
1 parent e432059 commit 8919b0a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
}

return {
itemName:match[3],
source:$parse(match[4]),
viewMapper:$parse(match[2] || match[1]),
modelMapper:$parse(match[1])
itemName: match[3],
source: $parse(match[4]),
viewMapper: $parse(match[2] || match[1]),
modelMapper: $parse(match[1])
};
}
};
Expand Down Expand Up @@ -171,7 +171,6 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
if (onCurrentRequest && hasFocus) {
if (matches && matches.length > 0) {

scope.activeIdx = focusFirst ? 0 : -1;
isNoResultsSetter(originalScope, false);
scope.matches.length = 0;
Expand Down Expand Up @@ -329,7 +328,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
locals[parserResult.itemName] = undefined;
emptyViewValue = parserResult.viewMapper(originalScope, locals);

return candidateViewValue!== emptyViewValue ? candidateViewValue : modelValue;
return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
}
});

Expand Down Expand Up @@ -379,16 +378,13 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
if (evt.which === 40) {
scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
scope.$digest();

} else if (evt.which === 38) {
scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
scope.$digest();

} else if (evt.which === 13 || evt.which === 9) {
scope.$apply(function () {
scope.select(scope.activeIdx);
});

} else if (evt.which === 27) {
evt.stopPropagation();

Expand Down

0 comments on commit 8919b0a

Please sign in to comment.