summaryrefslogtreecommitdiffstats
path: root/mailnews/compose/content
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
committerMatt A. Tobin <email@mattatobin.com>2019-11-03 00:17:46 -0400
commit302bf1b523012e11b60425d6eee1221ebc2724eb (patch)
treeb191a895f8716efcbe42f454f37597a545a6f421 /mailnews/compose/content
parent21b3f6247403c06f85e1f45d219f87549862198f (diff)
downloadUXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.gz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.lz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.xz
UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.zip
Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1
Diffstat (limited to 'mailnews/compose/content')
-rw-r--r--mailnews/compose/content/askSendFormat.js58
-rw-r--r--mailnews/compose/content/askSendFormat.xul46
-rw-r--r--mailnews/compose/content/mailComposeEditorOverlay.xul157
-rw-r--r--mailnews/compose/content/menulistCompactBindings.xml22
-rw-r--r--mailnews/compose/content/sendProgress.js171
-rw-r--r--mailnews/compose/content/sendProgress.xul50
6 files changed, 504 insertions, 0 deletions
diff --git a/mailnews/compose/content/askSendFormat.js b/mailnews/compose/content/askSendFormat.js
new file mode 100644
index 000000000..17f4bafe4
--- /dev/null
+++ b/mailnews/compose/content/askSendFormat.js
@@ -0,0 +1,58 @@
+/* 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 gParam = null;
+
+/**
+ * This dialog should be opened with arguments like e.g.
+ * {action: nsIMsgCompSendFormat.AskUser, convertible: nsIMsgCompConvertible.Yes}
+ */
+function Startup()
+{
+ gParam = window.arguments[0];
+
+ const msgCompSendFormat = Components.interfaces.nsIMsgCompSendFormat;
+ const msgCompConvertible = Components.interfaces.nsIMsgCompConvertible;
+
+ var bundle = document.getElementById("askSendFormatStringBundle");
+
+ // If the user hits the close box, we will abort.
+ gParam.abort = true;
+
+ // Set the question label
+ var mailSendFormatExplanation = document.getElementById("mailSendFormatExplanation");
+ var icon = document.getElementById("convertDefault");
+
+ switch (gParam.convertible)
+ {
+ case msgCompConvertible.Altering:
+ mailSendFormatExplanation.textContent = bundle.getString("convertibleAltering");
+ icon.className = "question-icon";
+ break;
+ case msgCompConvertible.No:
+ mailSendFormatExplanation.textContent = bundle.getString("convertibleNo");
+ icon.className = "alert-icon";
+ break;
+ default: // msgCompConvertible.Yes
+ mailSendFormatExplanation.textContent = bundle.getString("convertibleYes");
+ // XXX change this to use class message-icon once bug 512173 is fixed
+ icon.className = "question-icon";
+ break;
+ }
+
+ // Set the default radio array value and recommendation.
+ var group = document.getElementById("mailDefaultHTMLAction");
+ if (gParam.action != msgCompSendFormat.AskUser)
+ {
+ group.value = gParam.action;
+ group.selectedItem.label += " " + bundle.getString("recommended");
+ }
+}
+
+function Send()
+{
+ // gParam.action should be an integer for when it is returned to MsgComposeCommands.js
+ gParam.action = parseInt(document.getElementById("mailDefaultHTMLAction").value);
+ gParam.abort = false;
+}
diff --git a/mailnews/compose/content/askSendFormat.xul b/mailnews/compose/content/askSendFormat.xul
new file mode 100644
index 000000000..751378bd8
--- /dev/null
+++ b/mailnews/compose/content/askSendFormat.xul
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<!-- 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/. -->
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/askSendFormat.dtd">
+
+<dialog id="askSendFormat"
+ title="&windowTitle.label;"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ buttonpack="center"
+ onload="Startup();"
+ ondialogaccept="Send();"
+ buttonlabelaccept="&send.label;"
+ buttonaccesskeyaccept="&send.accesskey;"
+ style="width: 75ch;">
+
+ <script type="application/javascript"
+ src="chrome://messenger/content/messengercompose/askSendFormat.js"/>
+
+ <stringbundle id="askSendFormatStringBundle"
+ src="chrome://messenger/locale/messengercompose/askSendFormat.properties"/>
+
+ <separator class="thin"/>
+ <hbox>
+ <separator orient="vertical"/>
+ <vbox id="askImageBox">
+ <image id="convertDefault"/>
+ </vbox>
+ <separator orient="vertical"/>
+ <vbox flex="1">
+ <description>&recipient.label;</description>
+ <description id="mailSendFormatExplanation"/>
+ <description>&question.label;</description>
+ <separator/>
+ <radiogroup id="mailDefaultHTMLAction">
+ <radio value="3" label="&plainTextAndHtml.label;" accesskey="&plainTextAndHtml.accesskey;"/>
+ <radio value="1" selected="true"
+ label="&plainTextOnly.label;" accesskey="&plainTextOnly.accesskey;"/>
+ <radio value="2" label="&htmlOnly.label;" accesskey="&htmlOnly.accesskey;"/>
+ </radiogroup>
+ </vbox>
+ </hbox>
+</dialog>
diff --git a/mailnews/compose/content/mailComposeEditorOverlay.xul b/mailnews/compose/content/mailComposeEditorOverlay.xul
new file mode 100644
index 000000000..4304935e1
--- /dev/null
+++ b/mailnews/compose/content/mailComposeEditorOverlay.xul
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<!-- 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/. -->
+
+<!DOCTYPE window SYSTEM "chrome://messenger/locale/messengercompose/mailComposeEditorOverlay.dtd" >
+
+<overlay id="mailComposeEditorOverlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/javascript">
+ <![CDATA[
+ Components.utils.import("resource://gre/modules/Services.jsm");
+
+ var gMsgCompProcessLink = false;
+ var gMsgCompInputElement = null;
+ var gMsgCompPrevInputValue = null;
+ var gMsgCompPrevMozDoNotSendAttribute;
+ var gMsgCompAttachSourceElement = null;
+
+ function OnLoadOverlay()
+ {
+ gMsgCompAttachSourceElement = document.getElementById("AttachSourceToMail");
+ var editor = GetCurrentEditor();
+ if (gMsgCompAttachSourceElement && editor &&
+ (editor.flags & Components.interfaces.nsIPlaintextEditor.eEditorMailMask))
+ {
+ SetRelativeCheckbox = function() { SetAttachCheckbox();};
+ //initialize the AttachSourceToMail checkbox
+ gMsgCompAttachSourceElement.hidden = false;
+
+ switch (document.documentElement.id)
+ {
+ case "imageDlg":
+ gMsgCompInputElement = gDialog.srcInput;
+ gMsgCompProcessLink = false;
+ break;
+ case "linkDlg" :
+ gMsgCompInputElement = gDialog.hrefInput;
+ gMsgCompProcessLink = true;
+ break;
+ }
+ if (gMsgCompInputElement)
+ {
+ SetAttachCheckbox();
+ gMsgCompPrevMozDoNotSendAttribute = globalElement.getAttribute("moz-do-not-send")
+ }
+ }
+ }
+ addEventListener("load", OnLoadOverlay, false);
+
+ function OnAcceptOverlay()
+ {
+ // Auto-convert file URLs to data URLs. If we're in the link properties
+ // dialog convert only when requested - for the image dialog do it always.
+ if (/^file:/i.test(gMsgCompInputElement.value.trim()) &&
+ (gMsgCompAttachSourceElement.checked || !gMsgCompProcessLink)) {
+ var dataURI = GenerateDataURL(gMsgCompInputElement.value.trim());
+ gMsgCompInputElement.value = dataURI;
+ gMsgCompAttachSourceElement.checked = true;
+ }
+ DoAttachSourceCheckbox();
+ }
+ addEventListener("dialogaccept", OnAcceptOverlay, false);
+
+ function SetAttachCheckbox()
+ {
+ var resetCheckbox = false;
+ var mozDoNotSend = globalElement.getAttribute("moz-do-not-send");
+
+ //In case somebody played with the advanced property and changed the moz-do-not-send attribute
+ if (mozDoNotSend != gMsgCompPrevMozDoNotSendAttribute)
+ {
+ gMsgCompPrevMozDoNotSendAttribute = mozDoNotSend;
+ resetCheckbox = true;
+ }
+
+ // Has the URL changed
+ if (gMsgCompInputElement && gMsgCompInputElement.value != gMsgCompPrevInputValue)
+ {
+ gMsgCompPrevInputValue = gMsgCompInputElement.value;
+ resetCheckbox = true;
+ }
+
+ if (gMsgCompInputElement && resetCheckbox)
+ {
+ // Here is the rule about how to set the checkbox Attach Source To Message:
+ // If the attribute "moz-do-not-send" has not been set, we look at the scheme of the URL
+ // and at some preference to decide what is the best for the user.
+ // If it is set to "false", the checkbox is checked, otherwise unchecked.
+ var attach = false;
+ if (mozDoNotSend == null)
+ {
+ // We haven't yet set the "moz-do-not-send" attribute.
+ var inputValue = gMsgCompInputElement.value.trim();
+ if (/^(file|data):/i.test(inputValue)) {
+ // For files or data URLs, default to attach them.
+ attach = true;
+ } else if (!gMsgCompProcessLink && // Implies image dialogue.
+ /^https?:/i.test(inputValue)) {
+ // For images loaded via http(s) we default to the preference value.
+ attach = Services.prefs.getBoolPref("mail.compose.attach_http_images");
+ }
+ }
+ else
+ {
+ attach = (mozDoNotSend == "false");
+ }
+
+ gMsgCompAttachSourceElement.checked = attach;
+ }
+ }
+
+ function DoAttachSourceCheckbox()
+ {
+ gMsgCompPrevMozDoNotSendAttribute = (!gMsgCompAttachSourceElement.checked).toString();
+ globalElement.setAttribute("moz-do-not-send", gMsgCompPrevMozDoNotSendAttribute);
+ }
+
+ function GenerateDataURL(url) {
+ var file = Services.io.newURI(url, null, null)
+ .QueryInterface(Components.interfaces.nsIFileURL).file;
+ var contentType = Components.classes["@mozilla.org/mime;1"]
+ .getService(Components.interfaces.nsIMIMEService)
+ .getTypeFromFile(file);
+ var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"]
+ .createInstance(Components.interfaces.nsIFileInputStream);
+ inputStream.init(file, 0x01, 0o600, 0);
+ var stream = Components.classes["@mozilla.org/binaryinputstream;1"]
+ .createInstance(Components.interfaces.nsIBinaryInputStream);
+ stream.setInputStream(inputStream);
+ let data = "";
+ while (stream.available() > 0) {
+ data += stream.readBytes(stream.available());
+ }
+ let encoded = btoa(data);
+ stream.close();
+ return "data:" + contentType +
+ ";filename=" + encodeURIComponent(file.leafName) +
+ ";base64," + encoded;
+ }
+ ]]>
+ </script>
+
+ <hbox id="MakeRelativeHbox">
+ <checkbox id="AttachSourceToMail" hidden="true"
+ label="&attachImageSource.label;" accesskey="&attachImageSource.accesskey;"
+ insertafter="MakeRelativeCheckbox" oncommand="DoAttachSourceCheckbox()"/>
+ </hbox>
+
+ <groupbox id="LinkURLBox">
+ <checkbox id="AttachSourceToMail" hidden="true"
+ label="&attachLinkSource.label;" accesskey="&attachLinkSource.accesskey;"
+ insertafter="LinkLocationBox" oncommand="DoAttachSourceCheckbox()"/>
+ </groupbox>
+
+</overlay>
diff --git a/mailnews/compose/content/menulistCompactBindings.xml b/mailnews/compose/content/menulistCompactBindings.xml
new file mode 100644
index 000000000..5ca277347
--- /dev/null
+++ b/mailnews/compose/content/menulistCompactBindings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!-- 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/. -->
+
+<bindings id="menulistCompactBindings"
+ xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:xbl="http://www.mozilla.org/xbl">
+
+ <binding id="menulist-compact" display="xul:menu"
+ extends="chrome://global/content/bindings/menulist.xml#menulist">
+ <content sizetopopup="false">
+ <xul:hbox class="menulist-label-box" flex="1">
+ <xul:image class="menulist-icon" xbl:inherits="src"/>
+ <xul:label class="menulist-label" xbl:inherits="value=label,crop,accesskey" crop="right" flex="1"/>
+ </xul:hbox>
+ <children includes="menupopup"/>
+ </content>
+ </binding>
+
+</bindings>
diff --git a/mailnews/compose/content/sendProgress.js b/mailnews/compose/content/sendProgress.js
new file mode 100644
index 000000000..8354cf953
--- /dev/null
+++ b/mailnews/compose/content/sendProgress.js
@@ -0,0 +1,171 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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 nsIMsgCompDeliverMode = Components.interfaces.nsIMsgCompDeliverMode;
+
+// dialog is just an array we'll use to store various properties from the dialog document...
+var dialog;
+
+// the msgProgress is a nsIMsgProgress object
+var msgProgress = null;
+
+// random global variables...
+var itsASaveOperation = false;
+var gSendProgressStringBundle;
+
+// all progress notifications are done through the nsIWebProgressListener implementation...
+var progressListener = {
+ onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus)
+ {
+ if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_START)
+ {
+ // Put progress meter in undetermined mode.
+ dialog.progress.setAttribute("mode", "undetermined");
+ }
+
+ if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
+ {
+ // we are done sending/saving the message...
+ // Indicate completion in status area.
+ var msg;
+ if (itsASaveOperation)
+ msg = gSendProgressStringBundle.getString("messageSaved");
+ else
+ msg = gSendProgressStringBundle.getString("messageSent");
+ dialog.status.setAttribute("value", msg);
+
+ // Put progress meter at 100%.
+ dialog.progress.setAttribute("value", 100);
+ dialog.progress.setAttribute("mode", "normal");
+ var percentMsg = gSendProgressStringBundle.getFormattedString("percentMsg", [100]);
+ dialog.progressText.setAttribute("value", percentMsg);
+
+ window.close();
+ }
+ },
+
+ onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
+ {
+ // Calculate percentage.
+ var percent;
+ if (aMaxTotalProgress > 0)
+ {
+ percent = Math.round(aCurTotalProgress / aMaxTotalProgress * 100);
+ if (percent > 100)
+ percent = 100;
+
+ dialog.progress.removeAttribute("mode");
+
+ // Advance progress meter.
+ dialog.progress.setAttribute("value", percent);
+
+ // Update percentage label on progress meter.
+ var percentMsg = gSendProgressStringBundle.getFormattedString("percentMsg", [percent]);
+ dialog.progressText.setAttribute("value", percentMsg);
+ }
+ else
+ {
+ // Progress meter should be barber-pole in this case.
+ dialog.progress.setAttribute("mode", "undetermined");
+ // Update percentage label on progress meter.
+ dialog.progressText.setAttribute("value", "");
+ }
+ },
+
+ onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags)
+ {
+ // we can ignore this notification
+ },
+
+ onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage)
+ {
+ if (aMessage != "")
+ dialog.status.setAttribute("value", aMessage);
+ },
+
+ onSecurityChange: function(aWebProgress, aRequest, state)
+ {
+ // we can ignore this notification
+ },
+
+ QueryInterface : function(iid)
+ {
+ if (iid.equals(Components.interfaces.nsIWebProgressListener) ||
+ iid.equals(Components.interfaces.nsISupportsWeakReference) ||
+ iid.equals(Components.interfaces.nsISupports))
+ return this;
+
+ throw Components.results.NS_NOINTERFACE;
+ }
+};
+
+function onLoad()
+{
+ // Set global variables.
+ let subject = "";
+ gSendProgressStringBundle = document.getElementById("sendProgressStringBundle");
+
+ msgProgress = window.arguments[0];
+ if (!msgProgress)
+ {
+ Components.utils.reportError("Invalid argument to sendProgress.xul.");
+ window.close();
+ return;
+ }
+
+ if (window.arguments[1])
+ {
+ let progressParams = window.arguments[1].QueryInterface(Components.interfaces.nsIMsgComposeProgressParams);
+ if (progressParams)
+ {
+ itsASaveOperation = (progressParams.deliveryMode != nsIMsgCompDeliverMode.Now);
+ subject = progressParams.subject;
+ }
+ }
+
+ if (subject) {
+ let title = itsASaveOperation ? "titleSaveMsgSubject" : "titleSendMsgSubject";
+ document.title = gSendProgressStringBundle.getFormattedString(title, [subject]);
+ } else {
+ let title = itsASaveOperation ? "titleSaveMsg" : "titleSendMsg";
+ document.title = gSendProgressStringBundle.getString(title);
+ }
+
+ dialog = {};
+ dialog.status = document.getElementById("dialog.status");
+ dialog.progress = document.getElementById("dialog.progress");
+ dialog.progressText = document.getElementById("dialog.progressText");
+
+ // set our web progress listener on the helper app launcher
+ msgProgress.registerListener(progressListener);
+}
+
+function onUnload()
+{
+ if (msgProgress)
+ {
+ try
+ {
+ msgProgress.unregisterListener(progressListener);
+ msgProgress = null;
+ } catch (e) {}
+ }
+}
+
+// If the user presses cancel, tell the app launcher and close the dialog...
+function onCancel()
+{
+ // Cancel app launcher.
+ try
+ {
+ msgProgress.processCanceledByUser = true;
+ } catch (e)
+ {
+ return true;
+ }
+
+ // don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted.
+ return false;
+}
diff --git a/mailnews/compose/content/sendProgress.xul b/mailnews/compose/content/sendProgress.xul
new file mode 100644
index 000000000..45508387f
--- /dev/null
+++ b/mailnews/compose/content/sendProgress.xul
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+
+<!-- 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/. -->
+
+<?xml-stylesheet href="chrome://messenger/skin/dialogs.css" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/sendProgress.dtd">
+
+<dialog id="sendProgress"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="&sendDialog.title;"
+ style="width: 56ch;"
+ onload="onLoad();"
+ onunload="onUnload();"
+ buttons="cancel"
+ ondialogcancel="return onCancel();">
+
+ <script type="application/javascript"
+ src="chrome://messenger/content/messengercompose/sendProgress.js"/>
+ <stringbundle id="sendProgressStringBundle"
+ src="chrome://messenger/locale/messengercompose/sendProgress.properties"/>
+
+ <grid flex="1">
+ <columns>
+ <column/>
+ <column flex="1"/>
+ </columns>
+
+ <rows>
+ <row>
+ <hbox pack="end">
+ <label value="&status.label;"/>
+ </hbox>
+ <label id="dialog.status" crop="center"/>
+ </row>
+ <row class="thin-separator">
+ <hbox pack="end">
+ <label value="&progress.label;"/>
+ </hbox>
+ <progressmeter id="dialog.progress" mode="normal" value="0"/>
+ <hbox pack="end">
+ <label id="dialog.progressText"/>
+ </hbox>
+ </row>
+ </rows>
+ </grid>
+
+</dialog>