From 79af0bb1ba370bd5f194afb692e7ed59a26b02af Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 03 Nov 2008 09:26:23 -0500
Subject: [PATCH] - Add warning when switching editor mode from html to plain (#1485488) - Unified editor switching functions

---
 program/js/app.js |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index d8a7eed..5c258f9 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3622,24 +3622,34 @@
     this.enable_command('export', (this.contact_list.rowcount > 0));
     };
 
-  this.toggle_editor = function(checkbox, textAreaId)
+  this.toggle_editor = function(ishtml, textAreaId, flagElement)
     {
-    var ischecked = checkbox.checked;
     var composeElement = document.getElementById(textAreaId);
-    
-    if (ischecked)
+    var flag;
+
+    if (ishtml)
       {
       var existingPlainText = composeElement.value;
       var htmlText = "<pre>" + existingPlainText + "</pre>";
+
+      this.display_spellcheck_controls(false);
       composeElement.value = htmlText;
       tinyMCE.execCommand('mceAddControl', true, textAreaId);
+      if (flagElement && (flag = rcube_find_object(flagElement)))
+        flag.value = '1';
       }
     else
       {
+      if (!confirm(rcmail.get_label('editorwarning')))
+        return false;
+
       var thisMCE = tinyMCE.get(textAreaId);
       var existingHtml = thisMCE.getContent();
       this.html2plain(existingHtml, textAreaId);
       tinyMCE.execCommand('mceRemoveControl', true, textAreaId);
+      this.display_spellcheck_controls(true);
+      if (flagElement && (flag = rcube_find_object(flagElement)))
+        flag.value = '0';
       }
     };
 

--
Gitblit v1.9.1