onEnter.js 624 B

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