Susimail: Fix up compose.js (ticket #2176)

Enable for configuration page
Version the js
This commit is contained in:
zzz
2018-03-12 11:42:52 +00:00
parent 81808d4a60
commit ffc0bcc3a0
2 changed files with 8 additions and 17 deletions

View File

@@ -1,5 +1,2 @@
// onbeforeunload() is in the servlet because it has a translated string
function cancelPopup() {
window.onbeforeunload = null;
}
let beforePopup = true;
window.addEventListener('beforeunload', (e)=>{if (beforePopup) e.returnValue=true;} );

View File

@@ -524,8 +524,9 @@ 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) || name.equals(NEW_UPLOAD))
buf.append(" onclick=\"cancelPopup()\"");
if (name.equals(SEND) || name.equals(CANCEL) || name.equals(DELETE_ATTACHMENT) || name.equals(NEW_UPLOAD) ||
name.equals(SETPAGESIZE) || name.equals(SAVE)) // config page
buf.append(" onclick=\"beforePopup=false;\"");
// These are icons only now, via the CSS, so add a tooltip
if (name.equals(FIRSTPAGE) || name.equals(PREVPAGE) || name.equals(NEXTPAGE) || name.equals(LASTPAGE) ||
name.equals(PREV) || name.equals(LIST) || name.equals(NEXT))
@@ -2166,18 +2167,11 @@ public class WebMail extends HttpServlet
}
if(state != State.AUTH)
out.println("<link rel=\"stylesheet\" href=\"/susimail/css/print.css?" + CoreVersion.VERSION + "\" type=\"text/css\" media=\"print\" />");
if (state == State.NEW) {
if (state == State.NEW || state == State.CONFIG) {
// TODO cancel if to and body are empty
out.println(
"<script type=\"text/javascript\">\n" +
"window.onbeforeunload = function () {" +
"return \"" + _t("Message has not been sent. Do you want to discard it?") + "\";" +
"};\n" +
"</script>"
);
out.println("<script src=\"/susimail/js/compose.js\" type=\"text/javascript\"></script>");
out.println("<script src=\"/susimail/js/compose.js?" + CoreVersion.VERSION + "\" type=\"text/javascript\"></script>");
} else if (state == State.LIST) {
out.println("<script src=\"/susimail/js/folder.js\" type=\"text/javascript\"></script>");
out.println("<script src=\"/susimail/js/folder.js?" + CoreVersion.VERSION + "\" type=\"text/javascript\"></script>");
} else if (state == State.LOADING) {
// TODO JS?
out.println("<meta http-equiv=\"refresh\" content=\"5;url=" + myself + "\">");