Skip to content

Commit

Permalink
fix first detection of text change
Browse files Browse the repository at this point in the history
  • Loading branch information
fxmontigny committed Sep 22, 2017
1 parent 4034db2 commit b4d1431
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 148 deletions.
67 changes: 31 additions & 36 deletions dist/bundles/ng2-ace-editor.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,29 @@ var AceEditorDirective = /** @class */ (function () {
};
AceEditorDirective.prototype.initEvents = function () {
var _this = this;
var me = this;
me.editor.on('change', function () { return _this.updateText(); });
me.editor.on('paste', function () { return _this.updateText(); });
this.editor.on('change', function () { return _this.updateText(); });
this.editor.on('paste', function () { return _this.updateText(); });
};
AceEditorDirective.prototype.updateText = function () {
var newVal = this.editor.getValue(), that = this;
if (newVal === this.oldText) {
return;
}
if (typeof this.oldText !== 'undefined') {
if (!this._durationBeforeCallback) {
this._text = newVal;
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
}
else {
if (this.timeoutSaving != null) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(function () {
that._text = newVal;
that.textChange.emit(newVal);
that.textChanged.emit(newVal);
that.timeoutSaving = null;
}, this._durationBeforeCallback);
if (!this._durationBeforeCallback) {
this._text = newVal;
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
}
else {
if (this.timeoutSaving != null) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(function () {
that._text = newVal;
that.textChange.emit(newVal);
that.textChanged.emit(newVal);
that.timeoutSaving = null;
}, this._durationBeforeCallback);
}
this.oldText = newVal;
};
Expand Down Expand Up @@ -209,24 +206,22 @@ var AceEditorComponent = /** @class */ (function () {
if (newVal === this.oldText) {
return;
}
if (typeof this.oldText !== 'undefined') {
if (!this._durationBeforeCallback) {
this._text = newVal;
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
this._onChange(newVal);
}
else {
if (this.timeoutSaving) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(function () {
that._text = newVal;
that.textChange.emit(newVal);
that.textChanged.emit(newVal);
that.timeoutSaving = null;
}, this._durationBeforeCallback);
if (!this._durationBeforeCallback) {
this._text = newVal;
this.textChange.emit(newVal);
this.textChanged.emit(newVal);
this._onChange(newVal);
}
else {
if (this.timeoutSaving) {
clearTimeout(this.timeoutSaving);
}
this.timeoutSaving = setTimeout(function () {
that._text = newVal;
that.textChange.emit(newVal);
that.textChanged.emit(newVal);
that.timeoutSaving = null;
}, this._durationBeforeCallback);
}
this.oldText = newVal;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/bundles/ng2-ace-editor.umd.min.js

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

Loading

0 comments on commit b4d1431

Please sign in to comment.