From 0af418dced6038e56751d0b225dfb5ea8232c307 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 8 May 2018 11:07:01 +0300 Subject: [PATCH] revert commit 161bd0ee3d97ec5f3fd0d6284e90872855d5c5d2 (Bug 35896) --- .../common/main/lib/mods/perfect-scrollbar.js | 2 +- .../lib/template/CommentsPopover.template | 4 +- apps/common/main/lib/view/Comments.js | 61 ++++++++----------- apps/common/main/resources/less/comments.less | 10 +-- 4 files changed, 29 insertions(+), 48 deletions(-) diff --git a/apps/common/main/lib/mods/perfect-scrollbar.js b/apps/common/main/lib/mods/perfect-scrollbar.js index 3b4283bc6..9b6f650db 100644 --- a/apps/common/main/lib/mods/perfect-scrollbar.js +++ b/apps/common/main/lib/mods/perfect-scrollbar.js @@ -317,7 +317,7 @@ var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX, deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY; - if (e && e.target && (e.target.type === 'textarea' && !e.target.hasAttribute('readonly') || e.target.type === 'input')) { + if (e && e.target && (e.target.type === 'textarea' || e.target.type === 'input')) { e.stopImmediatePropagation(); e.preventDefault(); diff --git a/apps/common/main/lib/template/CommentsPopover.template b/apps/common/main/lib/template/CommentsPopover.template index 20f185e2e..9ca9e3ed8 100644 --- a/apps/common/main/lib/template/CommentsPopover.template +++ b/apps/common/main/lib/template/CommentsPopover.template @@ -5,7 +5,7 @@
<%=scope.getUserName(username)%>
<%=date%>
<% if (!editTextInPopover || hint) { %> - +
<%=scope.pickLink(comment)%>
<% } else { %>
@@ -27,7 +27,7 @@
<%=scope.getUserName(item.get("username"))%>
<%=item.get("date")%>
<% if (!item.get("editTextInPopover")) { %> - +
<%=scope.pickLink(item.get("reply"))%>
<% if (!hint) { %>
<% if (item.get("editable")) { %> diff --git a/apps/common/main/lib/view/Comments.js b/apps/common/main/lib/view/Comments.js index efda93c5c..a63c6538d 100644 --- a/apps/common/main/lib/view/Comments.js +++ b/apps/common/main/lib/view/Comments.js @@ -152,11 +152,11 @@ define([ }, getTextBox: function () { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); return (text && text.length) ? text : undefined; }, setFocusToTextBox: function (blur) { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); if (blur) { text.blur(); } else { @@ -169,16 +169,15 @@ define([ } }, getActiveTextBoxVal: function () { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); return (text && text.length) ? text.val().trim() : ''; }, autoHeightTextBox: function () { var view = this, textBox = this.$el.find('textarea'), domTextBox = null, - $domTextBox = null, - lineHeight = 0, minHeight = 50, + lineHeight = 0, scrollPos = 0, oldHeight = 0, newHeight = 0; @@ -187,17 +186,17 @@ define([ scrollPos = $(view.scroller.el).scrollTop(); if (domTextBox.scrollHeight > domTextBox.clientHeight) { - $domTextBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'}); + textBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'}); parentView.calculateSizeOfContent(); } else { oldHeight = domTextBox.clientHeight; if (oldHeight >= minHeight) { - $domTextBox.css({height: minHeight + 'px'}); + textBox.css({height: minHeight + 'px'}); if (domTextBox.scrollHeight > domTextBox.clientHeight) { newHeight = Math.max(domTextBox.scrollHeight + lineHeight, minHeight); - $domTextBox.css({height: newHeight + 'px'}); + textBox.css({height: newHeight + 'px'}); } parentView.calculateSizeOfContent(); @@ -210,23 +209,17 @@ define([ view.autoScrollToEditButtons(); } - this.textBox = undefined; if (textBox && textBox.length) { - textBox.each(function(idx, item){ - if (item) { - domTextBox = item; - $domTextBox = $(item); - var isEdited = !$domTextBox.hasClass('user-message'); - lineHeight = isEdited ? parseInt($domTextBox.css('lineHeight'), 10) * 0.25 : 0; - minHeight = isEdited ? 50 : 24; - updateTextBoxHeight(); - if (isEdited) { - $domTextBox.bind('input propertychange', updateTextBoxHeight); - view.textBox = $domTextBox; - } - } - }); + domTextBox = textBox.get(0); + + if (domTextBox) { + lineHeight = parseInt(textBox.css('lineHeight'), 10) * 0.25; + updateTextBoxHeight(); + textBox.bind('input propertychange', updateTextBoxHeight) + } } + + this.textBox = textBox; }, clearTextBoxBind: function () { if (this.textBox) { @@ -383,7 +376,6 @@ define([ t.fireEvent('comment:closeEditing'); readdresolves(); - this.autoHeightTextBox(); } else if (btn.hasClass('user-reply')) { t.fireEvent('comment:closeEditing'); @@ -408,7 +400,6 @@ define([ t.fireEvent('comment:closeEditing'); readdresolves(); - this.autoHeightTextBox(); } } else if (btn.hasClass('btn-close', false)) { t.fireEvent('comment:closeEditing', [commentId]); @@ -416,7 +407,6 @@ define([ t.fireEvent('comment:show', [commentId]); readdresolves(); - this.autoHeightTextBox(); } else if (btn.hasClass('btn-inner-edit', false)) { @@ -447,7 +437,6 @@ define([ } readdresolves(); - this.autoHeightTextBox(); } else if (btn.hasClass('btn-inner-close', false)) { if (record.get('dummy')) { @@ -459,8 +448,11 @@ define([ me.saveText(); record.set('hideAddReply', false); this.getTextBox().val(me.textVal); + this.autoHeightTextBox(); } else { + this.clearTextBoxBind(); + t.fireEvent('comment:closeEditing', [commentId]); } @@ -471,7 +463,6 @@ define([ me.calculateSizeOfContent(); readdresolves(); - this.autoHeightTextBox(); } else if (btn.hasClass('btn-resolve', false)) { var tip = btn.data('bs.tooltip'); @@ -480,7 +471,6 @@ define([ t.fireEvent('comment:resolve', [commentId]); readdresolves(); - this.autoHeightTextBox(); } else if (btn.hasClass('btn-resolve-check', false)) { var tip = btn.data('bs.tooltip'); if (tip) tip.dontShow = true; @@ -488,21 +478,20 @@ define([ t.fireEvent('comment:resolve', [commentId]); readdresolves(); - this.autoHeightTextBox(); } } }); me.on({ 'show': function () { - me.$window.find('textarea:not(.user-message)').keydown(function (event) { + me.commentsView.autoHeightTextBox(); + me.$window.find('textarea').keydown(function (event) { if (event.keyCode == Common.UI.Keys.ESC) { me.hide(); } }); }, 'animate:before': function () { - me.commentsView.autoHeightTextBox(); - var text = me.$window.find('textarea:not(.user-message)'); + var text = me.$window.find('textarea'); if (text && text.length) text.focus(); } @@ -910,11 +899,11 @@ define([ }, getTextBox: function () { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); return (text && text.length) ? text : undefined; }, setFocusToTextBox: function () { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); if (text && text.length) { var val = text.val(); text.focus(); @@ -923,7 +912,7 @@ define([ } }, getActiveTextBoxVal: function () { - var text = $(this.el).find('textarea:not(.user-message)'); + var text = $(this.el).find('textarea'); return (text && text.length) ? text.val().trim() : ''; }, autoHeightTextBox: function () { diff --git a/apps/common/main/resources/less/comments.less b/apps/common/main/resources/less/comments.less index 6fdc89c6f..a68083394 100644 --- a/apps/common/main/resources/less/comments.less +++ b/apps/common/main/resources/less/comments.less @@ -78,7 +78,7 @@ overflow: hidden; color: @gray-darker; - textarea:not(.user-message) { + textarea { width: 100%; height: 50px; resize: none; @@ -171,14 +171,6 @@ } } - textarea.user-message { - border: none; - resize: none; - width: 100%; - line-height: 15px; - cursor: text; - } - .user-reply { color: @black; margin-top: 10px;