diff --git a/app/assets/javascripts/discourse/lib/url.js b/app/assets/javascripts/discourse/lib/url.js index 851b0a64e32..def4300238b 100644 --- a/app/assets/javascripts/discourse/lib/url.js +++ b/app/assets/javascripts/discourse/lib/url.js @@ -179,6 +179,7 @@ Discourse.URL = Em.Object.createWithMixins({ enteredAt: new Date().getTime().toString() }); topicProgressController.set('progressPosition', closest); + Discourse.PostView.considerHighlighting(topicController, closest); }).then(function() { Discourse.TopicView.jumpToPost(closest); }); diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index e829c3c6f49..38419310ae1 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -226,29 +226,18 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { didInsertElement: function() { var $post = this.$(), post = this.get('post'), - postNumber = post.get('post_number'), - highlightNumber = this.get('controller.highlightOnInsert'); - - // If we're meant to highlight a post - if ((highlightNumber > 1) && (highlightNumber === postNumber)) { - this.set('controller.highlightOnInsert', null); - var $contents = $('#post_' + postNumber +' .topic-body', $post), - 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'); - }); - } + postNumber = post.get('post_number'); this.showLinkCounts(); // Track this post Discourse.ScreenTrack.current().track(this.$().prop('id'), postNumber); + // Highlight the post if required + if (postNumber > 1) { + Discourse.PostView.considerHighlighting(this.get('controller'), postNumber); + } + // Add syntax highlighting Discourse.SyntaxHighlighting.apply($post); Discourse.Lightbox.apply($post); @@ -280,3 +269,24 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { } }.observes('controller.searchHighlight', 'cooked') }); + +Discourse.PostView.reopenClass({ + considerHighlighting: function(controller, postNumber) { + var highlightNumber = controller.get('highlightOnInsert'); + + // If we're meant to highlight a post + if (highlightNumber === postNumber) { + controller.set('highlightOnInsert', null); + 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'); + }); + } + } +});