summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-05-05 19:14:53 +0000
committeralecpl <alec@alec.pl>2010-05-05 19:14:53 +0000
commit1f019c8e5886461eb1ab0c053d88527d45ccacde (patch)
tree4e03ee2795ce1ebdb1a3a56e494cb01cf19d6436 /program/js
parentc6427797b7b54716a8555fa5acef817a7ea3cdfc (diff)
- Set focus to editor on reply in HTML mode (#1486632)
- Fix composing in HTML jumps cursor to body instead of recipients (#1486674)
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js30
-rw-r--r--program/js/editor.js13
2 files changed, 26 insertions, 17 deletions
diff --git a/program/js/app.js b/program/js/app.js
index dd3feeeca..3304c1325 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -2621,9 +2621,11 @@ function rcube_webmail()
input_to.focus();
else if (input_subject.val() == '')
input_subject.focus();
- else if (input_message && !html_mode)
+ else if (input_message)
input_message.focus();
+ this.env.compose_focus_elem = document.activeElement;
+
// get summary of all field values
this.compose_field_hash(true);
@@ -2789,12 +2791,12 @@ function rcube_webmail()
if (!show_sig)
show_sig = this.env.show_sig;
- var id = obj.options[obj.selectedIndex].value;
- var input_message = $("[name='_message']");
- var message = input_message.val();
- var is_html = ($("input[name='_is_html']").val() == '1');
- var sig_separator = this.env.sig_above && (this.env.compose_mode == 'reply' || this.env.compose_mode == 'forward') ? '---' : '-- ';
- var sig, cursor_pos, p = -1;
+ var sig, cursor_pos, p = -1,
+ id = obj.options[obj.selectedIndex].value,
+ input_message = $("[name='_message']"),
+ message = input_message.val(),
+ is_html = ($("input[name='_is_html']").val() == '1'),
+ sig_separator = this.env.sig_above && (this.env.compose_mode == 'reply' || this.env.compose_mode == 'forward') ? '---' : '-- ';
if (!this.env.identity)
this.env.identity = id
@@ -2830,7 +2832,7 @@ function rcube_webmail()
if (p >= 0) { // in place of removed signature
message = message.substring(0, p) + sig + message.substring(p, message.length);
cursor_pos = p - 1;
- }
+ }
else if (pos = this.get_caret_pos(input_message.get(0))) { // at cursor position
message = message.substring(0, pos) + '\n' + sig + '\n\n' + message.substring(pos, message.length);
cursor_pos = pos;
@@ -2838,7 +2840,7 @@ function rcube_webmail()
else { // on top
cursor_pos = 0;
message = '\n\n' + sig + '\n\n' + message.replace(/^[\r\n]+/, '');
- }
+ }
}
else {
message = message.replace(/[\r\n]+$/, '');
@@ -2855,20 +2857,20 @@ function rcube_webmail()
this.set_caret_pos(input_message.get(0), cursor_pos);
}
else if (show_sig && this.env.signatures) { // html
- var editor = tinyMCE.get(this.env.composebody);
- var sigElem = editor.dom.get('_rc_sig');
+ var editor = tinyMCE.get(this.env.composebody),
+ sigElem = editor.dom.get('_rc_sig');
// Append the signature as a div within the body
if (!sigElem) {
- var body = editor.getBody();
- var doc = editor.getDoc();
+ var body = editor.getBody(),
+ doc = editor.getDoc();
sigElem = doc.createElement('div');
sigElem.setAttribute('id', '_rc_sig');
if (this.env.sig_above) {
// if no existing sig and top posting then insert at caret pos
- editor.getWin().focus(); // correct focus in IE
+ editor.getWin().focus(); // correct focus in IE & Chrome
var node = editor.selection.getNode();
if (node.nodeName == 'BODY') {
diff --git a/program/js/editor.js b/program/js/editor.js
index 1b1129ecc..34511ce0b 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -63,11 +63,18 @@ function rcmail_editor_init(skin_path, editor_lang, spellcheck, mode)
// react to real individual tinyMCE editor init
function rcmail_editor_callback(editor)
{
- var input_from = rcube_find_object('_from');
- if (input_from && input_from.type=='select-one')
- rcmail.change_identity(input_from);
+ var editor, elem = rcube_find_object('_from');
+ if (elem && elem.type=='select-one')
+ rcmail.change_identity(elem);
// set tabIndex
rcmail_editor_tabindex();
+ // set focus to element that was focused before
+ if (elem = rcmail.env.compose_focus_elem) {
+ if (elem.id == rcmail.env.composebody && (editor = tinyMCE.get(rcmail.env.composebody)))
+ editor.getWin().focus();
+ else
+ elem.focus();
+ }
}
// set tabIndex on tinyMCE editor