Fix Bug 35896.

This commit is contained in:
Julia Radzhabova 2017-09-28 14:02:33 +03:00
parent a3117efe05
commit 161bd0ee3d
4 changed files with 48 additions and 29 deletions

View file

@ -317,7 +317,7 @@
var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX, var deltaX = e.deltaX * e.deltaFactor || deprecatedDeltaX,
deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY; deltaY = e.deltaY * e.deltaFactor || deprecatedDeltaY;
if (e && e.target && (e.target.type === 'textarea' || e.target.type === 'input')) { if (e && e.target && (e.target.type === 'textarea' && !e.target.hasAttribute('readonly') || e.target.type === 'input')) {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
e.preventDefault(); e.preventDefault();

View file

@ -5,7 +5,7 @@
<div class="user-name"><%=scope.getUserName(username)%></div> <div class="user-name"><%=scope.getUserName(username)%></div>
<div class="user-date"><%=date%></div> <div class="user-date"><%=date%></div>
<% if (!editTextInPopover || hint) { %> <% if (!editTextInPopover || hint) { %>
<div class="user-message"><%=scope.pickLink(comment)%></div> <textarea readonly class="user-message user-select"><%=scope.pickLink(comment)%></textarea>
<% } else { %> <% } else { %>
<div class="inner-edit-ct"> <div class="inner-edit-ct">
<textarea class="msg-reply user-select" maxlength="maxCommLength"><%=comment%></textarea> <textarea class="msg-reply user-select" maxlength="maxCommLength"><%=comment%></textarea>
@ -27,7 +27,7 @@
<div class="user-name"><%=scope.getUserName(item.get("username"))%></div> <div class="user-name"><%=scope.getUserName(item.get("username"))%></div>
<div class="user-date"><%=item.get("date")%></div> <div class="user-date"><%=item.get("date")%></div>
<% if (!item.get("editTextInPopover")) { %> <% if (!item.get("editTextInPopover")) { %>
<div class="user-message"><%=scope.pickLink(item.get("reply"))%></div> <textarea readonly class="user-message user-select"><%=scope.pickLink(item.get("reply"))%></textarea>
<% if (!hint) { %> <% if (!hint) { %>
<div class="btns-reply-ct"> <div class="btns-reply-ct">
<% if (item.get("editable")) { %> <% if (item.get("editable")) { %>

View file

@ -152,11 +152,11 @@ define([
}, },
getTextBox: function () { getTextBox: function () {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
return (text && text.length) ? text : undefined; return (text && text.length) ? text : undefined;
}, },
setFocusToTextBox: function (blur) { setFocusToTextBox: function (blur) {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
if (blur) { if (blur) {
text.blur(); text.blur();
} else { } else {
@ -169,15 +169,16 @@ define([
} }
}, },
getActiveTextBoxVal: function () { getActiveTextBoxVal: function () {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
return (text && text.length) ? text.val().trim() : ''; return (text && text.length) ? text.val().trim() : '';
}, },
autoHeightTextBox: function () { autoHeightTextBox: function () {
var view = this, var view = this,
textBox = this.$el.find('textarea'), textBox = this.$el.find('textarea'),
domTextBox = null, domTextBox = null,
minHeight = 50, $domTextBox = null,
lineHeight = 0, lineHeight = 0,
minHeight = 50,
scrollPos = 0, scrollPos = 0,
oldHeight = 0, oldHeight = 0,
newHeight = 0; newHeight = 0;
@ -186,17 +187,17 @@ define([
scrollPos = $(view.scroller.el).scrollTop(); scrollPos = $(view.scroller.el).scrollTop();
if (domTextBox.scrollHeight > domTextBox.clientHeight) { if (domTextBox.scrollHeight > domTextBox.clientHeight) {
textBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'}); $domTextBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'});
parentView.calculateSizeOfContent(); parentView.calculateSizeOfContent();
} else { } else {
oldHeight = domTextBox.clientHeight; oldHeight = domTextBox.clientHeight;
if (oldHeight >= minHeight) { if (oldHeight >= minHeight) {
textBox.css({height: minHeight + 'px'}); $domTextBox.css({height: minHeight + 'px'});
if (domTextBox.scrollHeight > domTextBox.clientHeight) { if (domTextBox.scrollHeight > domTextBox.clientHeight) {
newHeight = Math.max(domTextBox.scrollHeight + lineHeight, minHeight); newHeight = Math.max(domTextBox.scrollHeight + lineHeight, minHeight);
textBox.css({height: newHeight + 'px'}); $domTextBox.css({height: newHeight + 'px'});
} }
parentView.calculateSizeOfContent(); parentView.calculateSizeOfContent();
@ -209,17 +210,23 @@ define([
view.autoScrollToEditButtons(); view.autoScrollToEditButtons();
} }
this.textBox = undefined;
if (textBox && textBox.length) { if (textBox && textBox.length) {
domTextBox = textBox.get(0); textBox.each(function(idx, item){
if (item) {
if (domTextBox) { domTextBox = item;
lineHeight = parseInt(textBox.css('lineHeight'), 10) * 0.25; $domTextBox = $(item);
var isEdited = !$domTextBox.hasClass('user-message');
lineHeight = isEdited ? parseInt($domTextBox.css('lineHeight'), 10) * 0.25 : 0;
minHeight = isEdited ? 50 : 24;
updateTextBoxHeight(); updateTextBoxHeight();
textBox.bind('input propertychange', updateTextBoxHeight) if (isEdited) {
$domTextBox.bind('input propertychange', updateTextBoxHeight);
view.textBox = $domTextBox;
} }
} }
});
this.textBox = textBox; }
}, },
clearTextBoxBind: function () { clearTextBoxBind: function () {
if (this.textBox) { if (this.textBox) {
@ -375,6 +382,7 @@ define([
t.fireEvent('comment:closeEditing'); t.fireEvent('comment:closeEditing');
readdresolves(); readdresolves();
this.autoHeightTextBox();
} else if (btn.hasClass('user-reply')) { } else if (btn.hasClass('user-reply')) {
t.fireEvent('comment:closeEditing'); t.fireEvent('comment:closeEditing');
@ -399,6 +407,7 @@ define([
t.fireEvent('comment:closeEditing'); t.fireEvent('comment:closeEditing');
readdresolves(); readdresolves();
this.autoHeightTextBox();
} }
} else if (btn.hasClass('btn-close', false)) { } else if (btn.hasClass('btn-close', false)) {
t.fireEvent('comment:closeEditing', [commentId]); t.fireEvent('comment:closeEditing', [commentId]);
@ -406,6 +415,7 @@ define([
t.fireEvent('comment:show', [commentId]); t.fireEvent('comment:show', [commentId]);
readdresolves(); readdresolves();
this.autoHeightTextBox();
} else if (btn.hasClass('btn-inner-edit', false)) { } else if (btn.hasClass('btn-inner-edit', false)) {
@ -427,6 +437,7 @@ define([
} }
readdresolves(); readdresolves();
this.autoHeightTextBox();
} else if (btn.hasClass('btn-inner-close', false)) { } else if (btn.hasClass('btn-inner-close', false)) {
if (record.get('dummy')) { if (record.get('dummy')) {
@ -438,11 +449,8 @@ define([
me.saveText(); me.saveText();
record.set('hideAddReply', false); record.set('hideAddReply', false);
this.getTextBox().val(me.textVal); this.getTextBox().val(me.textVal);
this.autoHeightTextBox();
} else { } else {
this.clearTextBoxBind(); this.clearTextBoxBind();
t.fireEvent('comment:closeEditing', [commentId]); t.fireEvent('comment:closeEditing', [commentId]);
} }
@ -453,6 +461,7 @@ define([
me.calculateSizeOfContent(); me.calculateSizeOfContent();
readdresolves(); readdresolves();
this.autoHeightTextBox();
} else if (btn.hasClass('btn-resolve', false)) { } else if (btn.hasClass('btn-resolve', false)) {
var tip = btn.data('bs.tooltip'); var tip = btn.data('bs.tooltip');
@ -461,6 +470,7 @@ define([
t.fireEvent('comment:resolve', [commentId]); t.fireEvent('comment:resolve', [commentId]);
readdresolves(); readdresolves();
this.autoHeightTextBox();
} else if (btn.hasClass('btn-resolve-check', false)) { } else if (btn.hasClass('btn-resolve-check', false)) {
var tip = btn.data('bs.tooltip'); var tip = btn.data('bs.tooltip');
if (tip) tip.dontShow = true; if (tip) tip.dontShow = true;
@ -468,20 +478,21 @@ define([
t.fireEvent('comment:resolve', [commentId]); t.fireEvent('comment:resolve', [commentId]);
readdresolves(); readdresolves();
this.autoHeightTextBox();
} }
} }
}); });
me.on({ me.on({
'show': function () { 'show': function () {
me.commentsView.autoHeightTextBox(); me.$window.find('textarea:not(.user-message)').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();
} }
}); });
}, },
'animate:before': function () { 'animate:before': function () {
var text = me.$window.find('textarea'); me.commentsView.autoHeightTextBox();
var text = me.$window.find('textarea:not(.user-message)');
if (text && text.length) if (text && text.length)
text.focus(); text.focus();
} }
@ -889,11 +900,11 @@ define([
}, },
getTextBox: function () { getTextBox: function () {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
return (text && text.length) ? text : undefined; return (text && text.length) ? text : undefined;
}, },
setFocusToTextBox: function () { setFocusToTextBox: function () {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
if (text && text.length) { if (text && text.length) {
var val = text.val(); var val = text.val();
text.focus(); text.focus();
@ -902,7 +913,7 @@ define([
} }
}, },
getActiveTextBoxVal: function () { getActiveTextBoxVal: function () {
var text = $(this.el).find('textarea'); var text = $(this.el).find('textarea:not(.user-message)');
return (text && text.length) ? text.val().trim() : ''; return (text && text.length) ? text.val().trim() : '';
}, },
autoHeightTextBox: function () { autoHeightTextBox: function () {

View file

@ -78,7 +78,7 @@
overflow: hidden; overflow: hidden;
color: @gray-darker; color: @gray-darker;
textarea { textarea:not(.user-message) {
width: 100%; width: 100%;
height: 50px; height: 50px;
resize: none; resize: none;
@ -172,6 +172,14 @@
} }
} }
textarea.user-message {
border: none;
resize: none;
width: 100%;
line-height: 15px;
cursor: text;
}
.user-reply { .user-reply {
color: @black; color: @black;
margin-top: 10px; margin-top: 10px;