!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 38 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
2
3 /*
4 * Core mail routines used by all of the major mail windows (address book, 3-pane, compose and stand alone message window).
5 * Routines to support custom toolbars in mail windows, opening up a new window of a particular type all live here.
6 * Before adding to this file, ask yourself, is this a JS routine that is going to be used by all of the main mail windows?
7 */
8
CustomizeMailToolbar
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
9 function CustomizeMailToolbar(id)
10 {
11 // Disable the toolbar context menu items
12 var menubar = document.getElementById("mail-menubar");
13 for (var i = 0; i < menubar.childNodes.length; ++i)
14 menubar.childNodes[i].setAttribute("disabled", true);
15
16 var customizePopup = document.getElementById("CustomizeMailToolbar");
17 customizePopup.setAttribute("disabled", "true");
18
19 var toolbox = document.getElementById(id);
20
21 var customizeURL = "chrome://global/content/customizeToolbar.xul";
22 //@line 59 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
23 var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
24 sheetFrame.hidden = false;
25
26 // The document might not have been loaded yet, if this is the first time.
27 // If it is already loaded, reload it so that the onload intialization code
28 // re-runs.
29 if (sheetFrame.getAttribute("src") == customizeURL)
30 sheetFrame.contentWindow.location.reload()
31 else
32 sheetFrame.setAttribute("src", customizeURL);
33
34 var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
35 document.getElementById("customizeToolbarSheetPopup")
36 .openPopup(toolbox, "after_start",
37 (window.innerWidth - sheetWidth) / 2, 0);
38 //@line 82 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
39 }
40
MailToolboxCustomizeDone
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
41 function MailToolboxCustomizeDone(aToolboxChanged)
42 {
43 //@line 87 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
44 document.getElementById("customizeToolbarSheetIFrame").hidden = true;
45 document.getElementById("customizeToolbarSheetPopup").hidePopup();
46 //@line 90 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
47
48 // Update global UI elements that may have been added or removed
49
50 // Re-enable parts of the UI we disabled during the dialog
51 var menubar = document.getElementById("mail-menubar");
52 for (var i = 0; i < menubar.childNodes.length; ++i)
53 menubar.childNodes[i].setAttribute("disabled", false);
54
55 // make sure the mail views search box is initialized
56 if (document.getElementById("mailviews-container"))
57 ViewPickerOnLoad();
58
59 // make sure the folder location picker is initialized
60 if (document.getElementById("folder-location-container"))
61 {
62 loadFolderViewForTree(gCurrentFolderView, document.getElementById('folderLocationPopup').tree);
63 UpdateFolderLocationPicker(gMsgFolderSelected);
64 }
65
66 gSearchInput = null;
67 if (document.getElementById("search-container"))
68 GetSearchInput();
69
70 var customizePopup = document.getElementById("CustomizeMailToolbar");
71 customizePopup.removeAttribute("disabled");
72
73 // make sure our toolbar buttons have the correct enabled state restored to them...
74 if (this.UpdateMailToolbar != undefined)
75 UpdateMailToolbar(focus);
76 }
77
onViewToolbarCommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
78 function onViewToolbarCommand(aToolbarId, aMenuItemId)
79 {
80 var toolbar = document.getElementById(aToolbarId);
81 var menuItem = document.getElementById(aMenuItemId);
82
83 if (!toolbar || !menuItem) return;
84
85 var toolbarCollapsed = toolbar.collapsed;
86
87 // toggle the checkbox
88 menuItem.setAttribute('checked', toolbarCollapsed);
89
90 // toggle visibility of the toolbar
91 toolbar.collapsed = !toolbarCollapsed;
92
93 document.persist(aToolbarId, 'collapsed');
94 document.persist(aMenuItemId, 'checked');
95 }
96
toJavaScriptConsole
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
97 function toJavaScriptConsole()
98 {
99 toOpenWindowByType("global:console", "chrome://global/content/console.xul");
100 }
101
102 const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
103
toOpenWindowByType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
104 function toOpenWindowByType( inType, uri )
105 {
106 var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
107
108 var windowManagerInterface = windowManager.QueryInterface(nsIWindowMediator);
109
110 var topWindow = windowManagerInterface.getMostRecentWindow( inType );
111
112 if ( topWindow )
113 topWindow.focus();
114 else
115 window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
116 }
117
toMessengerWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
118 function toMessengerWindow()
119 {
120 toOpenWindowByType("mail:3pane", "chrome://messenger/content/messenger.xul");
121 }
122
toAddressBook
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
123 function toAddressBook()
124 {
125 toOpenWindowByType("mail:addressbook", "chrome://messenger/content/addressbook/addressbook.xul");
126 }
127
toImport
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
128 function toImport()
129 {
130 window.openDialog("chrome://messenger/content/importDialog.xul","importDialog","chrome, modal, titlebar, centerscreen");
131 }
132
133 // aPaneID
openOptionsDialog
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
134 function openOptionsDialog(aPaneID, aTabID)
135 {
136 var prefsService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
137 var instantApply = prefsService.getBoolPref("browser.preferences.instantApply");
138 var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
139
140 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
141 .getService(Components.interfaces.nsIWindowMediator);
142
143 var win = wm.getMostRecentWindow("Mail:Preferences");
144 if (win)
145 {
146 win.focus();
147 if (aPaneID)
148 {
149 var pane = win.document.getElementById(aPaneID);
150 win.document.documentElement.showPane(pane);
151
152 // I don't know how to support aTabID for an arbitrary panel when the dialog is already open
153 // This is complicated because showPane is asynchronous (it could trigger a dynamic overlay)
154 // so our tab element may not be accessible right away...
155 }
156 }
157 else
158 openDialog("chrome://messenger/content/preferences/preferences.xul","Preferences", features, aPaneID, aTabID);
159 }
160
openAddonsMgr
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
161 function openAddonsMgr()
162 {
163 const EMTYPE = "Extension:Manager";
164 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
165 .getService(Components.interfaces.nsIWindowMediator);
166 var theEM = wm.getMostRecentWindow(EMTYPE);
167 if (theEM) {
168 theEM.focus();
169 return;
170 }
171
172 const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
173 const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
174 window.openDialog(EMURL, "", EMFEATURES);
175 }
176
SetBusyCursor
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
177 function SetBusyCursor(window, enable)
178 {
179 // setCursor() is only available for chrome windows.
180 // However one of our frames is the start page which
181 // is a non-chrome window, so check if this window has a
182 // setCursor method
183 if ("setCursor" in window) {
184 if (enable)
185 window.setCursor("wait");
186 else
187 window.setCursor("auto");
188 }
189
190 var numFrames = window.frames.length;
191 for(var i = 0; i < numFrames; i++)
192 SetBusyCursor(window.frames[i], enable);
193 }
194
openAboutDialog
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
195 function openAboutDialog()
196 {
197 //@line 241 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
198 var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
199 .getService(Components.interfaces.nsIWindowMediator);
200 var win = wm.getMostRecentWindow("Mail:About");
201 if (win) // If we have an open about dialog, just focus it.
202 win.focus();
203 else {
204 // Define minimizable=no although it does nothing on OS X
205 // (see Bug 287162); remove this comment once Bug 287162 is fixed...
206 window.open("chrome://messenger/content/aboutDialog.xul", "About",
207 "chrome, resizable=no, minimizable=no");
208 }
209 //@line 255 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/mail/base/content/mailCore.js"
210 }
211
212 /**
213 * Opens region specific web pages for the application like the release notes, the help site, etc.
214 * aResourceName --> the string resource ID in region.properties to load.
215 */
openRegionURL
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
216 function openRegionURL(aResourceName)
217 {
218 var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
219 .getService(Components.interfaces.nsIXULAppInfo);
220 try {
221 var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
222 var regionBundle = strBundleService.createBundle("chrome://messenger-region/locale/region.properties");
223 // the release notes are special and need to be formatted with the app version
224 var urlToOpen;
225 if (aResourceName == "releaseNotesURL")
226 urlToOpen = regionBundle.formatStringFromName(aResourceName, [appInfo.version], 1);
227 else
228 urlToOpen = regionBundle.GetStringFromName(aResourceName);
229
230 var uri = Components.classes["@mozilla.org/network/io-service;1"]
231 .getService(Components.interfaces.nsIIOService)
232 .newURI(urlToOpen, null, null);
233
234 var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
235 .getService(Components.interfaces.nsIExternalProtocolService);
236 protocolSvc.loadUrl(uri);
237 } catch (ex) {}
238 }
239
240 /**
241 * Fetches the url for the passed in pref name, formats it and then loads it in the default
242 * browser.
243 *
244 * @param aPrefName - name of the pref that holds the url we want to format and open
245 */
openFormattedURL
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
246 function openFormattedURL(aPrefName)
247 {
248 var formattedUrl = getFormattedURL(aPrefName);
249
250 var uri = Components.classes["@mozilla.org/network/io-service;1"].
251 getService(Components.interfaces.nsIIOService).
252 newURI(formattedUrl, null, null);
253
254 var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].
255 getService(Components.interfaces.nsIExternalProtocolService);
256 protocolSvc.loadUrl(uri);
257 }
258
259 /**
260 * Fetches the url for the passed in pref name and uses the URL formatter service to
261 * format it.
262 *
263 * @param aPrefName - name of the pref that holds the url we want to format and open
264 * @returns the formatted url string
265 */
getFormattedURL
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
266 function getFormattedURL(aPrefName)
267 {
268 var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
269 var format = prefBranch.getComplexValue(aPrefName, Components.interfaces.nsISupportsString).data;
270 var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"].
271 getService(Components.interfaces.nsIURLFormatter);
272 return formatter.formatURL(format);
273 }