Sha256: e8effd3e4e65e64c4864c568e08cc29def0d127993656178c30ebcb82bacaac3

Contents?: true

Size: 832 Bytes

Versions: 6

Compression:

Stored size: 832 Bytes

Contents

var ace_edit = function(id, template_type, name) {
  if (!name) { name = 'template_content' }
  var textarea_id = name + '-' + id
  var editor_id = name + '_editor-' + id
  $('#'+editor_id).show();
  var editor = ace.edit(editor_id);
  var $textarea = $('#'+textarea_id);
  $textarea.hide()
  var session = editor.getSession();
  session.setMode("ace/mode/" + template_type);
  session.setValue($textarea.val());
  session.setTabSize(2);
  session.setUseSoftTabs(true);
  session.setUseWrapMode(true);
  session.on('change', function(){
    $textarea.val(editor.getSession().getValue());
  });
  editor.commands.addCommand({
    name: 'save',
    bindKey: {win: 'Ctrl-S',  mac: 'Command-S'},
    exec: function(editor) {
      $("#"+editor.container.id).closest('form').submit();
    },
    readOnly: false
  });
  return editor;
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smithycms-0.5.99.3 app/assets/javascripts/smithy/editor.js
smithycms-0.5.99.2 app/assets/javascripts/smithy/editor.js
smithycms-0.5.99.1 app/assets/javascripts/smithy/editor.js
smithycms-0.5.99 app/assets/javascripts/smithy/editor.js
smithycms-0.5.2 app/assets/javascripts/smithy/editor.js
smithycms-0.6.0 app/assets/javascripts/smithy/editor.js