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') {
|
if (rgx === null || typeof rgx[1] === 'undefined') {
|
||||||
this._scrollList($article, direction);
|
this._scrollList($article, direction);
|
||||||
} else {
|
} else {
|
||||||
Discourse.TopicView.jumpToPost(rgx[1]);
|
Discourse.URL.jumpToPost(rgx[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*global LockOn:true*/
|
||||||
/**
|
/**
|
||||||
URL related functions.
|
URL related functions.
|
||||||
|
|
||||||
|
@ -10,6 +11,29 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||||
// Used for matching a topic
|
// Used for matching a topic
|
||||||
TOPIC_REGEXP: /\/t\/([^\/]+)\/(\d+)\/?(\d+)?/,
|
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.
|
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);
|
topicProgressController.set('progressPosition', closest);
|
||||||
Discourse.PostView.considerHighlighting(topicController, closest);
|
Discourse.PostView.considerHighlighting(topicController, closest);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
Discourse.TopicView.jumpToPost(closest);
|
Discourse.URL.jumpToPost(closest);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Abort routing, we have replaced our state.
|
// Abort routing, we have replaced our state.
|
||||||
|
|
|
@ -35,7 +35,7 @@ Discourse.TopicFromParamsRoute = Discourse.Route.extend({
|
||||||
progressPosition: closest,
|
progressPosition: closest,
|
||||||
expanded: false
|
expanded: false
|
||||||
});
|
});
|
||||||
Discourse.TopicView.jumpToPost(closest);
|
Discourse.URL.jumpToPost(closest);
|
||||||
|
|
||||||
if (topic.present('draft')) {
|
if (topic.present('draft')) {
|
||||||
composerController.open({
|
composerController.open({
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
/*global LockOn:true*/
|
import AddCategoryClass from 'discourse/mixins/add-category-class';
|
||||||
|
|
||||||
/**
|
export default Discourse.View.extend(AddCategoryClass, Discourse.Scrolling, {
|
||||||
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, {
|
|
||||||
templateName: 'topic',
|
templateName: 'topic',
|
||||||
topicBinding: 'controller.model',
|
topicBinding: 'controller.model',
|
||||||
userFiltersBinding: 'controller.userFilters',
|
userFiltersBinding: 'controller.userFilters',
|
||||||
|
@ -21,6 +12,8 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
menuVisible: true,
|
menuVisible: true,
|
||||||
SHORT_POST: 1200,
|
SHORT_POST: 1200,
|
||||||
|
|
||||||
|
categoryId: Em.computed.alias('topic.category.id'),
|
||||||
|
|
||||||
postStream: Em.computed.alias('controller.postStream'),
|
postStream: Em.computed.alias('controller.postStream'),
|
||||||
|
|
||||||
_updateTitle: function() {
|
_updateTitle: function() {
|
||||||
|
@ -186,29 +179,4 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
return I18n.t("topic.read_more", opts);
|
return I18n.t("topic.read_more", opts);
|
||||||
}
|
}
|
||||||
}.property('topicTrackingState.messageCount')
|
}.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