From b95a6d8f415789648ada33f54fd6dc15d9f07d46 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 18 Sep 2015 05:11:33 -0400
Subject: [PATCH] Disable some toolbar buttons if Mailvelope editor is active (#1490533)

---
 program/js/app.js |    8 ++++++++
 skins/larry/ui.js |   10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index c5e9e59..19c5f9b 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3451,6 +3451,10 @@
         .find('iframe:not([aria-hidden=true])').remove();
       $('#' + ref.env.composebody).show();
       $("[name='_pgpmime']").remove();
+
+      // disable commands that operate on the compose body
+      ref.enable_command('spellcheck', 'insert-sig', 'toggle-editor', 'insert-response', 'save-response', true);
+      ref.triggerEvent('compose-encrypted', { active:false });
     }
     // embed Mailvelope editor container
     else {
@@ -3471,6 +3475,10 @@
         container.addClass('mailvelope');
         $('#' + ref.env.composebody).hide();
 
+        // disable commands that operate on the compose body
+        ref.enable_command('spellcheck', 'insert-sig', 'toggle-editor', 'insert-response', 'save-response', false);
+        ref.triggerEvent('compose-encrypted', { active:true });
+
         // notify user about loosing attachments
         if (ref.env.attachments && !$.isEmptyObject(ref.env.attachments)) {
           alert(ref.get_label('encryptnoattachments'));
diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index 092f108..926f039 100644
--- a/skins/larry/ui.js
+++ b/skins/larry/ui.js
@@ -174,10 +174,14 @@
       }
       else if (rcmail.env.action == 'compose') {
         rcmail.addEventListener('aftersend-attachment', show_uploadform)
-          .addEventListener('aftertoggle-editor', function(e){
+          .addEventListener('aftertoggle-editor', function(e) {
             window.setTimeout(function(){ layout_composeview() }, 200);
             if (e && e.mode)
               $("select[name='editorSelector']").val(e.mode);
+          })
+          .addEventListener('compose-encrypted', function(e) {
+            $("select[name='editorSelector']").prop('disabled', e.active);
+            $('a.button.attach, a.button.responses')[(e.active?'addClass':'removeClass')]('disabled');
           });
 
         // Show input elements with non-empty value
@@ -1023,6 +1027,10 @@
       return;
     }
 
+    // do nothing if mailvelope editor is active
+    if (rcmail.mailvelope_editor)
+      return;
+
     // add icons to clone file input field
     if (rcmail.env.action == 'compose' && !$dialog.data('extended')) {
       $('<a>')

--
Gitblit v1.9.1