Sha256: 69708ffb682049fddfefdf1ce833025bdeeb1d5d738681ec007608d1e7401207

Contents?: true

Size: 1.32 KB

Versions: 13

Compression:

Stored size: 1.32 KB

Contents

decko.addEditor(
  '.ace-editor-textarea',
  ->
    decko.initAce $(this),
  ->
    aceEditorContent this[0]
)

$.extend decko,
  setAceConfig: (string) ->
    setter = ->
      try
        $.parseJSON string
      catch
        {}
    decko.aceConfig = setter()

  configAceEditor: (editor, mode) ->
    conf = {
      showGutter: true,
      theme: "ace/theme/github",
      printMargin: false,
      tabSize: 2,
      useSoftTabs: true,
      maxLines: 30
    }
    hard_conf = {
      mode: "ace/mode/" + mode
    }
    user_conf = if decko.aceConfig? then decko.aceConfig else {}
    $.extend conf, user_conf['default'], user_conf[mode], hard_conf
    editor.setOptions conf

  initAce: (textarea) ->
    mode = textarea.attr "data-ace-mode"

    unless mode
      textarea.autosize()
      return
    editDiv = $("<div>",
      position: "absolute"
      width: "auto"
      height: textarea.height()
    ).insertBefore(textarea)
    textarea.css "visibility", "hidden"
    textarea.css "height", "0px"
    ace.config.set('basePath', decko.path('assets/ace_editor/ace'))
    editor = ace.edit(editDiv[0])
    editor.getSession().setValue textarea.val()
    decko.configAceEditor(editor, mode)
    return

aceEditorContent = (element) ->
  ace_div = $(element).siblings(".ace_editor")
  editor = ace.edit(ace_div[0])
  editor.getSession().getValue()

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
card-mod-ace_editor-0.1 lib/javascript/script_ace_config.js.coffee
card-1.100.0 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.6 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.5 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.4 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.3 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.2 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.1 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.99.0 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.98.3 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.98.2 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.98.1 mod/ace_editor/lib/javascript/script_ace_config.js.coffee
card-1.98.0 mod/ace_editor/lib/javascript/script_ace_config.js.coffee