Sha256: 91dc1726b1c0062923fbfd45e883acbb2194edf6a4c87c2b6de1221bb14de6bb

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

Contents

# This is depricated. We will keep this around until we have moved everything over to the new
#  plain data form editor.

$(document).ready ->
  $('.ace_yaml_editor').each ->
    editor_area = document.createElement('div')
    this.appendChild(editor_area)

    # Initialize Ace Editor
    editor = ace.edit(editor_area)
    editor.getSession().setMode("ace/mode/yaml")
    editor.getSession().setTabSize(2)
    editor.setPrintMarginColumn(800)
    editor.setOptions({
      minLines: 8,
      maxLines: Infinity
    });

    textarea = $(this).children('textarea').hide()
    editor.getSession().setValue textarea.val()
    editor.getSession().on "change", ->
      textarea.val editor.getSession().getValue()


    # Setup drag-drop image upload
    editor.container.addEventListener 'dragover', (e) =>
      e.preventDefault()
      e.stopPropagation()

    editor.container.addEventListener 'dragleave', (e) =>
      e.preventDefault()
      e.stopPropagation()

    editor.container.addEventListener 'drop', (e) =>
      e.preventDefault()
      e.stopPropagation()
      fileUploader.sendFileToServer e.dataTransfer.files[0], 'embedded_image', (url) ->
        editor.insert('"' + url + '"')

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
biola_wcms_components-0.5.0 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.4.0 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.3.0 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.2.1 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.2.0 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.1.0 app/assets/javascripts/components/forms/yaml_editor.js.coffee
biola_wcms_components-0.0.1 app/assets/javascripts/components/forms/yaml_editor.js.coffee