onEnter.js 590 B

1234567891011121314151617
  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', () => (scope, element, attrs) =>
  10. element.bind('keydown keypress', function(event) {
  11. if (event.which === 13) {
  12. scope.$apply(() => scope.$eval(attrs.onEnter, { event }))
  13. return event.preventDefault()
  14. }
  15. })
  16. )