FEATURE: Include category / subcategory name in document title when
viewing a topic.
This commit is contained in:
parent
e2d40c033a
commit
2b2837fa12
|
@ -23,7 +23,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, {
|
||||||
// and are sometimes lazily loaded.
|
// and are sometimes lazily loaded.
|
||||||
this.send('refreshTitle');
|
this.send('refreshTitle');
|
||||||
}
|
}
|
||||||
}.observes('title'),
|
}.observes('title', 'category'),
|
||||||
|
|
||||||
termChanged: function() {
|
termChanged: function() {
|
||||||
var dropdown = this.get('controllers.header.visibleDropdown');
|
var dropdown = this.get('controllers.header.visibleDropdown');
|
||||||
|
|
|
@ -21,6 +21,10 @@ Discourse.Route = Ember.Route.extend({
|
||||||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_refreshTitleOnce: function() {
|
||||||
|
this.send('_collectTitleTokens', []);
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
_collectTitleTokens: function(tokens) {
|
_collectTitleTokens: function(tokens) {
|
||||||
// If there's a title token method, call it and get the token
|
// If there's a title token method, call it and get the token
|
||||||
|
@ -40,7 +44,7 @@ Discourse.Route = Ember.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTitle: function() {
|
refreshTitle: function() {
|
||||||
this.send('_collectTitleTokens', []);
|
Ember.run.once(this, this._refreshTitleOnce);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,20 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
||||||
titleToken: function() {
|
titleToken: function() {
|
||||||
var model = this.modelFor('topic');
|
var model = this.modelFor('topic');
|
||||||
if (model) {
|
if (model) {
|
||||||
return model.get('title');
|
var result = model.get('title'),
|
||||||
|
cat = model.get('category');
|
||||||
|
|
||||||
|
if (cat && !cat.get('isUncategorized')) {
|
||||||
|
var catName = cat.get('name'),
|
||||||
|
parentCategory = cat.get('parentCategory');
|
||||||
|
|
||||||
|
if (parentCategory) {
|
||||||
|
catName = parentCategory.get('name') + " / " + catName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [result, catName];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue