Sha256: 81a16e3246da88036e2887cb3bc530f5d0110e8db5b688924df12d2bed216e72

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

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

    CKEDITOR.on 'instanceReady', ->
      Tenon.features.Editor.watchChanges()

  _rowInserted: (e) =>
    # Reactivate Editor
    $wrap = $(e.currentTarget).closest('.tn-tc')
    @_redrawCkeditor()
    @_updateButtons($wrap)

  _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()

  _redrawCkeditor: =>
    Tenon.features.Editor.reinitInline()

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tenon-1.1.8 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.7 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.6 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.5 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.4 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.3 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.2 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee
tenon-1.1.1 app/assets/javascripts/tenon/features/tenon_content/editor.js.coffee