Sha256: deb40af207161acb87377970674ec5a5a8a22f8adef7ca1e2db050000cf69de8

Contents?: true

Size: 1.39 KB

Versions: 17

Compression:

Stored size: 1.39 KB

Contents

class Tenon.features.tenonContent.ColumnSwap
  constructor: (@$container) ->
    $(document).on('click', '.column-image .swap-sides', @_swapColumns)
    $(document).on('click', '.wrapped-image .swap-sides', @_swapWrapped)

  _swapColumns: (e) =>
    e.preventDefault()
    @$row = @_getRow(e)
    @_swapDOM()
    @_savePositions()
    @_saveRowType()

  _swapWrapped: (e) =>
    e.preventDefault()
    @$row = @_getRow(e)
    @$row.find('.tn-tc-asset-field').toggleClass('left').toggleClass('right')
    @_saveRowType()

  _swapDOM: =>
    $pieces = @$row.find('.tn-tc-piece')
    $($pieces[0]).insertAfter($($pieces[1]))
    $pieces.toggleClass('omega')

  _saveRowType: =>
    $input = @$row.find('input[name$="[row_type]"]')
    if $input.val() == "LeftImageRightText"
      $input.val("LeftTextRightImage")
    else if $input.val() == "LeftTextRightImage"
      $input.val("LeftImageRightText")
    else if $input.val() == "LeftWrappedImageWithText"
      $input.val("RightWrappedImageWithText")
    else if $input.val() == "RightWrappedImageWithText"
      $input.val("LeftWrappedImageWithText")

  _savePositions: =>
    # Note: run the find again to get the pieces in their new order
    $.each @$row.find('.tn-tc-piece'), (i, piece) ->
      $(piece).find('input[name$="[position]"]').val(i)

  _getRow: (e) =>
    $(e.currentTarget)
      .closest('.image-controls')
      .data('image')
      .closest('.tn-tc-row')

Version data entries

17 entries across 17 versions & 1 rubygems

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