summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-10-28 11:21:18 +0100
committerAleksander Machniak <alec@alec.pl>2014-10-28 11:21:18 +0100
commit45bfde71d2e83d4f759ca6ae6e17cd293960fcea (patch)
tree42ba9039f07a9a0b3f7d9651c838e413b4d23136
parent68c41f1dff4ec94ffa78ef772cd1bcd3f8d2d9a0 (diff)
Fix so draft auto-save does not turn spellchecker off (#1490120)
-rw-r--r--program/js/app.js4
-rw-r--r--program/js/editor.js29
2 files changed, 19 insertions, 14 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 5d799c278..0fe485a4a 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3652,7 +3652,7 @@ function rcube_webmail()
this.save_response = function()
{
// show dialog to enter a name and to modify the text to be saved
- var buttons = {}, text = this.editor.get_content(true, true),
+ var buttons = {}, text = this.editor.get_content({selection: true, format: 'text', nosig: true}),
html = '<form class="propform">' +
'<div class="prop block"><label>' + this.get_label('responsename') + '</label>' +
'<input type="text" name="name" id="ffresponsename" size="40" /></div>' +
@@ -3840,7 +3840,7 @@ function rcube_webmail()
if (val = $('[name="_' + hash_fields[i] + '"]').val())
str += val + ':';
- str += this.editor.get_content();
+ str += this.editor.get_content({refresh: false});
if (this.env.attachments)
for (id in this.env.attachments)
diff --git a/program/js/editor.js b/program/js/editor.js
index 26b6927f5..3c10ad881 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -391,29 +391,33 @@ function rcube_text_editor(config, id)
};
// get selected text (if no selection returns all text) from the editor
- this.get_content = function(selected, plain)
+ this.get_content = function(args)
{
- // apply spellcheck changes if spell checker is active
- this.spellcheck_stop();
+ var sigstart, ed = this.editor, text = '', strip = false,
+ defaults = {refresh: true, selection: false, nosig: false, format: 'html'};
+
+ args = $.extend(defaults, args);
- var sigstart, ed = this.editor,
- format = plain ? 'text' : 'html',
- text = '', strip = false;
+ // apply spellcheck changes if spell checker is active
+ if (args.refresh) {
+ this.spellcheck_stop();
+ }
// get selected text from tinymce editor
if (ed) {
ed.getWin().focus(); // correct focus in IE & Chrome
- if (selected)
- text = ed.selection.getContent({format: format});
+ if (args.selection)
+ text = ed.selection.getContent({format: args.format});
if (!text) {
- text = ed.getContent({format: format});
- strip = true;
+ text = ed.getContent({format: args.format});
+ // @todo: strip signature in html mode
+ strip = args.format == 'text';
}
}
// get selected text from compose textarea
else if (ed = rcube_find_object(this.id)) {
- if (selected && $(ed).is(':focus')) {
+ if (args.selection && $(ed).is(':focus')) {
text = rcmail.get_input_selection(ed).text;
}
@@ -424,7 +428,8 @@ function rcube_text_editor(config, id)
}
// strip off signature
- if (strip) {
+ // @todo: make this optional
+ if (strip && args.nosig) {
sigstart = text.indexOf('-- \n');
if (sigstart > 0) {
text = text.substring(0, sigstart);