mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
Highlight posts when jumping to them.
This commit is contained in:
parent
1876407db8
commit
42ca46e628
@ -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);
|
||||
});
|
||||
|
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user