From 2a39ec165dd1cea9032463c540d6f4da87492c48 Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 13 Jul 2016 21:50:07 +0200 Subject: [PATCH] client/general: add title to every page --- client/js/controllers/auth_controller.js | 1 + client/js/controllers/comments_controller.js | 1 + client/js/controllers/help_controller.js | 1 + client/js/controllers/history_controller.js | 1 + client/js/controllers/home_controller.js | 1 + client/js/controllers/not_found_controller.js | 1 + client/js/controllers/password_reset_controller.js | 1 + client/js/controllers/post_controller.js | 1 + client/js/controllers/post_list_controller.js | 1 + client/js/controllers/post_upload_controller.js | 1 + client/js/controllers/settings_controller.js | 1 + client/js/controllers/tag_categories_controller.js | 1 + client/js/controllers/tag_controller.js | 1 + client/js/controllers/tag_list_controller.js | 1 + client/js/controllers/user_controller.js | 1 + client/js/controllers/user_list_controller.js | 1 + client/js/controllers/user_registration_controller.js | 1 + client/js/models/top_navigation.js | 5 +++++ 18 files changed, 22 insertions(+) diff --git a/client/js/controllers/auth_controller.js b/client/js/controllers/auth_controller.js index baae595c..e2fe4c9e 100644 --- a/client/js/controllers/auth_controller.js +++ b/client/js/controllers/auth_controller.js @@ -9,6 +9,7 @@ class LoginController { constructor() { api.forget(); topNavigation.activate('login'); + topNavigation.setTitle('Login'); this._loginView = new LoginView(); this._loginView.addEventListener('submit', e => this._evtLogin(e)); diff --git a/client/js/controllers/comments_controller.js b/client/js/controllers/comments_controller.js index 7fa490ef..a1405992 100644 --- a/client/js/controllers/comments_controller.js +++ b/client/js/controllers/comments_controller.js @@ -12,6 +12,7 @@ const fields = ['id', 'comments', 'commentCount', 'thumbnailUrl']; class CommentsController { constructor(ctx) { topNavigation.activate('comments'); + topNavigation.setTitle('Listing comments'); this._pageController = new PageController({ parameters: ctx.parameters, diff --git a/client/js/controllers/help_controller.js b/client/js/controllers/help_controller.js index 4c42d0b4..2010176d 100644 --- a/client/js/controllers/help_controller.js +++ b/client/js/controllers/help_controller.js @@ -6,6 +6,7 @@ const HelpView = require('../views/help_view.js'); class HelpController { constructor(section, subsection) { topNavigation.activate('help'); + topNavigation.setTitle('Help'); this._helpView = new HelpView(section, subsection); } } diff --git a/client/js/controllers/history_controller.js b/client/js/controllers/history_controller.js index f09e0b6f..05c7c918 100644 --- a/client/js/controllers/history_controller.js +++ b/client/js/controllers/history_controller.js @@ -5,6 +5,7 @@ const topNavigation = require('../models/top_navigation.js'); class HistoryController { constructor() { topNavigation.activate(''); + topNavigation.setTitle('History'); } } diff --git a/client/js/controllers/home_controller.js b/client/js/controllers/home_controller.js index 02e022e8..4def183b 100644 --- a/client/js/controllers/home_controller.js +++ b/client/js/controllers/home_controller.js @@ -9,6 +9,7 @@ const HomeView = require('../views/home_view.js'); class HomeController { constructor() { topNavigation.activate('home'); + topNavigation.setTitle('Home'); this._homeView = new HomeView({ name: config.name, diff --git a/client/js/controllers/not_found_controller.js b/client/js/controllers/not_found_controller.js index 1a8ae34f..1d54b219 100644 --- a/client/js/controllers/not_found_controller.js +++ b/client/js/controllers/not_found_controller.js @@ -6,6 +6,7 @@ const NotFoundView = require('../views/not_found_view.js'); class NotFoundController { constructor(path) { topNavigation.activate(''); + topNavigation.setTitle('Not found'); this._notFoundView = new NotFoundView(path); } }; diff --git a/client/js/controllers/password_reset_controller.js b/client/js/controllers/password_reset_controller.js index f291bd4e..b4861046 100644 --- a/client/js/controllers/password_reset_controller.js +++ b/client/js/controllers/password_reset_controller.js @@ -8,6 +8,7 @@ const PasswordResetView = require('../views/password_reset_view.js'); class PasswordResetController { constructor() { topNavigation.activate('login'); + topNavigation.setTitle('Password reminder'); this._passwordResetView = new PasswordResetView(); this._passwordResetView.addEventListener( diff --git a/client/js/controllers/post_controller.js b/client/js/controllers/post_controller.js index a9683f22..896377ef 100644 --- a/client/js/controllers/post_controller.js +++ b/client/js/controllers/post_controller.js @@ -14,6 +14,7 @@ const EmptyView = require('../views/empty_view.js'); class PostController { constructor(id, editMode, ctx) { topNavigation.activate('posts'); + topNavigation.setTitle('Post #' + id.toString()); let parameters = ctx.parameters; Promise.all([ diff --git a/client/js/controllers/post_list_controller.js b/client/js/controllers/post_list_controller.js index 8219520c..974c6b26 100644 --- a/client/js/controllers/post_list_controller.js +++ b/client/js/controllers/post_list_controller.js @@ -16,6 +16,7 @@ const fields = [ class PostListController { constructor(ctx) { topNavigation.activate('posts'); + topNavigation.setTitle('Listing posts'); this._ctx = ctx; this._pageController = new PageController({ diff --git a/client/js/controllers/post_upload_controller.js b/client/js/controllers/post_upload_controller.js index beb8ec61..82f3b490 100644 --- a/client/js/controllers/post_upload_controller.js +++ b/client/js/controllers/post_upload_controller.js @@ -6,6 +6,7 @@ const EmptyView = require('../views/empty_view.js'); class PostUploadController { constructor() { topNavigation.activate('upload'); + topNavigation.setTitle('Upload'); this._emptyView = new EmptyView(); } } diff --git a/client/js/controllers/settings_controller.js b/client/js/controllers/settings_controller.js index e7bba6eb..237ad52f 100644 --- a/client/js/controllers/settings_controller.js +++ b/client/js/controllers/settings_controller.js @@ -7,6 +7,7 @@ const SettingsView = require('../views/settings_view.js'); class SettingsController { constructor() { topNavigation.activate('settings'); + topNavigation.setTitle('Browsing settings'); this._view = new SettingsView({ settings: settings.get(), }); diff --git a/client/js/controllers/tag_categories_controller.js b/client/js/controllers/tag_categories_controller.js index f676eb40..f7b86558 100644 --- a/client/js/controllers/tag_categories_controller.js +++ b/client/js/controllers/tag_categories_controller.js @@ -10,6 +10,7 @@ const EmptyView = require('../views/empty_view.js'); class TagCategoriesController { constructor() { topNavigation.activate('tags'); + topNavigation.setTitle('Listing tags'); TagCategoryList.get().then(response => { this._tagCategories = response.results; this._view = new TagCategoriesView({ diff --git a/client/js/controllers/tag_controller.js b/client/js/controllers/tag_controller.js index 9d46744c..0f8dfae5 100644 --- a/client/js/controllers/tag_controller.js +++ b/client/js/controllers/tag_controller.js @@ -12,6 +12,7 @@ class TagController { constructor(ctx, section) { Tag.get(ctx.parameters.name).then(tag => { topNavigation.activate('tags'); + topNavigation.setTitle('Tag #' + tag); this._name = ctx.parameters.name; tag.addEventListener('change', e => this._evtSaved(e)); diff --git a/client/js/controllers/tag_list_controller.js b/client/js/controllers/tag_list_controller.js index f0597715..823469f7 100644 --- a/client/js/controllers/tag_list_controller.js +++ b/client/js/controllers/tag_list_controller.js @@ -14,6 +14,7 @@ const fields = [ class TagListController { constructor(ctx) { topNavigation.activate('tags'); + topNavigation.setTitle('Listing tags'); this._pageController = new PageController({ parameters: ctx.parameters, diff --git a/client/js/controllers/user_controller.js b/client/js/controllers/user_controller.js index e068bfdd..aa12a988 100644 --- a/client/js/controllers/user_controller.js +++ b/client/js/controllers/user_controller.js @@ -11,6 +11,7 @@ const EmptyView = require('../views/empty_view.js'); class UserController { constructor(ctx, section) { + topNavigation.setTitle('User ' + ctx.parameters.name); User.get(ctx.parameters.name).then(user => { const isLoggedIn = api.isLoggedIn(user); const infix = isLoggedIn ? 'self' : 'any'; diff --git a/client/js/controllers/user_list_controller.js b/client/js/controllers/user_list_controller.js index 31d0e72f..0df1eae8 100644 --- a/client/js/controllers/user_list_controller.js +++ b/client/js/controllers/user_list_controller.js @@ -11,6 +11,7 @@ const UsersPageView = require('../views/users_page_view.js'); class UserListController { constructor(ctx) { topNavigation.activate('users'); + topNavigation.setTitle('Listing users'); this._pageController = new PageController({ parameters: ctx.parameters, diff --git a/client/js/controllers/user_registration_controller.js b/client/js/controllers/user_registration_controller.js index db61efb5..a456bb7c 100644 --- a/client/js/controllers/user_registration_controller.js +++ b/client/js/controllers/user_registration_controller.js @@ -9,6 +9,7 @@ const RegistrationView = require('../views/registration_view.js'); class UserRegistrationController { constructor() { topNavigation.activate('register'); + topNavigation.setTitle('Registration'); this._view = new RegistrationView(); this._view.addEventListener('submit', e => this._evtRegister(e)); } diff --git a/client/js/models/top_navigation.js b/client/js/models/top_navigation.js index 73a2ccf7..5b93d994 100644 --- a/client/js/models/top_navigation.js +++ b/client/js/models/top_navigation.js @@ -1,5 +1,6 @@ 'use strict'; +const config = require('../config.js'); const events = require('../events.js'); class TopNavigationItem { @@ -51,6 +52,10 @@ class TopNavigation extends events.EventTarget { })); } + setTitle(title) { + document.title = config.name + (title ? (' – ' + title) : ''); + } + showAll() { for (let item of this._items) { item.available = true;