mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 01:56:01 -05:00
FIX: When expanding embedded replies, adjust the scroll position to not lose your place
This commit is contained in:
parent
cc2acafc9a
commit
f2a1ef8d7d
4 changed files with 36 additions and 20 deletions
|
@ -308,24 +308,6 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
|
|||
this.get('content').toggleStar();
|
||||
},
|
||||
|
||||
/**
|
||||
Toggle the replies this post is a reply to
|
||||
|
||||
@method showReplyHistory
|
||||
**/
|
||||
toggleReplyHistory: function(post) {
|
||||
var replyHistory = post.get('replyHistory'),
|
||||
topicController = this;
|
||||
|
||||
if (replyHistory.length > 0) {
|
||||
replyHistory.clear();
|
||||
} else {
|
||||
post.set('loadingReplyHistory', true);
|
||||
topicController.get('postStream').findReplyHistory(post).then(function () {
|
||||
post.set('loadingReplyHistory', false);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Clears the pin from a topic for the currently logged in user
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<article class='boxed' {{bindAttr id="postElementId"}} {{bindAttr data-post-id="id"}} data-user-id="{{unbound user_id}}">
|
||||
<div class='row'>
|
||||
{{#if showUserReplyTab}}
|
||||
<a href='#' {{action toggleReplyHistory this}} class='reply-to-tab'>
|
||||
<a href='#' {{action toggleReplyHistory this target="view"}} class='reply-to-tab'>
|
||||
{{#if loadingReplyHistory}}
|
||||
{{i18n loading}}
|
||||
{{else}}
|
||||
|
|
|
@ -11,7 +11,8 @@ Discourse.EmbeddedPostView = Discourse.GroupedView.extend({
|
|||
classNames: ['reply'],
|
||||
|
||||
didInsertElement: function() {
|
||||
Discourse.ScreenTrack.current().track(this.get('elementId'), this.get('post.post_number'));
|
||||
var post = this.get('content');
|
||||
Discourse.ScreenTrack.current().track(this.get('elementId'), post.get('post_number'));
|
||||
},
|
||||
|
||||
willDestroyElement: function() {
|
||||
|
|
|
@ -135,6 +135,39 @@ Discourse.PostView = Discourse.GroupedView.extend({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
Toggle the replies this post is a reply to
|
||||
|
||||
@method showReplyHistory
|
||||
**/
|
||||
toggleReplyHistory: function(post) {
|
||||
|
||||
var replyHistory = post.get('replyHistory'),
|
||||
topicController = this.get('controller'),
|
||||
origScrollTop = $(window).scrollTop();
|
||||
|
||||
|
||||
if (replyHistory.length > 0) {
|
||||
var origHeight = this.$('.embedded-posts.top').height();
|
||||
|
||||
replyHistory.clear();
|
||||
Em.run.next(function() {
|
||||
$(window).scrollTop(origScrollTop - origHeight);
|
||||
});
|
||||
} else {
|
||||
post.set('loadingReplyHistory', true);
|
||||
|
||||
var self = this;
|
||||
topicController.get('postStream').findReplyHistory(post).then(function () {
|
||||
post.set('loadingReplyHistory', false);
|
||||
|
||||
Em.run.next(function() {
|
||||
$(window).scrollTop(origScrollTop + self.$('.embedded-posts.top').height());
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Add the quote controls to a post
|
||||
insertQuoteControls: function() {
|
||||
var postView = this;
|
||||
|
|
Loading…
Reference in a new issue