From b0bb38703e73794a924949effe6df5d8dfd106a0 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 11 Mar 2015 12:04:19 -0400
Subject: [PATCH] Fix bug where spellchecking in HTML editor do not work after switching editor type more than once (#1490311)

---
 CHANGELOG            |    1 +
 program/js/editor.js |   13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index b2b181d..c949585 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -33,6 +33,7 @@
 - Fix Opera browser detection in javascript (#1490307)
 - Fix so search filter, scope and fields are reset on folder change
 - Fix rows count when messages search fails (#1490266)
+- Fix bug where spellchecking in HTML editor do not work after switching editor type more than once (#1490311)
 
 RELEASE 1.1.0
 -------------
diff --git a/program/js/editor.js b/program/js/editor.js
index d16c0e8..3b2d65e 100644
--- a/program/js/editor.js
+++ b/program/js/editor.js
@@ -65,6 +65,15 @@
     }
   }
 
+  // secure spellchecker requests with Roundcube token
+  // Note: must be registered only once (#1490311)
+  if (!tinymce.registered_request_token) {
+    tinymce.registered_request_token = true;
+    tinymce.util.XHR.on('beforeSend', function(e) {
+      e.xhr.setRequestHeader('X-Roundcube-Request', rcmail.env.request_token);
+    });
+  }
+
   // minimal editor
   if (config.mode == 'identity') {
     $.extend(conf, {
@@ -106,10 +115,6 @@
     });
     ed.on('keypress', function() {
       rcmail.compose_type_activity++;
-    });
-    // secure spellchecker requests with Roundcube token
-    tinymce.util.XHR.on('beforeSend', function(e) {
-      e.xhr.setRequestHeader('X-Roundcube-Request', rcmail.env.request_token);
     });
   };
 

--
Gitblit v1.9.1