Sha256: 9b577209adcc995c947bad6f6bdb7404a89a5e63f7fcbeb23adf9bb5f01e86f6

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

#= require codemirror
#= require codemirror/xml

class window.HtmlEditor extends Backbone.View
  events:
    'click a[href=#edit]': 'showEditor'
    'ajax:success [role=editor] form': 'showDisplay'

  initialize: ->
    CodeMirror.fromTextArea @$('[role=editor] .content')[0],
      mode: 'text/html'
      tabMode: 'indent'
    @$('[role=editor]').hide().css('visibility', 'visible')

  showDisplay: (e,data) ->
    e.preventDefault()
    @$('[role=editor]').hide()
    @$('[role=display]').show()
    @$('[role=display] .content').html data.formatted_content

  showEditor: (e) ->
    e.preventDefault()
    @$('[role=editor]').show()
    @$('[role=display]').hide()

jQuery ($) ->
  new HtmlEditor {el} for el in $('[role=html-editor]')

  $('body.cms form textarea').each ->
    $container = $('<div class="epiceditor-container">')
    $textarea = $(this).hide().after($container)
    console.log $textarea

    editor = new EpicEditor
      container: $container[0]
      basePath: '/assets/epiceditor'
      clientSideStorage: false
      file:
        defaultContent: $textarea.val()

    editor.load()
    editor.on 'update', (response) ->
      $textarea.val response.content

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
honey-cms-0.3.3 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.2 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.1 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.0 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.2.4 vendor/assets/javascripts/cms.js.coffee