diff --git a/app/assets/javascripts/discourse/lib/url.js b/app/assets/javascripts/discourse/lib/url.js index e196943e5..8c6b1dccc 100644 --- a/app/assets/javascripts/discourse/lib/url.js +++ b/app/assets/javascripts/discourse/lib/url.js @@ -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); diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index f95f12e25..77806e107 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -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); } } });