Sha256: e0dcad4b656703c07cf1ecf6d5c402201caf5994cad4b3f96714530fa1217a9f

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 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', '.tn-tc-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('.tn-tc-image-and-text, .tn-tc-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('.tn-tc-wrapped-image-with-text'), (i, row) ->
      height = $(row).find('.image').height();
      $(row).find('.editable-text').css('min-height', height + 20)

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tenon-1.1.8 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.7 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.6 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.5 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.4 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.3 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.2 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.1.1 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.76 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.75 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.74 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.73 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.72 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.71 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.70 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.69 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.68 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee