summaryrefslogtreecommitdiffstats
path: root/comm/suite/mailnews/content/msgFolderPickerOverlay.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /comm/suite/mailnews/content/msgFolderPickerOverlay.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/suite/mailnews/content/msgFolderPickerOverlay.js')
-rw-r--r--comm/suite/mailnews/content/msgFolderPickerOverlay.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/comm/suite/mailnews/content/msgFolderPickerOverlay.js b/comm/suite/mailnews/content/msgFolderPickerOverlay.js
new file mode 100644
index 0000000000..b097cd553e
--- /dev/null
+++ b/comm/suite/mailnews/content/msgFolderPickerOverlay.js
@@ -0,0 +1,100 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
+
+var gMessengerBundle;
+
+// call this from dialog onload() to set the menu item to the correct value
+function MsgFolderPickerOnLoad(pickerID) {
+ var uri = null;
+ try {
+ uri = window.arguments[0].preselectedURI;
+ } catch (ex) {
+ uri = null;
+ }
+
+ if (uri) {
+ // dump("on loading, set titled button to " + uri + "\n");
+
+ // verify that the value we are attempting to
+ // pre-flight the menu with is valid for this
+ // picker type
+ var msgfolder = MailUtils.getExistingFolder(uri);
+ if (!msgfolder) {
+ return;
+ }
+
+ var verifyFunction = null;
+
+ switch (pickerID) {
+ case "msgNewFolderPicker":
+ verifyFunction = msgfolder.canCreateSubfolders;
+ break;
+ case "msgRenameFolderPicker":
+ verifyFunction = msgfolder.canRename;
+ break;
+ default:
+ verifyFunction = msgfolder.canFileMessages;
+ break;
+ }
+
+ if (verifyFunction) {
+ SetFolderPicker(uri, pickerID);
+ }
+ }
+}
+
+function PickedMsgFolder(selection, pickerID) {
+ var selectedUri = selection.getAttribute("id");
+ SetFolderPicker(selectedUri, pickerID);
+}
+
+function SetFolderPickerElement(uri, picker) {
+ var msgfolder = MailUtils.getExistingFolder(uri);
+
+ if (!msgfolder) {
+ return;
+ }
+
+ var selectedValue = null;
+ var serverName;
+
+ if (msgfolder.isServer) {
+ selectedValue = msgfolder.name;
+ } else {
+ if (msgfolder.server) {
+ serverName = msgfolder.server.prettyName;
+ } else {
+ dump("Can't find server for " + uri + "\n");
+ serverName = "???";
+ }
+
+ switch (picker.id) {
+ case "runFiltersFolder":
+ selectedValue = msgfolder.name;
+ break;
+ case "msgTrashFolderPicker":
+ selectedValue = msgfolder.name;
+ break;
+ default:
+ if (!gMessengerBundle) {
+ gMessengerBundle = document.getElementById("bundle_messenger");
+ }
+ selectedValue = gMessengerBundle.getFormattedString(
+ "verboseFolderFormat",
+ [msgfolder.name, serverName]
+ );
+ break;
+ }
+ }
+
+ picker.setAttribute("label", selectedValue);
+ picker.setAttribute("uri", uri);
+}
+
+function SetFolderPicker(uri, pickerID) {
+ SetFolderPickerElement(uri, document.getElementById(pickerID));
+}