From 0344b168276f80189e2254c75a762aff5b517b6b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sun, 22 May 2016 06:32:57 -0400 Subject: [PATCH] Fix priority icon(s) position --- program/js/editor.js | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/program/js/editor.js b/program/js/editor.js index 200d8c8..1702e21 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -450,7 +450,6 @@ // get selected text from tinymce editor if (ed) { - ed.getWin().focus(); // correct focus in IE & Chrome if (args.selection) text = ed.selection.getContent({format: args.format}); @@ -513,10 +512,10 @@ message = message.substring(0, p) + sig + message.substring(p, message.length); cursor_pos = p - 1; } - // empty message - else if (!message) { - message = '\n\n' + sig; - cursor_pos = 0; + // empty message or new-message mode + else if (!message || !rcmail.env.compose_mode) { + cursor_pos = message.length; + message += '\n\n' + sig; } else if (rcmail.env.top_posting && !rcmail.env.sig_below) { // at cursor position @@ -555,8 +554,10 @@ sigElem = $('<div id="_rc_sig"></div>').get(0); // insert at start or at cursor position in top-posting mode - // (but not if the content is empty) - if (rcmail.env.top_posting && !rcmail.env.sig_below && (body.childNodes.length > 1 || $(body).text())) { + // (but not if the content is empty and not in new-message mode) + if (rcmail.env.top_posting && !rcmail.env.sig_below + && rcmail.env.compose_mode && (body.childNodes.length > 1 || $(body).text()) + ) { this.editor.getWin().focus(); // correct focus in IE & Chrome var node = this.editor.selection.getNode(); @@ -566,7 +567,7 @@ } else { body.appendChild(sigElem); - position_element = rcmail.env.top_posting ? body.firstChild : $(sigElem).prev(); + position_element = rcmail.env.top_posting && rcmail.env.compose_mode ? body.firstChild : $(sigElem).prev(); } } -- Gitblit v1.9.1