Merged in iss83 (pull request #44)

Показывать добавленный комментарий; Fixes #83
This commit is contained in:
isqua 2015-02-07 20:49:25 +03:00
commit 7b4e3f250a
1 changed files with 22 additions and 11 deletions

View File

@ -8,9 +8,9 @@ function AjaxComments() {
if (comments) {
this._comments = comments;
this.listen(comments);
}
this.listenFirstComments();
this.listenFirstComments();
}
}
/**
@ -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);
};
/**