diff --git a/chrome/content/messenger.js b/chrome/content/messenger.js index 537bd44..6eaf8a2 100644 --- a/chrome/content/messenger.js +++ b/chrome/content/messenger.js @@ -39,9 +39,20 @@ var nightlyApp = { repository: 'comm-central', -savedSetTitleFromFolder: window.setTitleFromFolder, +storedTitleModifier: document.documentElement.getAttribute("titlemodifier"), +storedTitleMenuSeparator: document.documentElement.getAttribute("titlemenuseparator"), + +savedTabmailSetDocumentTitle: null, +tabmailSetDocumentTitle: null, + +customTitleModifier: '', customTitle: '', +get defaultTitle() { + var tabmail = document.getElementById("tabmail"); + return tabmail.currentTabInfo.title + nightlyApp.storedTitleMenuSeparator + nightlyApp.storedTitleModifier; +}, + init: function() { var brandbundle = document.getElementById("bundle_brand"); @@ -51,6 +62,12 @@ init: function() } nightly.variables.defaulttitle=brandbundle.getString("brandShortName"); nightly.variables.brandname=brandbundle.getString("brandFullName"); + + var tabmail = document.getElementById("tabmail"); + if (tabmail && typeof(tabmail.setDocumentTitle) === "function") + { + nightlyApp.savedTabmailSetDocumentTitle=tabmail.setDocumentTitle; + } }, openURL: function(url, event) @@ -75,62 +92,47 @@ detectLeaks: function(event) window.openDialog("chrome://nightly/content/leaks/leaks.xul", "_blank", "chrome,all,dialog=no"); }, -customSetTitleFromFolder: function(msgfolder, subject) +customTabmailSetDocumentTitle: function(aTab) { - var brandbundle = document.getElementById("bundle_brand"); - var end = " - "+brandbundle.getString("brandShortName"); - nightlyApp.savedSetTitleFromFolder(msgfolder,subject); - - var title; - if ((document.title)&&(document.title.length>0)) - { - title = document.title; - } - else - { - title = window.title; - } - - if (title.substring(title.length-end.length)==end) - { - title=title.substring(0,title.length-end.length); - if (nightlyApp.customTitle && nightlyApp.customTitle.length>0) - title=title+' - '+nightlyApp.customTitle; - } - - if ((document.title)&&(document.title.length>0)) - { - document.title=title; - } - else - { - window.title=title; - } + + nightlyApp.customTitleModifier = nightlyApp.customTitle.substring( + nightlyApp.customTitle.indexOf(nightlyApp.storedTitleMenuSeparator) + + nightlyApp.storedTitleMenuSeparator.length + ); + document.documentElement.setAttribute("titlemodifier", nightlyApp.customTitleModifier); + + // to implement Bug 624394 - Version 3.1 loses ability to customize titlebar with just window title + // 1. remove this passthrough + // 2. override once tabmail's setDocumentTitle with nightly's tabmailSetDocumentTitle + // 3. and set the document.title here + nightlyApp.savedTabmailSetDocumentTitle(aTab); }, updateTitle: function() { - if (gDBView) - window.setTitleFromFolder(gDBView.msgFolder,null); + if (nightlyApp.savedTabmailSetDocumentTitle) { + nightlyApp.tabmailSetDocumentTitle(window.document.getElementById("tabmail").currentTabInfo); + } }, setCustomTitle: function(title) { nightlyApp.customTitle=title; - window.setTitleFromFolder=nightlyApp.customSetTitleFromFolder; + nightlyApp.tabmailSetDocumentTitle=nightlyApp.customTabmailSetDocumentTitle; nightlyApp.updateTitle(); }, setBlankTitle: function() { nightlyApp.customTitle=''; - window.setTitleFromFolder=nightlyApp.customSetTitleFromFolder; + nightlyApp.tabmailSetDocumentTitle=nightlyApp.customTabmailSetDocumentTitle; nightlyApp.updateTitle(); }, setStandardTitle: function() { - window.setTitleFromFolder=nightlyApp.savedSetTitleFromFolder; + nightlyApp.tabmailSetDocumentTitle=nightlyApp.savedTabmailSetDocumentTitle; + document.documentElement.setAttribute("titlemodifier", nightlyApp.storedTitleModifier); nightlyApp.updateTitle(); } diff --git a/chrome/content/messengerOverlay.xul b/chrome/content/messengerOverlay.xul index ba5979a..5064651 100644 --- a/chrome/content/messengerOverlay.xul +++ b/chrome/content/messengerOverlay.xul @@ -69,6 +69,7 @@ +