BigW Consortium Gitlab

autosize.js.coffee 512 Bytes
Newer Older
1
#= require jquery.ba-resize
Robert Speicher committed
2 3 4
#= require autosize

$ ->
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  $fields = $('.js-autosize')

  $fields.on 'autosize:resized', ->
    $field = $(@)
    $field.data('height', $field.outerHeight())

  $fields.on 'resize.autosize', ->
    $field = $(@)

    if $field.data('height') != $field.outerHeight()
      $field.data('height', $field.outerHeight())
      autosize.destroy($field)
      $field.css('max-height', window.outerHeight)

  autosize($fields)
  autosize.update($fields)

  $fields.css('resize', 'vertical')