Sha256: e5b727c109397f0cdb4acf18b3846b2cd980d4d9fd58ee0b15d743972a3a98e6
Contents?: true
Size: 1.36 KB
Versions: 24
Compression:
Stored size: 1.36 KB
Contents
$ -> $("textarea[data-add-editor='true']").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='true']").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
24 entries across 24 versions & 1 rubygems