| | |
| | | tinymce.registered_request_token = true; |
| | | tinymce.util.XHR.on('beforeSend', function(e) { |
| | | e.xhr.setRequestHeader('X-Roundcube-Request', rcmail.env.request_token); |
| | | // Fix missing lang parameter on addToDictionary request (#1490634) |
| | | if (e.settings && e.settings.data && /^method=addToDictionary/.test(e.settings.data) && !/&lang=/.test(e.settings.data)) |
| | | e.settings.data += '&lang=' + ref.editor.plugins.spellchecker.getLanguage(); |
| | | }); |
| | | } |
| | | |
| | |
| | | |
| | | // 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}); |
| | | |
| | |
| | | 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 |
| | |
| | | |
| | | // Append the signature as a div within the body |
| | | if (!sigElem) { |
| | | var body = this.editor.getBody(), |
| | | doc = this.editor.getDoc(); |
| | | var body = this.editor.getBody(); |
| | | |
| | | sigElem = doc.createElement('div'); |
| | | sigElem.setAttribute('id', '_rc_sig'); |
| | | sigElem = $('<div id="_rc_sig"></div>').get(0); |
| | | |
| | | if (rcmail.env.top_posting && !rcmail.env.sig_below) { |
| | | // insert at start or at cursor position in top-posting mode |
| | | // (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(); |
| | | |
| | | // insert at start or at cursor position if found |
| | | body.insertBefore(sigElem, node.nodeName == 'BODY' ? body.firstChild : node.nextSibling); |
| | | body.insertBefore(doc.createElement('p'), sigElem); |
| | | $(sigElem).insertBefore(node.nodeName == 'BODY' ? body.firstChild : node.nextSibling); |
| | | $('<p>').append($('<br>')).insertBefore(sigElem); |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | |