Sha256: b043e9c5604f1e61850e486ba07d556ba117de5daaf0cb5bd5f4eb3b82efde88

Contents?: true

Size: 1005 Bytes

Versions: 31

Compression:

Stored size: 1005 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

31 entries across 31 versions & 2 rubygems

Version Path
gitdocs-0.5.0.pre6 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0.pre5 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0.pre3 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0.pre2 lib/gitdocs/public/js/edit.js
gitdocs-0.5.0.pre1 lib/gitdocs/public/js/edit.js
gitdocs-0.4.15 lib/gitdocs/public/js/edit.js
siuying-gitdocs-0.4.16 lib/gitdocs/public/js/edit.js
siuying-gitdocs-0.4.15 lib/gitdocs/public/js/edit.js
siuying-gitdocs-0.4.14 lib/gitdocs/public/js/edit.js
siuying-gitdocs-0.4.14.md lib/gitdocs/public/js/edit.js
gitdocs-0.4.14 lib/gitdocs/public/js/edit.js
gitdocs-0.4.13 lib/gitdocs/public/js/edit.js
gitdocs-0.4.12 lib/gitdocs/public/js/edit.js
gitdocs-0.4.11 lib/gitdocs/public/js/edit.js
gitdocs-0.4.10 lib/gitdocs/public/js/edit.js
gitdocs-0.4.9 lib/gitdocs/public/js/edit.js
gitdocs-0.4.8 lib/gitdocs/public/js/edit.js
gitdocs-0.4.7 lib/gitdocs/public/js/edit.js
gitdocs-0.4.6 lib/gitdocs/public/js/edit.js
gitdocs-0.4.5 lib/gitdocs/public/js/edit.js