Sha256: c45c8004bce9eefdcf2cb2b752edfea10fffa5cf68560dab39e8b424eb031690

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 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)

    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

6 entries across 6 versions & 1 rubygems

Version Path
honey-cms-0.4.7 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.4.6 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.4.5 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.4.2 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.4.1 vendor/assets/javascripts/cms.js.coffee
honey-cms-0.4.0 vendor/assets/javascripts/cms.js.coffee