Sha256: d476c7a1d2ba34d775d1655937f15a1f6a39d874469ab378373f06819eda63fa

Contents?: true

Size: 951 Bytes

Versions: 5

Compression:

Stored size: 951 Bytes

Contents

class Tenon.features.tenonContent.Editor
  constructor: ->
    $('.tenon-content').on('cocoon:after-insert', @_rowInserted)
    $('.tenon-content').on('cocoon:after-remove', @_rowRemoved)
    $(document).on('input keypress paste change', '.editable-text', @_contentUpdated)
    for div in $('.tn-tc')
      @_updateButtons($(div))

  _rowInserted: (e) =>
    Tenon.mediumEditor.deactivate()
    new Tenon.features.Medium
    @_updateButtons($(e.currentTarget).closest('.tn-tc'))

  _rowRemoved: (e) =>
    @_updateButtons($(e.currentTarget).closest('.tn-tc'))

  _contentUpdated: (e) =>
    $editable = $(e.currentTarget)
    $editable.next('input[type=hidden]').val($editable.html())

  _updateButtons: ($wrap)=>
    if $wrap.find('.tn-tc-row:visible').length == 0
      $wrap.find('.tn-tc-add-content').show()
      $wrap.find('.tn-tc-pop-out').hide()
    else
      $wrap.find('.tn-tc-add-content').hide()
      $wrap.find('.tn-tc-pop-out').show()

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tenon-1.0.57 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.56 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.55 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.54 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.53 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee