]> code.citadel.org Git - citadel.git/blobdiff - webcit-ng/static/js/view_mail.js
Close attachments window on Cancel
[citadel.git] / webcit-ng / static / js / view_mail.js
index 0b6cf8ce4a87b23c05b43a81d1ec1962c23238ae..8fac46efaaa8c72ae54ddfdae88925cbf9f98dce 100644 (file)
@@ -13,6 +13,7 @@ var newmail_notify = {
         NO  : 0,                                                               // do not perform new mail notifications
         YES : 1                                                                        // yes, perform new mail notifications
 };
+var num_attachments = 0;                                                       // number of attachments in current composed msg
 
 
 // This is the async back end for mail_delete_selected()
@@ -217,7 +218,7 @@ function mail_render_one(msgnum, msg, target_div, include_controls) {
                                        }
                                        display_attachments += 1;
                                        outmsg += "<li>"
-                                               + "<a href=\"/ctdl/r/" + escapeHTMLURI(current_room) + "/" + msgnum + "/" + msg.part[r].partnum + "/" + escapeHTMLURI(msg.part[r].filename) + "\">"
+                                               + "<a href=\"/ctdl/r/" + escapeHTMLURI(current_room) + "/" + msgnum + "/" + msg.part[r].partnum + "/" + escapeHTMLURI(msg.part[r].filename) + "\" target=\"_blank\">"
                                                + "<i class=\"fa fa-paperclip\"></i>&nbsp;" + msg.part[r].partnum + ": " + msg.part[r].filename
                                                + " (" + msg.part[r].len + " " + _("bytes") + ")"
                                                + "</a>"
@@ -513,9 +514,9 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                + "<div class=\"ctdl-compose-toolbar\">"
                + "<span class=\"ctdl-msg-button\" onclick=\"mail_send_message()\"><i class=\"fa fa-paper-plane\" style=\"color:green\"></i> " + _("Send message") + "</span>"
                + "<span class=\"ctdl-msg-button\">" + _("Save to Drafts") + "</span>"
-               + "<span class=\"ctdl-msg-button\">" + _("Attachments:") + " 0" + "</span>"
+               + "<span class=\"ctdl-msg-button\" onClick=\"show_or_hide_attachments()\"><i class=\"fa fa-paperclip\" style=\"color:grey\"></i> " + _("Attachments:") + " <span id=\"ctdl_num_attachments\">" + num_attachments + "</span></span>"
                + "<span class=\"ctdl-msg-button\">" + _("Contacts") + "</span>"
-               + "<span class=\"ctdl-msg-button\" onClick=\"gotoroom(current_room)\"><i class=\"fa fa-trash\" style=\"color:red\"></i> " + _("Cancel") + "</span>"
+               + "<span class=\"ctdl-msg-button\" onClick=\"document.getElementById('ctdl_big_modal').style.display='none';gotoroom(current_room)\"><i class=\"fa fa-trash\" style=\"color:red\"></i> " + _("Cancel") + "</span>"
                + "</div>"
        ;
 
@@ -525,6 +526,37 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                document.getElementById("ctdl-compose-cc-label").style.display = "block";
                document.getElementById("ctdl-compose-cc-field").style.display = "block";
        }
+
+       // Now the compose screen is set up properly; set up the attachments modal in case the user wants it
+
+       document.getElementById("ctdl_big_modal").innerHTML = ""
+               + "<div id=\"ctdl_attachments_outer\">"
+               + "<div id=\"ctdl_attachments_title\" class=\"ctdl-compose-attachments-title\">"
+               + "<div><h1><i class=\"fa fa-paperclip\" style=\"color:grey\"></i> " + _("Attachments:") + "</h1></div>"
+               + "<div><h1><i class=\"fas fa-window-close\" style=\"color:red\" onClick=\"show_or_hide_attachments()\"></i></h1></div>"
+               + "</div>"
+               + "<br>"
+               + "this is the attachments modal.  there are many like it, but this one is mine."
+               + "</div>"
+       ;
+
+}
+
+
+// Show or hide the attachments window in the composer
+function show_or_hide_attachments() {
+
+       if (document.getElementById("ctdl_big_modal").style.display == "block") {
+               document.getElementById("ctdl_big_modal").style.display = "none";
+       }
+       else {
+               document.getElementById("ctdl_big_modal").style.display = "block";
+               document.getElementById("ctdl_attachments_outer").style.width =
+                       Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().width) * 0.90).toString() + "px";
+               document.getElementById("ctdl_attachments_outer").style.height =
+                       Math.trunc((document.getElementById("ctdl-editor-body").getBoundingClientRect().height) * 0.90).toString() + "px";
+       }
+
 }