Skip to content

Commit

Permalink
Bug 715557 - Refresh Thunderbird-specific code of titlebar customizat…
Browse files Browse the repository at this point in the history
…ion in NTT 3.x
  • Loading branch information
Szabolcs Hubai authored and harthur committed Jan 9, 2012
1 parent fb00974 commit e7caa50
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
74 changes: 38 additions & 36 deletions chrome/content/messenger.js
Expand Up @@ -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");
Expand All @@ -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)
Expand All @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions chrome/content/messengerOverlay.xul
Expand Up @@ -69,6 +69,7 @@
<menuitem id="nightly-pushlog" label="&nightly.pushlog.label;" oncommand="nightly.openPushlog();"/>
<menuseparator/>
<menuitem label="&nightly.screenshot.full.label;" oncommand="nightly.getScreenshot();"/>
<menuitem label="&nightly.customize.label;" oncommand="nightly.openCustomize();"/>
<menu id="nightly-crashme" label="&nightly.crashme.label;">
<menupopup id="nightly-crashme-popup">
<menuitem id="nightly.crashme-nullptr" label="&nightly.crashme.nullptr.label;"
Expand Down

0 comments on commit e7caa50

Please sign in to comment.