]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/view_mail.js
"make cc/bcc visible" now makes BOTH visible.
[citadel.git] / webcit-ng / static / js / view_mail.js
index d058f470ecf35727d3820f4e455275e6c4c720d2..0e37bd0d9cd417f3636ea67a9cefefb2dff8da1c 100644 (file)
@@ -431,8 +431,12 @@ function render_mailbox_display(notify) {
 
 // Compose a new mail message (called by the Reply button here, or by the dispatcher in views.js)
 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 +452,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) {
@@ -502,8 +507,9 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                + "<div class=\"ctdl-compose-message-box\" id=\"ctdl-editor-body\" contenteditable=\"true\">"
        ;
 
+       // If this is a quoted reply, insert a div within which we will render the original message.
        if (is_quoted) {
-               compose_screen += "<br><br><blockquote><div id=\"" + quoted_div_name + "\"></div></blockquote>";
+               compose_screen += "<br><br><blockquote><div id=\"" + quoted_div_name + "\">QUOTED MESSAGE HERE</div></blockquote>";
        }
 
        // The button bar is a Grid element, and is also a Flexbox container.
@@ -518,20 +524,37 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                </div>`
        ;
 
+
        document.getElementById("ctdl-main").innerHTML = compose_screen;
-       mail_display_message(quoted_msgnum, document.getElementById(quoted_div_name), 0);
+
        if (m_cc) {
                document.getElementById("ctdl-compose-cc-label").style.display = "block";
                document.getElementById("ctdl-compose-cc-field").style.display = "block";
        }
 
        activate_uploads("ctdl-editor-body");
+
+       // If this is a quoted reply, render the original message into the div we set up earlier.
+       if (is_quoted) {
+               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";
 }