From 00846a56ccb5adfe5123ef87429d3c1a39f49e2c Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 7 Feb 2015 20:11:23 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=BE=D0=BB=D0=BB=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BA=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=BE=D0=BC=D1=83=20=D0=BA=D0=BE=D0=BC=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D1=8E=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/modules/ajax-comments.js | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/chrome_point_plus/modules/ajax-comments.js b/chrome_point_plus/modules/ajax-comments.js index 640cf60..9e25d99 100644 --- a/chrome_point_plus/modules/ajax-comments.js +++ b/chrome_point_plus/modules/ajax-comments.js @@ -165,15 +165,7 @@ AjaxCommentProcessor.prototype.onSuccess = function(data, textStatus) { if (data.error) { this.onError(null, null, data.error); } else { - // Creating the comment HTML - create_comment_elements({ - id: data.comment_id, - toId: this._commentId || null, - postId: this._postId, - author: $('#name h1').text(), - text: this._text, - fadeOut: true - }, this.insertComment.bind(this)); + this.createComment(data); this.hideForm(); @@ -184,6 +176,17 @@ AjaxCommentProcessor.prototype.onSuccess = function(data, textStatus) { } }; +AjaxCommentProcessor.prototype.createComment = function(data) { + create_comment_elements({ + id: data.comment_id, + toId: this._commentId || null, + postId: this._postId, + author: $('#name h1').text(), + text: this._text, + fadeOut: true + }, this.insertComment.bind(this)); +}; + /** * Вставляет комментарий в DOM * @param {jQuery} $comment @@ -212,6 +215,14 @@ AjaxCommentProcessor.prototype.insertComment = function($comment) { ); } } + + this.showComment($comment); +}; + +AjaxCommentProcessor.prototype.showComment = function($comment) { + $('body').animate({ + scrollTop: $comment.offset().top + }, 500); }; /** From 35b1a2c309de78250de8fab1958602e4398ec2a0 Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 7 Feb 2015 20:15:20 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D1=80=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=BE=D1=81=D1=82=20=D0=B8=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B9,=20?= =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D0=B9=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BD=D0=B5=20=D1=81=D0=BE=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/modules/ajax-comments.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome_point_plus/modules/ajax-comments.js b/chrome_point_plus/modules/ajax-comments.js index 9e25d99..8e51d6a 100644 --- a/chrome_point_plus/modules/ajax-comments.js +++ b/chrome_point_plus/modules/ajax-comments.js @@ -8,9 +8,9 @@ function AjaxComments() { if (comments) { this._comments = comments; this.listen(comments); - } - this.listenFirstComments(); + this.listenFirstComments(); + } } /**