17261
|
1 |
diff -r 77f7d8c11ea7 mail/base/content/mailCore.js
|
|
2 |
--- a/mail/base/content/mailCore.js Tue Dec 29 05:27:57 2009 +0100
|
|
3 |
+++ b/mail/base/content/mailCore.js Thu Dec 31 13:07:59 2009 +0800
|
|
4 |
@@ -137,16 +137,85 @@ function CustomizeMailToolbar(toolboxId,
|
|
5 |
wintype = wintype.replace(/:/g, "");
|
|
6 |
|
|
7 |
window.openDialog(customizeURL,
|
|
8 |
"CustomizeToolbar"+wintype,
|
|
9 |
"chrome,all,dependent", toolbox);
|
|
10 |
}
|
|
11 |
}
|
|
12 |
|
|
13 |
+var MailToolbarObserver = {
|
|
14 |
+ observe: function(subject,topic,data) {
|
|
15 |
+ if ( topic != "mail:updateToolbarItems")
|
|
16 |
+ return;
|
|
17 |
+
|
|
18 |
+ var current_toolbarset_ids,original_toolbarset_ids,item;
|
|
19 |
+
|
|
20 |
+ current_toolbarset_ids = this.toolbar.currentSet.split(",");
|
|
21 |
+ original_toolbarset_ids= this.original_toolbarset.split(",");
|
|
22 |
+
|
|
23 |
+
|
|
24 |
+ // Only need to update new toolbar items
|
|
25 |
+ for ( var i = 0; i< current_toolbarset_ids.length; i++)
|
|
26 |
+ {
|
|
27 |
+ for (var j = 0; j < original_toolbarset_ids.length; j++)
|
|
28 |
+ if (current_toolbarset_ids[i] == original_toolbarset_ids[j])
|
|
29 |
+ break;
|
|
30 |
+
|
|
31 |
+ if ( j != original_toolbarset_ids.length)
|
|
32 |
+ continue;
|
|
33 |
+
|
|
34 |
+ // item is a toolbar item just added
|
|
35 |
+ item = document.getElementById(current_toolbarset_ids[i]);
|
|
36 |
+ SyncWithObservers(item);
|
|
37 |
+ }
|
|
38 |
+
|
|
39 |
+ //Unregist
|
|
40 |
+ var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
|
41 |
+ .getService(Components.interfaces.nsIObserverService);
|
|
42 |
+ observerService.removeObserver(this, "mail:updateToolbarItems" );
|
|
43 |
+ }
|
|
44 |
+}
|
|
45 |
+
|
|
46 |
+//if the root has an "observe" attribute,
|
|
47 |
+// its "disabled" attribute should be synced with the observed element.
|
|
48 |
+function SyncWithObservers(root)
|
|
49 |
+{
|
|
50 |
+ var observed_item_id, observed_item;
|
|
51 |
+ var children,disabled;
|
|
52 |
+
|
|
53 |
+ if (!root)
|
|
54 |
+ return;
|
|
55 |
+
|
|
56 |
+ observed_item_id = root.observes;
|
|
57 |
+ if (observed_item_id)
|
|
58 |
+ {
|
|
59 |
+ observed_item = document.getElementById(observed_item_id);
|
|
60 |
+ disabled = observed_item.getAttribute("disabled");
|
|
61 |
+ if (disabled)
|
|
62 |
+ root.disabled = true;
|
|
63 |
+ else
|
|
64 |
+ root.disabled = false;
|
|
65 |
+ }
|
|
66 |
+
|
|
67 |
+ children = root.childNodes;
|
|
68 |
+ for ( var i = 0; i < children.length; i++)
|
|
69 |
+ SyncWithObservers(children[i]);
|
|
70 |
+}
|
|
71 |
+
|
|
72 |
+function MailToolboxCustomizeInitialized(aEvent)
|
|
73 |
+{
|
|
74 |
+ var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
|
75 |
+ .getService(Components.interfaces.nsIObserverService);
|
|
76 |
+ observerService.addObserver(MailToolbarObserver, "mail:updateToolbarItems", false);
|
|
77 |
+
|
|
78 |
+ MailToolbarObserver.toolbar = document.getElementById("mail-bar3");
|
|
79 |
+ MailToolbarObserver.original_toolbarset = MailToolbarObserver.toolbar.currentSet;
|
|
80 |
+}
|
|
81 |
+
|
|
82 |
function MailToolboxCustomizeDone(aEvent, customizePopupId)
|
|
83 |
{
|
|
84 |
if (gCustomizeSheet) {
|
|
85 |
document.getElementById("customizeToolbarSheetIFrame").hidden = true;
|
|
86 |
document.getElementById("customizeToolbarSheetPopup").hidePopup();
|
|
87 |
}
|
|
88 |
|
|
89 |
// Update global UI elements that may have been added or removed
|
|
90 |
diff -r 77f7d8c11ea7 mail/base/content/msgMail3PaneWindow.js
|
|
91 |
--- a/mail/base/content/msgMail3PaneWindow.js Tue Dec 29 05:27:57 2009 +0100
|
|
92 |
+++ b/mail/base/content/msgMail3PaneWindow.js Thu Dec 31 13:07:59 2009 +0800
|
|
93 |
@@ -395,16 +395,17 @@ function LoadPostAccountWizard()
|
|
94 |
OnLoadMsgHeaderPane();
|
|
95 |
|
|
96 |
//Set focus to the Thread Pane the first time the window is opened.
|
|
97 |
SetFocusThreadPane();
|
|
98 |
|
|
99 |
// initialize the customizeDone method on the customizeable toolbar
|
|
100 |
var toolbox = document.getElementById("mail-toolbox");
|
|
101 |
toolbox.customizeDone = function(aEvent) { MailToolboxCustomizeDone(aEvent, "CustomizeMailToolbar"); };
|
|
102 |
+ toolbox.customizeInitialized = function(aEvent) { MailToolboxCustomizeInitialized(aEvent); };
|
|
103 |
|
|
104 |
var toolbarset = document.getElementById('customToolbars');
|
|
105 |
toolbox.toolbarset = toolbarset;
|
|
106 |
|
|
107 |
// XXX Do not select the folder until the window displays or the threadpane
|
|
108 |
// will be at minimum size. We used to have
|
|
109 |
// gFolderDisplay.ensureRowIsVisible use settimeout itself to defer that
|
|
110 |
// calculation, but that was ugly. Also, in theory we will open the window
|