Set document.title on every page

This commit is contained in:
Toby Zerner 2015-05-18 14:28:15 +09:30
parent 39dd2f9b9b
commit d7facbd90a
6 changed files with 15 additions and 3 deletions

View File

@ -9,7 +9,6 @@ export default class ActivityPage extends UserPage {
constructor(props) {
super(props);
this.user = m.prop();
this.loading = m.prop(true);
this.moreResults = m.prop(false);
this.activity = m.prop([]);
@ -30,7 +29,7 @@ export default class ActivityPage extends UserPage {
setupUser(user) {
m.startComputation();
this.user(user);
super.setupUser(user);
m.endComputation();
this.refresh();

View File

@ -91,6 +91,8 @@ export default class DiscussionPage extends Component {
// }
this.streamContent.goToNumber(this.currentNear, true);
app.setTitle(discussion.title());
}
onload(element, isInitialized, context) {

View File

@ -142,6 +142,8 @@ export default class IndexPage extends Component {
}
}
}
app.setTitle('');
}
newDiscussion() {

View File

@ -14,7 +14,8 @@ export default class SettingsPage extends UserPage {
constructor(props) {
super(props);
this.user = app.session.user;
this.setupUser(app.session.user());
app.setTitle('Settings');
}
content() {

View File

@ -21,6 +21,8 @@ export default class UserPage extends Component {
constructor(props) {
super(props);
this.user = m.prop();
app.history.push('user');
app.current = this;
}
@ -30,6 +32,8 @@ export default class UserPage extends Component {
*/
setupUser(user) {
this.user(user);
app.setTitle(user.username());
}
onload(element, isInitialized, context) {

View File

@ -10,6 +10,10 @@ class App {
this.initializers.toArray().forEach((initializer) => initializer(this));
}
setTitle(title) {
document.title = (title ? title+' - ' : '')+this.config['forum_title'];
}
route(name, params) {
var url = this.routes[name][0].replace(/:([^\/]+)/g, function(m, t) {
var value = params[t];