Skip to content

Commit

Permalink
FIX: Error with ace editor and new ember.
Browse files Browse the repository at this point in the history
Fix upgrades ace editor, which was a huge headache due to AMD.
  • Loading branch information
eviltrout committed May 13, 2015
1 parent 06643fb commit d90063f
Show file tree
Hide file tree
Showing 321 changed files with 383 additions and 360 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"exists",
"visible",
"invisible",
"asyncRender",
"selectDropdown",
"asyncTestDiscourse",
"fixture",
Expand Down
29 changes: 15 additions & 14 deletions app/assets/javascripts/admin/components/ace-editor.js.es6
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*global ace:true */

/* global ace:true */
import loadScript from 'discourse/lib/load-script';

export default Ember.Component.extend({
Expand Down Expand Up @@ -33,19 +32,21 @@ export default Ember.Component.extend({
const self = this;

loadScript("/javascripts/ace/ace.js", { scriptTag: true }).then(function() {
const editor = ace.edit(self.$('.ace')[0]);

editor.setTheme("ace/theme/chrome");
editor.setShowPrintMargin(false);
editor.getSession().setMode("ace/mode/" + (self.get('mode')));
editor.on('change', function() {
self._skipContentChangeEvent = true;
self.set('content', editor.getSession().getValue());
self._skipContentChangeEvent = false;
ace.require(['ace/ace'], function(loadedAce) {
const editor = loadedAce.edit(self.$('.ace')[0]);

editor.setTheme("ace/theme/chrome");
editor.setShowPrintMargin(false);
editor.getSession().setMode("ace/mode/" + (self.get('mode')));
editor.on('change', function() {
self._skipContentChangeEvent = true;
self.set('content', editor.getSession().getValue());
self._skipContentChangeEvent = false;
});

self.$().data('editor', editor);
self._editor = editor;
});

self.$().data('editor', editor);
self._editor = editor;
});

}.on('didInsertElement')
Expand Down
6 changes: 5 additions & 1 deletion app/assets/javascripts/discourse/lib/load-script.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ function loadWithTag(path, cb) {

let s = document.createElement('script');
s.src = path;
if (Ember.Test) { Ember.Test.pendingAjaxRequests++; }
head.appendChild(s);

s.onload = s.onreadystatechange = function(_, abort) {
if (Ember.Test) { Ember.Test.pendingAjaxRequests--; }
if (abort || !s.readyState || s.readyState === "loaded" || s.readyState === "complete") {
s = s.onload = s.onreadystatechange = null;
if (!abort) { cb(); }
if (!abort) {
Ember.run(null, cb);
}
}
};
}
Expand Down
22 changes: 11 additions & 11 deletions public/javascripts/ace/ace.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/javascripts/ace/ext-beautify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d90063f

Please sign in to comment.