Sha256: 9b9bdb8f75e664a08a49fd0248916a611a0affb4fef844f22ae6ec7a21bc57b5

Contents?: true

Size: 929 Bytes

Versions: 23

Compression:

Stored size: 929 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', '.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

23 entries across 23 versions & 1 rubygems

Version Path
tenon-1.0.52 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.51 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.50 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.49 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.48 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.47 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.46 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.45 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.44 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.43 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.42 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.41 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.40 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.39 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.38 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.37 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.36 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.35 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.33 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.0.32 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee