Fix comment highlightning in the SPV

This commit is contained in:
Steffen van Bergerem 2016-11-12 14:17:49 +01:00
parent 5808b84e83
commit 55349162bd
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
2 changed files with 4 additions and 3 deletions

View file

@ -11,7 +11,6 @@ app.pages.SinglePostViewer = app.views.Base.extend({
initialize : function() {
this.model = new app.models.Post(gon.post);
this.initViews();
this.model.comments.fetch(); // async, yo, might want to throttle this later.
},
initViews : function() {

View file

@ -8,6 +8,9 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
$(window).on('hashchange',this.highlightPermalinkComment);
this.setupBindings();
this.model.comments.on("reset", this.render, this);
this.model.comments.fetch({success: function() {
setTimeout(this.highlightPermalinkComment, 0);
}.bind(this)});
},
highlightPermalinkComment: function() {
@ -17,14 +20,13 @@ app.views.SinglePostCommentStream = app.views.CommentStream.extend({
$(".highlighted").removeClass("highlighted");
element.addClass("highlighted");
var pos = element.offset().top - headerSize;
window.scroll(0, pos);
$("html,body").animate({scrollTop: pos});
}
},
postRenderTemplate: function() {
app.views.CommentStream.prototype.postRenderTemplate.apply(this);
this.$(".new-comment-form-wrapper").removeClass("hidden");
_.defer(this.highlightPermalinkComment);
},
presenter: function(){