Sha256: c893f52d15bc21292f99272a533cdd98ff9ec08caf2b89e2ad26d257612099e3
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
= javascript_pack_tag 'optimacms/ace' :javascript $(document).ready(function() { // set content from input to editor $( "textarea.form_input_content" ).each(function( index ) { var textarea = $(this); var lang=textarea.data('lang'); textarea.hide(); editors[lang].getSession().setValue(textarea.val()); }); // set content from editor back to input $('#mainform form').submit(function(){ $( "textarea.form_input_content" ).each(function( index ) { var textarea = $(this); var lang=textarea.data('lang'); textarea.val(editors[lang].getSession().getValue()); }); }); }); function init_editor(id){ //var editor = ace.edit("content"); var editor = ace.edit(id); editor.setTheme("ace/theme/chrome"); editor.getSession().setMode("ace/mode/haml"); //editor.getSession().setNewLineMode("windows"); editor.getSession().setNewLineMode("unix"); editor.getSession().setTabSize(2); return editor; } // init editors var editors = []; #{ @languages.map do |lang| name = lang=='' ? 'def' : lang "editors[\"#{name}\"] = init_editor(\"content-#{name}\");" end.join(' ').html_safe }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
optimacms-0.4.3 | app/views/optimacms/admin/common/_js_ace.html.haml |
optimacms-0.4.2 | app/views/optimacms/admin/common/_js_ace.html.haml |