onEnter.js 611 B

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