[Comments] Save text for new (not added) comment: clear text when esc, close or add button pressed
This commit is contained in:
parent
99f7070c7a
commit
6da9f77db0
|
@ -1299,8 +1299,8 @@ define([
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.handlerHide = (function () {
|
dialog.handlerHide = (function (clear) {
|
||||||
me.clearDummyComment();
|
me.clearDummyComment(clear);
|
||||||
});
|
});
|
||||||
|
|
||||||
anchor = this.api.asc_getAnchorPosition();
|
anchor = this.api.asc_getAnchorPosition();
|
||||||
|
@ -1309,7 +1309,7 @@ define([
|
||||||
anchor.asc_getY(),
|
anchor.asc_getY(),
|
||||||
this.hintmode ? anchor.asc_getX() : undefined);
|
this.hintmode ? anchor.asc_getX() : undefined);
|
||||||
|
|
||||||
dialog.showComments(true, false, true);
|
dialog.showComments(true, false, true, dialog.getDummyText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1323,12 +1323,14 @@ define([
|
||||||
this.hidereply = false;
|
this.hidereply = false;
|
||||||
this.isSelectedComment = false;
|
this.isSelectedComment = false;
|
||||||
this.uids = [];
|
this.uids = [];
|
||||||
this.isDummyComment = false;
|
|
||||||
|
|
||||||
this.popoverComments.reset();
|
this.popoverComments.reset();
|
||||||
if (this.getPopover().isVisible()) {
|
if (this.getPopover().isVisible()) {
|
||||||
this.getPopover().hideComments();
|
this.getPopover().hideComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isDummyComment = false;
|
||||||
|
|
||||||
comment.asc_putText(commentVal);
|
comment.asc_putText(commentVal);
|
||||||
comment.asc_putTime(this.utcDateToString(new Date()));
|
comment.asc_putTime(this.utcDateToString(new Date()));
|
||||||
comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date()));
|
comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date()));
|
||||||
|
@ -1348,7 +1350,7 @@ define([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearDummyComment: function () {
|
clearDummyComment: function (clear) {
|
||||||
if (this.isDummyComment) {
|
if (this.isDummyComment) {
|
||||||
this.isDummyComment = false;
|
this.isDummyComment = false;
|
||||||
|
|
||||||
|
@ -1360,6 +1362,9 @@ define([
|
||||||
|
|
||||||
var dialog = this.getPopover();
|
var dialog = this.getPopover();
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
|
clear && dialog.clearDummyText();
|
||||||
|
dialog.saveDummyText();
|
||||||
|
|
||||||
dialog.handlerHide = (function () {
|
dialog.handlerHide = (function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -386,6 +386,7 @@ define([
|
||||||
|
|
||||||
if (record.get('dummy')) {
|
if (record.get('dummy')) {
|
||||||
var commentVal = this.getActiveTextBoxVal();
|
var commentVal = this.getActiveTextBoxVal();
|
||||||
|
me.clearDummyText();
|
||||||
if (commentVal.length > 0)
|
if (commentVal.length > 0)
|
||||||
me.fireEvent('comment:addDummyComment', [commentVal]);
|
me.fireEvent('comment:addDummyComment', [commentVal]);
|
||||||
else {
|
else {
|
||||||
|
@ -414,6 +415,7 @@ define([
|
||||||
|
|
||||||
} else if (btn.hasClass('btn-inner-close', false)) {
|
} else if (btn.hasClass('btn-inner-close', false)) {
|
||||||
if (record.get('dummy')) {
|
if (record.get('dummy')) {
|
||||||
|
me.clearDummyText();
|
||||||
me.hide();
|
me.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -460,7 +462,7 @@ define([
|
||||||
me.commentsView.autoHeightTextBox();
|
me.commentsView.autoHeightTextBox();
|
||||||
me.$window.find('textarea').keydown(function (event) {
|
me.$window.find('textarea').keydown(function (event) {
|
||||||
if (event.keyCode == Common.UI.Keys.ESC) {
|
if (event.keyCode == Common.UI.Keys.ESC) {
|
||||||
me.hide();
|
me.hide(true); // clear text in dummy comment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -583,7 +585,7 @@ define([
|
||||||
|
|
||||||
hide: function () {
|
hide: function () {
|
||||||
if (this.handlerHide) {
|
if (this.handlerHide) {
|
||||||
this.handlerHide();
|
this.handlerHide.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hideTips();
|
this.hideTips();
|
||||||
|
@ -846,6 +848,22 @@ define([
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
|
saveDummyText: function () {
|
||||||
|
if (this.commentsView && this.commentsView.cmpEl.find('.lock-area').length < 1) {
|
||||||
|
this.textDummyVal = this.commentsView.getActiveTextBoxVal();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clearDummyText: function () {
|
||||||
|
if (this.commentsView && this.commentsView.cmpEl.find('.lock-area').length < 1) {
|
||||||
|
this.textDummyVal = undefined;
|
||||||
|
var textBox = this.commentsView.getTextBox();
|
||||||
|
textBox && textBox.val('');
|
||||||
|
this.commentsView.clearTextBoxBind();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getDummyText: function() {
|
||||||
|
return this.textDummyVal || '';
|
||||||
|
},
|
||||||
|
|
||||||
hookTextBox: function () {
|
hookTextBox: function () {
|
||||||
var me = this, textBox = this.commentsView.getTextBox();
|
var me = this, textBox = this.commentsView.getTextBox();
|
||||||
|
|
Loading…
Reference in a new issue