diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 47d095e8b..4a1511e70 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -1299,8 +1299,8 @@ define([ dialog.hide(); } - dialog.handlerHide = (function () { - me.clearDummyComment(); + dialog.handlerHide = (function (clear) { + me.clearDummyComment(clear); }); anchor = this.api.asc_getAnchorPosition(); @@ -1309,7 +1309,7 @@ define([ anchor.asc_getY(), 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.isSelectedComment = false; this.uids = []; - this.isDummyComment = false; this.popoverComments.reset(); if (this.getPopover().isVisible()) { this.getPopover().hideComments(); } + + this.isDummyComment = false; + comment.asc_putText(commentVal); comment.asc_putTime(this.utcDateToString(new Date())); comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date())); @@ -1348,7 +1350,7 @@ define([ } } }, - clearDummyComment: function () { + clearDummyComment: function (clear) { if (this.isDummyComment) { this.isDummyComment = false; @@ -1360,6 +1362,9 @@ define([ var dialog = this.getPopover(); if (dialog) { + clear && dialog.clearDummyText(); + dialog.saveDummyText(); + dialog.handlerHide = (function () { }); diff --git a/apps/common/main/lib/view/ReviewPopover.js b/apps/common/main/lib/view/ReviewPopover.js index 7d7d0090f..893b06b75 100644 --- a/apps/common/main/lib/view/ReviewPopover.js +++ b/apps/common/main/lib/view/ReviewPopover.js @@ -386,6 +386,7 @@ define([ if (record.get('dummy')) { var commentVal = this.getActiveTextBoxVal(); + me.clearDummyText(); if (commentVal.length > 0) me.fireEvent('comment:addDummyComment', [commentVal]); else { @@ -414,6 +415,7 @@ define([ } else if (btn.hasClass('btn-inner-close', false)) { if (record.get('dummy')) { + me.clearDummyText(); me.hide(); return; } @@ -460,7 +462,7 @@ define([ me.commentsView.autoHeightTextBox(); me.$window.find('textarea').keydown(function (event) { if (event.keyCode == Common.UI.Keys.ESC) { - me.hide(); + me.hide(true); // clear text in dummy comment } }); }, @@ -583,7 +585,7 @@ define([ hide: function () { if (this.handlerHide) { - this.handlerHide(); + this.handlerHide.apply(this, arguments); } this.hideTips(); @@ -846,6 +848,22 @@ define([ 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 () { var me = this, textBox = this.commentsView.getTextBox();