Sha256: 36154962f0584927f6c1ff17db18ca154d437f383e2c451656902fd849536581

Contents?: true

Size: 1.35 KB

Versions: 22

Compression:

Stored size: 1.35 KB

Contents

$ ->
  $('textarea[data-add-editor]').each ->
    textarea = @

    # Create css id based on the text area id
    div_id = "editor_for_#{$(textarea).attr('id')}"

    # Add editor div
    $(textarea).after("<div id=\"#{div_id}\" class=\"editor\">#{$(textarea).val()}</div>")

    # Hide textarea
    $(textarea).css('display', 'none');

    # Add editor
    editor = ace.edit("#{div_id}")

    # Set syntax highlighting
    if $(textarea).is('[data-editor-syntax]')
      syntax = $(textarea).attr('data-editor-syntax')
      editor.session.setMode("ace/mode/#{syntax}");

    # On change, copy content to the textarea
    editor.on('input', ->
      $(textarea).val(editor.getValue())
    )
    
$ ->
  $('pre[data-add-editor]').each ->
    container = @

    # Create css id based on the container id
    div_id = "editor_for_#{$(container).attr('id')}"

    # Add editor div
    $(container).after("<div id=\"#{div_id}\" class=\"editor\">#{$(container).html()}</div>")

    # Hide container
    $(container).css('display', 'none');

    # Add editor
    editor = ace.edit("#{div_id}")

    # editor.setValue($(container).html())

    # Set syntax highlighting
    if $(container).is('[data-editor-syntax]')
      syntax = $(container).attr('data-editor-syntax')
      editor.session.setMode("ace/mode/#{syntax}");

    # Set the editor to read-only
    editor.setReadOnly(true)

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
itsf_backend-1.2.6 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.2.5 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.2.4 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.2.1 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.2.0 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.15 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.14 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.13 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.12 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.11 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.10 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.9 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.8 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.7 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.6 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.5 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.4 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.3 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.2 app/assets/javascripts/itsf/backend/application/ace.coffee
itsf_backend-1.1.1 app/assets/javascripts/itsf/backend/application/ace.coffee