set document.title on router events

This commit is contained in:
Nils Schneider 2015-04-05 23:44:43 +02:00
commit 3b75f01ccd
2 changed files with 35 additions and 2 deletions

31
lib/title.js Normal file
View file

@ -0,0 +1,31 @@
define(function () {
return function (config) {
function setTitle(d) {
var title = [config.siteName]
if (d !== undefined)
title.push(d)
document.title = title.join(": ")
}
this.resetView = function () {
setTitle()
}
this.gotoNode = function (d) {
if (d)
setTitle(d.nodeinfo.hostname)
}
this.gotoLink = function (d) {
if (d)
setTitle(d.source.node.nodeinfo.hostname + " " + d.target.node.nodeinfo.hostname)
}
this.destroy = function () {
}
return this
}
})