This is an automated email from the ASF dual-hosted git repository. amaranhao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push: new 2154639 Updates page title to match current route (#1108) 2154639 is described below commit 2154639ff0ae8f2868f279cab55c59d178018302 Author: Antonio Maranhao <30349380+antonio-maran...@users.noreply.github.com> AuthorDate: Sun Jul 22 21:51:48 2018 -0400 Updates page title to match current route (#1108) --- app/core/router.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/core/router.js b/app/core/router.js index 3ce3e7e..507c5d7 100644 --- a/app/core/router.js +++ b/app/core/router.js @@ -18,6 +18,7 @@ var beforeUnloads = {}; export default Backbone.Router.extend({ routes: {}, + originalPageTitle: window.document.title, beforeUnload: function (name, fn) { beforeUnloads[name] = fn; @@ -44,6 +45,17 @@ export default Backbone.Router.extend({ if (continueNav) { Backbone.Router.prototype.navigate(fragment, options); + this.updateWindowTitle(fragment); + } + }, + + updateWindowTitle: function(fragment) { + if (fragment.startsWith('#/')) { + window.document.title = this.originalPageTitle + ' - ' + fragment.substring(2); + } else if (fragment.startsWith('/') || fragment.startsWith('#')) { + window.document.title = this.originalPageTitle + ' - ' + fragment.substring(1); + } else { + window.document.title = this.originalPageTitle + ' - ' + fragment; } },