mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-12-28 17:24:20 +00:00
Скроллить к добавленному комментарию на странице поста
This commit is contained in:
parent
62e20aca51
commit
00846a56cc
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue