expandableTextArea.coffee 390 B

1234567891011121314151617
  1. define [
  2. "base"
  3. ], (App) ->
  4. App.directive "expandableTextArea", () ->
  5. restrict: "A"
  6. link: (scope, el) ->
  7. resetHeight = () ->
  8. curHeight = el.outerHeight()
  9. fitHeight = el.prop("scrollHeight")
  10. if fitHeight > curHeight and el.val() != ""
  11. scope.$emit "expandable-text-area:resize"
  12. el.css("height", fitHeight)
  13. scope.$watch (() -> el.val()), resetHeight