onEnter.js 621 B

123456789101112131415161718
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Fix any style issues and re-enable lint.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  7. */
  8. import App from '../base'
  9. export default App.directive('onEnter', function () {
  10. return (scope, element, attrs) =>
  11. element.bind('keydown keypress', function (event) {
  12. if (event.which === 13) {
  13. scope.$apply(() => scope.$eval(attrs.onEnter, { event }))
  14. return event.preventDefault()
  15. }
  16. })
  17. })