Skip to content

Commit

Permalink
Replace call to get('editor') with this.editor for speed up.
Browse files Browse the repository at this point in the history
  • Loading branch information
spalax committed Jan 19, 2014
1 parent 76f8d20 commit f2d3225
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,24 @@ define([
id: this.id
}, this.settings));

this.get('editor').on('instanceReady', lang.hitch(this, function (){
this.editor = CKEDITOR.instances[this.id];

this.editor.on('instanceReady', lang.hitch(this, function (){
this.emit('ready', this);
}));

this.get('editor').on('change', lang.hitch(this, function (){
this.editor.on('change', lang.hitch(this, function (){
this._handleOnChange(this.get('value'));
}));

this.get('editor').on('blur', lang.hitch(this, function (){
this.editor.on('blur', lang.hitch(this, function (){
this._onBlur();
}));

this.get('editor').on('focus', lang.hitch(this, function (){
this.editor.on('focus', lang.hitch(this, function (){
this._onFocus();
}));

} catch (e) {
console.error(this.declaredClass, arguments, e);
throw e;
Expand All @@ -49,16 +52,7 @@ define([
focus: function () {
try {
this.inherited(arguments);
this.get('editor').focus();
} catch (e) {
console.error(this.declaredClass, arguments, e);
throw e;
}
},

_getEditorAttr: function () {
try {
return CKEDITOR.instances[this.id];
this.editor.focus();
} catch (e) {
console.error(this.declaredClass, arguments, e);
throw e;
Expand All @@ -77,7 +71,7 @@ define([
this.__lock = true;

var inherited = lang.hitch(this, 'inherited', arguments);
this.get('editor').setData(value || '', lang.hitch(this, function (){
this.editor.setData(value || '', lang.hitch(this, function (){
this.__lock = false;
inherited();
}));
Expand All @@ -89,7 +83,7 @@ define([

destroy: function () {
try {
this.get('editor').destroy();
this.editor && this.editor.destroy();
this.inherited(arguments);
} catch (e) {
console.error(this.declaredClass, arguments, e);
Expand All @@ -99,7 +93,7 @@ define([

_getValueAttr: function () {
try {
return string.trim(this.get('editor').getData());
return string.trim(this.editor.getData());
} catch (e) {
console.error(this.declaredClass+" "+arguments.callee.nom, arguments, e);
throw e;
Expand Down

0 comments on commit f2d3225

Please sign in to comment.