]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/view_mail.js
Fixing the parameters sent to the mail composer.
[citadel.git] / webcit-ng / static / js / view_mail.js
index 830768a50476e3b83124a27f667fbee52ed818c0..d5673193a4e86fab587fdae351ba98e42f8ab4c7 100644 (file)
@@ -137,6 +137,9 @@ function mail_render_one(msgnum, msg, target_div, include_controls) {
                ;
 
                if (include_controls) {                                         // omit controls if this is a pull quote
+
+                       let subject     = msg.subj              ? escapeJS(msg.subj)            : "" ;
+
                        outmsg +=
                          render_userpic(msg.from)                              // user avatar
                        + "<div class=\"ctdl-mmsg-content\">"                   // begin content
@@ -156,9 +159,15 @@ function mail_render_one(msgnum, msg, target_div, include_controls) {
                        + "</a></span>"
                
                        + "<span class=\"ctdl-msg-button\">"                    // Reply-All (mail is always Quoted)
-                       + "<a href=\"javascript:mail_compose(true,'"+msg.wefw+"','"+msgnum+"', replyall_to(msg), msg.cccc, 'Re: '+msg.subj);\">"
+                       + `<a href="javascript:mail_compose(true, msg.wefw, ${msgnum}, replyall_to(msg), msg.cccc, 'Re: ${subject}');">`
                        + "<i class=\"fa fa-reply-all\"></i> " 
                        + _("ReplyAll")
+                       + "</a></span>"
+               
+                       + "<span class=\"ctdl-msg-button\">"                    // Forward (server handles this)
+                       + "<a href=\"javascript:mail_compose(true,'"+msg.wefw+"','"+msgnum+"', '', '', 'Fwd: '+msg.subj);\">"
+                       + "<i class=\"fa fa-mail-forward\"></i> " 
+                       + _("Forward")
                        + "</a></span>";
                
                        if (can_delete_messages) {
@@ -430,9 +439,21 @@ function render_mailbox_display(notify) {
 
 
 // Compose a new mail message (called by the Reply button here, or by the dispatcher in views.js)
+//
+// is_quoted           true or false depending on whether the user selected "reply quoted" (is this appropriate for mail?)
+// references          list of references, be sure to use this in a reply
+// quoted_msgnum       if a reply, the msgid of the most recent message in the chain, the one to which we are replying
+// m_to                        an ARRAY of zero or more recipients to pre-insert into the To: field
+// m_cc                        an ARRAY of zero or more recipients to pre-insert into the Cc: field
+// m_subject           a string to pre-insert into the Subject: field
+//
 function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subject) {
+
+       let is_reply = 0;
+
        // m_to will be an array of zero or more recipients for the To: field.  Convert it to a string.
        if (m_to) {
+               is_reply = 1;
                m_to = Array.from(new Set(m_to));       // remove dupes
                m_to_str = "";
                for (i=0; i<m_to.length; ++i) {
@@ -448,6 +469,7 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
 
        // m_to will be an array of zero or more recipients for the Cc: field.  Convert it to a string.
        if (m_cc) {
+               is_reply = 1;
                m_cc = Array.from(new Set(m_cc));       // remove dupes
                m_cc_str = "";
                for (i=0; i<m_cc.length; ++i) {
@@ -466,10 +488,6 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
        // Make the "Write mail" button disappear.  We're already there!
        document.getElementById("ctdl-newmsg-button").style.display = "none";
 
-       // is_quoted    true or false depending on whether the user selected "reply quoted" (is this appropriate for mail?)
-       // references   list of references, be sure to use this in a reply
-       // msgid        if a reply, the msgid of the most recent message in the chain, the one to which we are replying
-
        // Now display the screen.  (Yes, I combined regular strings + template literals.  I just learned template literals.  Converting to all template literals would be fine.)
        compose_screen =
                // Hidden values that we are storing right here in the document tree for later
@@ -534,12 +552,22 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                document.getElementById(quoted_div_name).innerHTML = quoted_msgnum;
                mail_display_message(quoted_msgnum, document.getElementById(quoted_div_name), 0);
        }
+
+       if (is_reply) {
+               setTimeout(() => { document.getElementById("ctdl-editor-body").focus(); }, 0);
+       }
+       else {
+               setTimeout(() => { document.getElementById("ctdl-compose-to-field").focus(); }, 0);
+       }
+
 }
 
 // Called when the user clicks the button to make the hidden "CC" and "BCC" lines appear.
 // It is also called automatically during a Reply when CC is pre-populated.
 function make_cc_bcc_visible() {
        document.getElementById("ctdl-cc-bcc-buttons").style.display = "none";
+       document.getElementById("ctdl-compose-cc-label").style.display = "block";
+       document.getElementById("ctdl-compose-cc-field").style.display = "block";
        document.getElementById("ctdl-compose-bcc-label").style.display = "block";
        document.getElementById("ctdl-compose-bcc-field").style.display = "block";
 }