summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/js/app.js30
-rw-r--r--program/js/editor.js24
2 files changed, 31 insertions, 23 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 3543ed3ce..a3b2b27ac 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -225,7 +225,7 @@ function rcube_webmail()
}
}
else if (this.env.action == 'compose') {
- this.enable_command('send-attachment', 'remove-attachment', 'send', true);
+ this.enable_command('send-attachment', 'remove-attachment', 'send', 'toggle-editor', true);
if (this.env.spellcheck) {
this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); };
@@ -321,7 +321,7 @@ function rcube_webmail()
}
else if (this.env.action=='edit-identity' || this.env.action=='add-identity') {
this.enable_command('add', this.env.identities_level < 2);
- this.enable_command('save', 'delete', 'edit', true);
+ this.enable_command('save', 'delete', 'edit', 'toggle-editor', true);
}
else if (this.env.action=='folders')
this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', 'enable-threading', 'disable-threading', true);
@@ -978,7 +978,6 @@ function rcube_webmail()
// unified command call (command name == function name)
default:
var func = command.replace('-', '_');
- alert(func);
if (this[func] && typeof this[func] == 'function')
this[func](props);
break;
@@ -2808,6 +2807,30 @@ function rcube_webmail()
return true;
};
+ this.toggle_editor = function(props)
+ {
+ if (props.mode == 'html') {
+ this.display_spellcheck_controls(false);
+ this.plain2html($('#'+props.id).val(), props.id);
+ tinyMCE.execCommand('mceAddControl', false, props.id);
+ }
+ else {
+ var thisMCE = tinyMCE.get(props.id),
+ existingHtml = thisMCE.getContent();
+
+ if (existingHtml) {
+ if (!confirm(this.get_label('editorwarning'))) {
+ return false;
+ }
+ this.html2plain(existingHtml, props.id);
+ }
+ tinyMCE.execCommand('mceRemoveControl', false, props.id);
+ this.display_spellcheck_controls(true);
+ }
+
+ return true;
+ };
+
this.stop_spellchecking = function()
{
if (this.env.spellcheck && !this.spellcheck_ready) {
@@ -5116,3 +5139,4 @@ function rcube_webmail()
rcube_webmail.prototype.addEventListener = rcube_event_engine.prototype.addEventListener;
rcube_webmail.prototype.removeEventListener = rcube_event_engine.prototype.removeEventListener;
rcube_webmail.prototype.triggerEvent = rcube_event_engine.prototype.triggerEvent;
+
diff --git a/program/js/editor.js b/program/js/editor.js
index a5e3af3d5..fd128cb8f 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -95,7 +95,6 @@ function rcmail_editor_tabindex()
// switch html/plain mode
function rcmail_toggle_editor(select, textAreaId, flagElement)
{
- var composeElement = document.getElementById(textAreaId);
var flag, ishtml;
if (select.tagName != 'SELECT')
@@ -103,32 +102,17 @@ function rcmail_toggle_editor(select, textAreaId, flagElement)
else
ishtml = select.value == 'html';
- if (ishtml) {
- rcmail.display_spellcheck_controls(false);
+ var res = rcmail.command('toggle-editor', {id:textAreaId, mode:ishtml?'html':'plain'});
- rcmail.plain2html(composeElement.value, textAreaId);
- tinyMCE.execCommand('mceAddControl', false, textAreaId);
+ if (ishtml) {
// #1486593
setTimeout("rcmail_editor_tabindex();", 500);
if (flagElement && (flag = rcube_find_object(flagElement)))
flag.value = '1';
}
else {
- var thisMCE = tinyMCE.get(textAreaId);
- var existingHtml = thisMCE.getContent();
-
- if (existingHtml) {
- if (!confirm(rcmail.get_label('editorwarning'))) {
- if (select.tagName == 'SELECT')
- select.value = 'html';
- return false;
- }
-
- rcmail.html2plain(existingHtml, textAreaId);
- }
-
- tinyMCE.execCommand('mceRemoveControl', false, textAreaId);
- rcmail.display_spellcheck_controls(true);
+ if (!res && select.tagName == 'SELECT')
+ select.value = 'html';
if (flagElement && (flag = rcube_find_object(flagElement)))
flag.value = '0';
}