From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mailnews/base/content/newFolderDialog.js | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 comm/mailnews/base/content/newFolderDialog.js (limited to 'comm/mailnews/base/content/newFolderDialog.js') diff --git a/comm/mailnews/base/content/newFolderDialog.js b/comm/mailnews/base/content/newFolderDialog.js new file mode 100644 index 0000000000..2476f198b0 --- /dev/null +++ b/comm/mailnews/base/content/newFolderDialog.js @@ -0,0 +1,82 @@ +/* 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 FOLDERS = 1; +var MESSAGES = 2; +var dialog; + +window.addEventListener("DOMContentLoaded", onLoad); +document.addEventListener("dialogaccept", onOK); + +function onLoad() { + var windowArgs = window.arguments[0]; + + dialog = {}; + + dialog.nameField = document.getElementById("name"); + dialog.nameField.focus(); + + // call this when OK is pressed + dialog.okCallback = windowArgs.okCallback; + + // pre select the folderPicker, based on what they selected in the folder pane + dialog.folder = windowArgs.folder; + try { + document + .getElementById("MsgNewFolderPopup") + .selectFolder(windowArgs.folder); + } catch (ex) { + // selected a child folder + document + .getElementById("msgNewFolderPicker") + .setAttribute("label", windowArgs.folder.prettyName); + } + + // can folders contain both folders and messages? + if (windowArgs.dualUseFolders) { + dialog.folderType = FOLDERS | MESSAGES; + + // hide the section when folder contain both folders and messages. + var newFolderTypeBox = document.getElementById("newFolderTypeBox"); + newFolderTypeBox.setAttribute("hidden", "true"); + } else { + // set our folder type by calling the default selected type's oncommand + document.getElementById("folderGroup").selectedItem.doCommand(); + } + + doEnabling(); +} + +function onFolderSelect(event) { + dialog.folder = event.target._folder; + document + .getElementById("msgNewFolderPicker") + .setAttribute("label", dialog.folder.prettyName); +} + +function onOK() { + var name = dialog.nameField.value; + + // do name validity check? + + // make sure name ends in "/" if folder to create can only contain folders + if (dialog.folderType == FOLDERS && !name.endsWith("/")) { + dialog.okCallback(name + "/", dialog.folder); + } else { + dialog.okCallback(name, dialog.folder); + } +} + +function onFoldersOnly() { + dialog.folderType = FOLDERS; +} + +function onMessagesOnly() { + dialog.folderType = MESSAGES; +} + +function doEnabling() { + document.querySelector("dialog").getButton("accept").disabled = + !dialog.nameField.value; +} -- cgit v1.2.3