Sha256: cb941a6763e0eab89ad1d3a18f69d66440aca31388b5fc1be771810f4edaf5d8

Contents?: true

Size: 1.43 KB

Versions: 57

Compression:

Stored size: 1.43 KB

Contents

class Tenon.features.tenonContent.Aesthetics
  constructor: (@$container) ->
    @$wrap = @$container.closest('.tn-tc-wrap')
    @$container.imagesLoaded(@_applyAesthetics)
    $(window).on('resize', @_applyAesthetics)
    $('.tenon-content').on('cocoon:after-insert', @_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

57 entries across 57 versions & 1 rubygems

Version Path
tenon-1.0.57 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.56 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.55 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.54 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.53 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.52 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.51 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.50 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.49 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.48 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.47 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.46 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.45 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.44 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.43 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.42 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.41 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.40 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.39 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee
tenon-1.0.38 app/assets/javascripts/tenon/features/tenon_content/aesthetics.js.coffee