Sha256: 99bbe2c50322cf87cd075d7ccc9a68923e357d698b5196bb1624c7744cb6e957

Contents?: true

Size: 1.27 KB

Versions: 63

Compression:

Stored size: 1.27 KB

Contents

class Tenon.features.tenonContent.StretchToFill
  constructor: (@$container) ->
    $(document).on('click', '.medium-editor-action.stretch-to-fill', @stretchImage)

  stretchImage: (e) =>
    e.preventDefault()
    @$button = $(e.currentTarget)
    @$piece = @_getPiece()
    @$image = @_getImage()
    @_setState()

  _setState: () =>
    if @$image.hasClass('stretch')
      @state = false
    else
      @state = true
    @_saveState()

  _saveState: () =>
    @_setFormFieldState()
    @_setImageState()
    @_setButtonActiveState()

  _setFormFieldState: () =>
    @$piece.find('input[name$="[stretch_to_fill]"]').val(@state)

  _setImageState: () =>
    if @state == true
      @$image.addClass('stretch')
    else
      @$image.removeClass('stretch')

  _setButtonActiveState: () =>
    if @state == true
      @$button.addClass('medium-editor-button-active')
      @$image.find('.stretch-to-fill').addClass('medium-editor-button-active')
    else
      @$button.removeClass('medium-editor-button-active')
      @$image.find('.stretch-to-fill').removeClass('medium-editor-button-active')

  _getImage: () =>
    @$button
      .closest('.image-controls')
      .data('image')

  _getPiece: () =>
    @$button
      .closest('.image-controls')
      .data('image')
      .closest('.tn-tc-piece')

Version data entries

63 entries across 63 versions & 1 rubygems

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