OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/assets/javascripts/angular/directives/components/execute-on-enter-directive.js

17 lines
429 B

angular.module('openproject.uiComponents')
.constant('ENTER_KEY', 13)
.directive('executeOnEnter', ['ENTER_KEY', function(ENTER_KEY) {
return {
restrict: 'A',
scope: { executeOnEnter: '&' },
link: function(scope, element) {
element.on('keydown', function(event) {
if(event.which === ENTER_KEY) {
event.preventDefault();
scope.executeOnEnter();
}
});
}
};
}]);