Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
ace: create editor in enteredView to pacify IE.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 14, 2013
1 parent 6b81e2a commit c3310be
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions ace-element/ace-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@
wrap: false,
// allow styling from the outside world!
applyAuthorStyles: true,
// TODO(sorvell): to work in IE reliably, can only be
// created in enteredView. However, api that wants to access this.editor
// may be used before that. Instead of making each function bail if
// this.editor is not set, we create a dummy editor. At editor
// initialization time, any pending changes are synch'd.
created: function() {
this.editor = ace.edit(document.createElement('div'));
},
enteredView: function() {
this.initializeEditor();
},
initializeEditor: function() {
ace.config.set('basePath', this.resolvePath('src-min-noconflict/'));
this.editor = ace.edit(this.$.editor);
this.editor.focus();
Expand All @@ -45,7 +56,8 @@
this.readonlyChanged();
this.wrapChanged();
this.tabSizeChanged();
this.editor.on("blur", this.editorBlur.bind(this));
this.editor.on("blur", this.editorBlurAction.bind(this));
this.editor.on('change', this.editorChangeAction.bind(this));
this.value = this.textContent;
},
fontSizeChanged: function() {
Expand Down Expand Up @@ -105,12 +117,15 @@
this.editor.getSession().selection.moveCursorLineStart();
this.editor.clearSelection();
},
editorBlur: function(event) {
editorBlurAction: function(event) {
if (this._value !== null && this._value != this.editorValue) {
this.fire('editor-change', {value: this.editorValue, oldValue: this._value});
}
this._value = this.editorValue;
},
editorChangeAction: function() {
this.fire('editor-input', {value: this.editorValue, oldValue: this._value});
},
get editorValue() {
return this.editor.getValue();
},
Expand Down

0 comments on commit c3310be

Please sign in to comment.