diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index 5f47fea23d0735ef0d0724fb7e2c4afaab0e650c..8a6d3f963821988f358f18fa28ca9c018fdaa50a 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -374,7 +374,7 @@ public class WebMail extends HttpServlet StringBuilder buf = new StringBuilder(128); buf.append("<input type=\"submit\" class=\"").append(name).append("\" name=\"") .append(name).append("\" value=\"").append(label).append('"'); - if (name.equals(SEND) || name.equals(CANCEL) || name.equals(DELETE_ATTACHMENT)) + if (name.equals(SEND) || name.equals(CANCEL) || name.equals(DELETE_ATTACHMENT) || name.equals(NEW_UPLOAD)) buf.append(" onclick=\"cancelPopup()\""); buf.append('>'); return buf.toString(); @@ -971,15 +971,21 @@ public class WebMail extends HttpServlet sessionObject.pageChanged = true; } } + /** * process buttons of compose message dialog + * This must be called BEFORE processStateChangeButtons so we can add the attachment before SEND + * * @param sessionObject * @param request */ private static void processComposeButtons(SessionObject sessionObject, RequestWrapper request) { - if( buttonPressed( request, NEW_UPLOAD ) ) { - String filename = request.getFilename( NEW_FILENAME ); + String filename = request.getFilename( NEW_FILENAME ); + // We handle an attachment whether sending or uploading + if (filename != null && + (buttonPressed(request, NEW_UPLOAD) || buttonPressed(request, SEND))) { + Debug.debug(Debug.DEBUG, "Got filename in compose form: " + filename); int i = filename.lastIndexOf( "/" ); if( i != - 1 ) filename = filename.substring( i + 1 ); @@ -1339,6 +1345,11 @@ public class WebMail extends HttpServlet sessionObject.imgPath = sessionObject.themePath + "images/"; sessionObject.isMobile = isMobile; + // This must be called to add the attachment before + // processStateChangeButtons() sends the message + if( sessionObject.state == STATE_NEW ) + processComposeButtons( sessionObject, request ); + int oldState = sessionObject.state; processStateChangeButtons( sessionObject, request ); int newState = sessionObject.state; @@ -1381,9 +1392,6 @@ public class WebMail extends HttpServlet } } - if( sessionObject.state == STATE_NEW ) - processComposeButtons( sessionObject, request ); - /* * update folder content */ @@ -1685,8 +1693,7 @@ public class WebMail extends HttpServlet private static void showCompose( PrintWriter out, SessionObject sessionObject, RequestWrapper request ) { out.println( button( SEND, _("Send") ) + spacer + - button( CANCEL, _("Cancel") ) + spacer + - (sessionObject.attachments != null && (!sessionObject.attachments.isEmpty()) ? button( DELETE_ATTACHMENT, _("Delete Attachment") ) : button2( DELETE_ATTACHMENT, _("Delete Attachment") ) ) + spacer); + button( CANCEL, _("Cancel") )); //if (Config.hasConfigFile()) // out.println(button( RELOAD, _("Reload Config") ) + spacer); //out.println(button( LOGOUT, _("Logout") ) ); @@ -1715,12 +1722,13 @@ public class WebMail extends HttpServlet "<tr><td align=\"right\">" + _("To:") + "</td><td align=\"left\"><input type=\"text\" size=\"80\" name=\"" + NEW_TO + "\" value=\"" + to + "\"></td></tr>\n" + "<tr><td align=\"right\">" + _("Cc:") + "</td><td align=\"left\"><input type=\"text\" size=\"80\" name=\"" + NEW_CC + "\" value=\"" + cc + "\"></td></tr>\n" + "<tr><td align=\"right\">" + _("Bcc:") + "</td><td align=\"left\"><input type=\"text\" size=\"80\" name=\"" + NEW_BCC + "\" value=\"" + bcc + "\"></td></tr>\n" + - "<tr><td align=\"right\">" + _("Bcc to self") + ": </td><td align=\"left\"><input type=\"checkbox\" class=\"optbox\" name=\"" + NEW_BCC_TO_SELF + "\" value=\"1\"" + (sessionObject.bccToSelf ? "checked" : "" ) + "></td></tr>\n" + + "<tr><td align=\"right\">" + _("Bcc to self") + ": </td><td align=\"left\"><input type=\"checkbox\" class=\"optbox\" name=\"" + NEW_BCC_TO_SELF + "\" value=\"1\" " + (sessionObject.bccToSelf ? "checked" : "" ) + "></td></tr>\n" + "<tr><td align=\"right\">" + _("Subject:") + "</td><td align=\"left\"><input type=\"text\" size=\"80\" name=\"" + NEW_SUBJECT + "\" value=\"" + subject + "\"></td></tr>\n" + "<tr><td colspan=\"2\" align=\"center\"><textarea cols=\"" + Config.getProperty( CONFIG_COMPOSER_COLS, 80 )+ "\" rows=\"" + Config.getProperty( CONFIG_COMPOSER_ROWS, 10 )+ "\" name=\"" + NEW_TEXT + "\">" + text + "</textarea>" + "<tr><td colspan=\"2\" align=\"center\"><hr></td></tr>\n" + - "<tr><td align=\"right\">" + _("New Attachment:") + "</td><td align=\"left\"><input type=\"file\" size=\"50%\" name=\"" + NEW_FILENAME + "\" value=\"\">" + - "<input type=\"submit\" name=\"" + NEW_UPLOAD + "\" value=\"" + _("Upload File") + "\" onclick=\"cancelPopup()\"></td></tr>" ); + "<tr><td align=\"right\">" + _("Add Attachment:") + "</td><td align=\"left\"><input type=\"file\" size=\"50%\" name=\"" + NEW_FILENAME + "\" value=\"\"></td></tr>" + + // TODO disable/hide in JS if no file selected + "<tr><td> </td><td align=\"left\">" + button(NEW_UPLOAD, _("Add another attachment")) + "</td></tr>"); if( sessionObject.attachments != null && !sessionObject.attachments.isEmpty() ) { boolean wroteHeader = false; @@ -1733,6 +1741,10 @@ public class WebMail extends HttpServlet } out.println("<td align=\"left\"><input type=\"checkbox\" class=\"optbox\" name=\"check" + attachment.hashCode() + "\" value=\"1\"> " + attachment.getFileName() + "</td></tr>"); } + // TODO disable in JS if none selected + out.println("<tr><td> </td><td align=\"left\">" + + button( DELETE_ATTACHMENT, _("Delete selected attachments") ) + + "</td></tr>"); } out.println( "</table>" ); } diff --git a/installer/resources/themes/susimail/dark/susimail.css b/installer/resources/themes/susimail/dark/susimail.css index 7a4990b3dd5a5ef9a7236ae476e45ee0fafe2c07..832a72e000e11261fcb2b05c5c7839d6c241bd93 100644 --- a/installer/resources/themes/susimail/dark/susimail.css +++ b/installer/resources/themes/susimail/dark/susimail.css @@ -233,6 +233,11 @@ input.send, input.setpagesize { min-height: 22px; } +input[type=file], input.new_upload { + background: #000 url('/themes/console/images/add.png') no-repeat 2px center; + min-height: 22px; +} + input { font-size: 9pt; font-weight: bold; diff --git a/installer/resources/themes/susimail/light/susimail.css b/installer/resources/themes/susimail/light/susimail.css index 41f42bc009779d611ac5faa5ba49997171b79cc0..4cc9889c1bed4887f9409fb19b4fb6ce33263550 100644 --- a/installer/resources/themes/susimail/light/susimail.css +++ b/installer/resources/themes/susimail/light/susimail.css @@ -230,6 +230,12 @@ input.send, input.setpagesize { min-height: 22px; } +input[type=file], input.new_upload { + background: #ddf url('/themes/console/images/add.png') no-repeat 4px center; + padding: 2px 3px 2px 24px; + min-height: 22px; +} + input[type=text], input[type=password] { padding: 1px 4px; }