Commit 07af0116 authored by Sean Hammond's avatar Sean Hammond

Move "Save on Ctrl+Enter" into AnnotationController

Move the DOM event listener function that saves an annotation on
Ctrl+Enter into AnnotationController. This is just for the sake of
keeping all the code in one place (in AnnotationController, not in the
directive's link function) and putting code where it can be tested more
easily.

Note that the controller's save() function was previously called with
scope.$evalAsync() and we're now just calling it synchronously. This
seems to be fine.
parent 34d21546
......@@ -208,6 +208,14 @@ function AnnotationController(
return groups.get(model.group);
};
// Save on Meta + Enter or Ctrl + Enter.
vm.onKeydown = function(event) {
if (event.keyCode === 13 && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
vm.save();
}
};
/**
* @ngdoc method
* @name annotation.AnnotationController#tagsAutoComplete.
......@@ -654,15 +662,7 @@ function annotation($document, features) {
var threadFilter = controllers[2];
var counter = controllers[3];
// Save on Meta + Enter or Ctrl + Enter.
elem.on('keydown', function(event) {
if (event.keyCode === 13 && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
scope.$evalAsync(function() {
ctrl.save();
});
}
});
elem.on('keydown', ctrl.onKeydown);
// Give template access to feature flags.
scope.feature = features.flagEnabled;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment