Sha256: 76c08320f9da81f077354e88845fab2aa56caab56c1e2743f027eb4e98d726bb

Contents?: true

Size: 1009 Bytes

Versions: 5

Compression:

Stored size: 1009 Bytes

Contents

$(document).ready(function() {
  $('form.edit #editor').hide();
  var editor = ace.edit("editor");
  var textarea = $('form.edit textarea#data').hide();
  var filename = $('form.edit input.filename').val();
  editor.setShowPrintMargin(false);
  editor.setTheme("ace/theme/tomorrow_night");

  // Sync with textarea
  editor.getSession().setValue(textarea.val());
  editor.getSession().on('change', function(){
    textarea.val(editor.getSession().getValue());
  });

  // Define languages
  var langMode = {};
  var langMap  = { 'rb' : 'ruby', 'js' : 'javascript', 'css' : 'css', 'md' : 'markdown', 'html' : 'html' };
  $(Utils.getValues(langMap)).each(function(idx, lang) {
    langMode[lang] = require("ace/mode/" + lang).Mode;
  });

  // Apply code highlighting mode based on map
  $.each(langMap, function(ext, name) {
    if (filename.match(ext)) { editor.getSession().setMode(new langMode[name]()); }
  });

  // Display ace editor
  $('form.edit').show().find('#editor').show();
  editor.focus();
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitdocs-0.6.2 lib/gitdocs/public/js/edit.js
gitdocs-0.6.1 lib/gitdocs/public/js/edit.js
gitdocs-0.6.0 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0.pre7 lib/gitdocs/public/js/edit.js