From 3940ba65be1993c4a2c2be4599f53d3018228783 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 30 Jun 2010 04:40:39 -0400
Subject: [PATCH] - Resize editor after switching to html mode - create toggle-editor command in app.js, to make possible binding to this command - Code cleanup in rcmail_ui (moved compose-related functions into rcmail_ui)

---
 program/js/editor.js |   24 ++++--------------------
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/program/js/editor.js b/program/js/editor.js
index a5e3af3..fd128cb 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -95,7 +95,6 @@
 // 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 @@
   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';
   }

--
Gitblit v1.9.1