Sha256: 7688e297c3404616f678626a5e303413c8daff3cb3f21f07542db78f836fc0b1

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

class Tenon.features.tenonContent.Aesthetics
  constructor: (@$container) ->
    @$wrap = @$container.closest('.tn-tc-wrap')
    @$container.imagesLoaded(@_applyAesthetics)
    $(window).on('resize', @_applyAesthetics)
    $(document).on('cocoon:after-insert', '.tenon-content', @_applyAesthetics)
    @$container.on('tenon.asset_attached', '.asset-field', @_applyAesthetics)
    @$container.on('tenon.content.column_resized', 'div', @_applyAesthetics)
    @$wrap.on('tenon.content.popped', @_applyAesthetics)
    @$wrap.on('tenon.content.resized', @_applyAesthetics)
    @$container.on('keyup', '.editable-text', $.debounce(350, @_applyAesthetics))

  _applyAesthetics: =>
    if @$wrap.hasClass('mobile-breakpoint')
      @$container.find('.editable-text').css('min-height', '')
    else
      @_setMinimumEditorHeightWithImage()
      @_setMinimumWrappedEditorHeight()

  _setMinimumEditorHeightWithImage: =>
    $.each @$container.find('.image-and-text, .multi-text'), (i, row) ->
      $images = $(row).find('.image, .editable-text')
      $images.css('min-height', '0px')
      heights = $.map($images, (img, i) -> $(img).outerHeight())
      height = Math.max.apply(Math, heights)
      $(row).find('.editable-text').css('min-height', height)

  _setMinimumWrappedEditorHeight: =>
    $.each @$container.find('.wrapped-image-with-text'), (i, row) ->
      height = $(row).find('.image').height();
      $(row).find('.editable-text').css('min-height', height + 20)

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tenon-1.0.67 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.66 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.65 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.64 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.63 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.62 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.61 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.60 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.59 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee