You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/07/23 01:51:50 UTC

[GitHub] Antonio-Maranhao closed pull request #1108: Updates page title to match current route

Antonio-Maranhao closed pull request #1108: Updates page title to match current route
URL: https://github.com/apache/couchdb-fauxton/pull/1108
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/app/core/router.js b/app/core/router.js
index 3ce3e7ea4..507c5d71a 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;
     }
   },
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services