mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:05:24 +08:00
FIX: Apply category class when inside a topic of that category
This commit is contained in:
parent
c94cf78291
commit
f62b05c985
|
@ -224,7 +224,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
|||
if (rgx === null || typeof rgx[1] === 'undefined') {
|
||||
this._scrollList($article, direction);
|
||||
} else {
|
||||
Discourse.TopicView.jumpToPost(rgx[1]);
|
||||
Discourse.URL.jumpToPost(rgx[1]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*global LockOn:true*/
|
||||
/**
|
||||
URL related functions.
|
||||
|
||||
|
@ -10,6 +11,29 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||
// Used for matching a topic
|
||||
TOPIC_REGEXP: /\/t\/([^\/]+)\/(\d+)\/?(\d+)?/,
|
||||
|
||||
/**
|
||||
Jumps to a particular post in the stream
|
||||
**/
|
||||
jumpToPost: function(postNumber) {
|
||||
var holderId = '#post-cloak-' + postNumber;
|
||||
|
||||
Em.run.schedule('afterRender', function() {
|
||||
if (postNumber === 1) {
|
||||
$(window).scrollTop(0);
|
||||
return;
|
||||
}
|
||||
|
||||
new LockOn(holderId, {offsetCalculator: function() {
|
||||
var $header = $('header'),
|
||||
$title = $('#topic-title'),
|
||||
windowHeight = $(window).height() - $title.height(),
|
||||
expectedOffset = $title.height() - $header.find('.contents').height() + (windowHeight / 5);
|
||||
|
||||
return $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset);
|
||||
}}).lock();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
Browser aware replaceState. Will only be invoked if the browser supports it.
|
||||
|
||||
|
@ -181,7 +205,7 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||
topicProgressController.set('progressPosition', closest);
|
||||
Discourse.PostView.considerHighlighting(topicController, closest);
|
||||
}).then(function() {
|
||||
Discourse.TopicView.jumpToPost(closest);
|
||||
Discourse.URL.jumpToPost(closest);
|
||||
});
|
||||
|
||||
// Abort routing, we have replaced our state.
|
||||
|
|
|
@ -35,7 +35,7 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
|||
progressPosition: closest,
|
||||
expanded: false
|
||||
});
|
||||
Discourse.TopicView.jumpToPost(closest);
|
||||
Discourse.URL.jumpToPost(closest);
|
||||
|
||||
if (topic.present('draft')) {
|
||||
composerController.open({
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
/*global LockOn:true*/
|
||||
import AddCategoryClass from 'discourse/mixins/add-category-class';
|
||||
|
||||
/**
|
||||
This view is for rendering an icon representing the status of a topic
|
||||
|
||||
@class TopicView
|
||||
@extends Discourse.View
|
||||
@namespace Discourse
|
||||
@uses Discourse.Scrolling
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||
export default Discourse.View.extend(AddCategoryClass, Discourse.Scrolling, {
|
||||
templateName: 'topic',
|
||||
topicBinding: 'controller.model',
|
||||
userFiltersBinding: 'controller.userFilters',
|
||||
|
@ -21,6 +12,8 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
|||
menuVisible: true,
|
||||
SHORT_POST: 1200,
|
||||
|
||||
categoryId: Em.computed.alias('topic.category.id'),
|
||||
|
||||
postStream: Em.computed.alias('controller.postStream'),
|
||||
|
||||
_updateTitle: function() {
|
||||
|
@ -186,29 +179,4 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
|||
return I18n.t("topic.read_more", opts);
|
||||
}
|
||||
}.property('topicTrackingState.messageCount')
|
||||
|
||||
});
|
||||
|
||||
Discourse.TopicView.reopenClass({
|
||||
|
||||
jumpToPost: function(postNumber) {
|
||||
var holderId = '#post-cloak-' + postNumber;
|
||||
|
||||
Em.run.schedule('afterRender', function() {
|
||||
if (postNumber === 1) {
|
||||
$(window).scrollTop(0);
|
||||
return;
|
||||
}
|
||||
|
||||
new LockOn(holderId, {offsetCalculator: function() {
|
||||
var $header = $('header'),
|
||||
$title = $('#topic-title'),
|
||||
windowHeight = $(window).height() - $title.height(),
|
||||
expectedOffset = $title.height() - $header.find('.contents').height() + (windowHeight / 5);
|
||||
|
||||
return $header.outerHeight(true) + ((expectedOffset < 0) ? 0 : expectedOffset);
|
||||
}}).lock();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user