expandableTextArea.js 815 B

123456789101112131415161718192021222324252627
  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('expandableTextArea', () => ({
  13. restrict: 'A',
  14. link(scope, el) {
  15. const resetHeight = function() {
  16. const curHeight = el.outerHeight()
  17. const fitHeight = el.prop('scrollHeight')
  18. if (fitHeight > curHeight && el.val() !== '') {
  19. scope.$emit('expandable-text-area:resize')
  20. return el.css('height', fitHeight)
  21. }
  22. }
  23. return scope.$watch(() => el.val(), resetHeight)
  24. }
  25. })))