From fbd59eaf24f87b5eefe21018139bbf839ba21734 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Aug 2018 16:43:06 +0300 Subject: [PATCH] Fix comments: scroll to edit buttons, update height after closing edit box and adding reply. --- apps/common/main/lib/view/ReviewPopover.js | 47 ++++++++++++---------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/apps/common/main/lib/view/ReviewPopover.js b/apps/common/main/lib/view/ReviewPopover.js index d2738d796..067cef0a6 100644 --- a/apps/common/main/lib/view/ReviewPopover.js +++ b/apps/common/main/lib/view/ReviewPopover.js @@ -196,7 +196,7 @@ define([ } parentView.scroller.scrollTop(scrollPos); - view.autoScrollToEditButtons(); + parentView.autoScrollToEditButtons(); } if (textBox && textBox.length) { @@ -216,23 +216,6 @@ define([ this.textBox.unbind('input propertychange'); this.textBox = undefined; } - }, - autoScrollToEditButtons: function () { - var button = $('#id-comments-change-popover'), // TODO: add to cache - btnBounds = null, - contentBounds = this.el.getBoundingClientRect(), - moveY = 0, - padding = 7; - - if (button.length) { - btnBounds = button.get(0).getBoundingClientRect(); - if (btnBounds && contentBounds) { - moveY = contentBounds.bottom - (btnBounds.bottom + padding); - if (moveY < 0) { - parentView.scroller.scrollTop(parentView.scroller.getScrollTop() - moveY); - } - } - } } } })()); @@ -328,7 +311,7 @@ define([ me.hookTextBox(); - this.autoScrollToEditButtons(); + me.autoScrollToEditButtons(); this.setFocusToTextBox(); } else { if (!showEditBox) { @@ -347,7 +330,7 @@ define([ me.hookTextBox(); - this.autoScrollToEditButtons(); + me.autoScrollToEditButtons(); this.setFocusToTextBox(); } } @@ -380,7 +363,7 @@ define([ this.autoHeightTextBox(); me.hookTextBox(); - this.autoScrollToEditButtons(); + me.autoScrollToEditButtons(); this.setFocusToTextBox(); } else if (btn.hasClass('btn-reply', false)) { if (showReplyBox) { @@ -388,6 +371,7 @@ define([ me.fireEvent('comment:addReply', [commentId, this.getActiveTextBoxVal()]); me.fireEvent('comment:closeEditing'); + me.calculateSizeOfContent(); readdresolves(); } @@ -774,6 +758,8 @@ define([ sdkBoundsTopPos = 0; if (commentsView && arrowView && commentsView.get(0)) { + var scrollPos = this.scroller.getScrollTop(); + commentsView.css({height: '100%'}); contentBounds = commentsView.get(0).getBoundingClientRect(); @@ -813,6 +799,7 @@ define([ arrowPosY = Math.min(arrowPosY, sdkBoundsHeight - (sdkPanelHeight + this.arrow.margin + this.arrow.width)); arrowView.css({top: arrowPosY + 'px'}); + this.scroller.scrollTop(scrollPos); } else { outerHeight = windowHeight; @@ -922,6 +909,24 @@ define([ return this.popover; }, + autoScrollToEditButtons: function () { + var button = $('#id-comments-change-popover'), // TODO: add to cache + btnBounds = null, + contentBounds = this.$window[0].getBoundingClientRect(), + moveY = 0, + padding = 7; + + if (button.length) { + btnBounds = button.get(0).getBoundingClientRect(); + if (btnBounds && contentBounds) { + moveY = contentBounds.bottom - (btnBounds.bottom + padding); + if (moveY < 0) { + this.scroller.scrollTop(this.scroller.getScrollTop() - moveY); + } + } + } + }, + textAddReply : 'Add Reply', textAdd : "Add", textCancel : 'Cancel',