Sha256: cad66ec0b24319cae63c4580e1b208896a55921f22772c1bc1ede1d2e9470d78

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

#= require codemirror
#= require codemirror/xml
#= require epiceditor

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

9 entries across 9 versions & 1 rubygems

Version Path
honey-cms-0.3.13 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.12 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.11 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.10 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.9 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.8 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.7 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.5 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.3.4 vendor/assets/javascripts/cms.js.coffee