FIX: Posts weren't highlighting when jumping using the progress widget

This commit is contained in:
Robin Ward 2015-01-14 12:09:40 -05:00
parent 930fc4a109
commit 78d5d22776
2 changed files with 18 additions and 18 deletions

View file

@ -203,7 +203,6 @@ Discourse.URL = Em.Object.createWithMixins({
var container = Discourse.__container__,
topicController = container.lookup('controller:topic'),
topicProgressController = container.lookup('controller:topic-progress'),
opts = {},
postStream = topicController.get('postStream');
@ -218,8 +217,10 @@ Discourse.URL = Em.Object.createWithMixins({
enteredAt: new Date().getTime().toString()
});
var closestPost = postStream.closestPostForPostNumber(closest),
progress = postStream.progressIndexOfPost(closestPost);
topicProgressController.set('progressPosition', progress);
progress = postStream.progressIndexOfPost(closestPost),
progressController = container.lookup('controller:topic-progress');
progressController.set('progressPosition', progress);
Discourse.PostView.considerHighlighting(topicController, closest);
}).then(function() {
Discourse.URL.jumpToPost(closest);

View file

@ -307,28 +307,27 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
}.observes('controller.searchHighlight', 'cooked')
});
function highlight(postNumber) {
var $contents = $('#post_' + postNumber +' .topic-body'),
origColor = $contents.data('orig-color') || $contents.css('backgroundColor');
$contents.data("orig-color", origColor)
.addClass('highlighted')
.stop()
.animate({ backgroundColor: origColor }, 2500, 'swing', function(){
$contents.removeClass('highlighted');
$contents.css({'background-color': ''});
});
}
Discourse.PostView.reopenClass({
highlight: function(postNumber){
var $contents = $('#post_' + postNumber +' .topic-body'),
origColor = $contents.data('orig-color') || $contents.css('backgroundColor');
$contents.data("orig-color", origColor);
$contents
.addClass('highlighted')
.stop()
.animate({ backgroundColor: origColor }, 2500, 'swing', function(){
$contents.removeClass('highlighted');
$contents.css({'background-color': ''});
});
},
considerHighlighting: function(controller, postNumber) {
var highlightNumber = controller.get('highlightOnInsert');
// If we're meant to highlight a post
if (highlightNumber === postNumber) {
controller.set('highlightOnInsert', null);
this.highlight(postNumber);
Ember.run.scheduleOnce('afterRender', null, highlight, postNumber);
}
}
});