From bd0551b22076b82a6d49e9f7a2b2e0c90a1b2326 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 05 Feb 2016 07:25:27 -0500
Subject: [PATCH] Secure also downloads of addressbook exports, managesieve script exports and Enigma keys exports

---
 skins/classic/functions.js |   87 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/skins/classic/functions.js b/skins/classic/functions.js
index b521be3..5a55c95 100644
--- a/skins/classic/functions.js
+++ b/skins/classic/functions.js
@@ -193,6 +193,9 @@
     catch(e){}  // ignore errors
   }
 
+  if (rcmail.mailvelope_editor)
+    return;
+
   this.show_popupmenu('uploadmenu', show);
 
   if (!document.all && this.popups.uploadmenu.obj.is(':visible'))
@@ -398,11 +401,11 @@
 {
   var id = elem.parentNode.id.replace(/^attach/, '');
 
-  $('#attachmenuopen').unbind('click').attr('onclick', '').click(function(e) {
+  $('#attachmenuopen').off('click').attr('onclick', '').click(function(e) {
     return rcmail.command('open-attachment', id, this);
   });
 
-  $('#attachmenudownload').unbind('click').attr('onclick', '').click(function() {
+  $('#attachmenudownload').off('click').attr('onclick', '').click(function() {
     rcmail.command('download-attachment', id, this);
   });
 
@@ -547,12 +550,13 @@
 resize_compose_body: function()
 {
   var div = $('#compose-div .boxlistcontent'),
-    w = div.width() - 2, h = div.height(),
+    w = div.width() - 6,
+    h = div.height() - 2,
     x = bw.ie || bw.opera ? 4 : 0;
 
-  $('#compose-body_ifr').width(w+3).height(h-2 - $('div.mce-toolbar').height());
+  $('#compose-body_ifr').width(w + 6).height(h - 1 - $('div.mce-toolbar').height());
   $('#compose-body').width(w-x).height(h);
-  $('#googie_edit_layer').height(h);
+  $('#googie_edit_layer').width(w).height(h);
 },
 
 resize_compose_body_ev: function()
@@ -636,6 +640,41 @@
     var label = rcmail.gettext(p.status ? 'replylist' : 'replyall');
     $('a.button.replyAll').attr('title', label);
   }
+  else if (p.command == 'compose-encrypted') {
+    // show the toolbar button for Mailvelope
+    $('#messagetoolbar > a.encrypt').show();
+  }
+},
+
+folder_search_init: function(container)
+{
+  // animation to unfold list search box
+  $('.boxtitle a.search', container).click(function(e) {
+    var title = $('.boxtitle', container),
+      box = $('.listsearchbox', container),
+      dir = box.is(':visible') ? -1 : 1,
+      height = 24 + ($('select', box).length ? 24 : 0);
+
+    box.slideToggle({
+      duration: 160,
+      progress: function(animation, progress) {
+        if (dir < 0) progress = 1 - progress;
+          $('.boxlistcontent', container).css('top', (title.outerHeight() + height * progress) + 'px');
+      },
+      complete: function() {
+        box.toggleClass('expanded');
+        if (box.is(':visible')) {
+          box.find('input[type=text]').focus();
+        }
+        else {
+          $('a.reset', box).click();
+        }
+        // TODO: save state in cookie
+      }
+    });
+
+    return false;
+  });
 }
 
 };
@@ -976,7 +1015,7 @@
       update_quota(rcmail.env.quota_content);
     rcmail.addEventListener('setquota', update_quota);
 
-    $('iframe').load(iframe_events)
+    $('iframe').on('load', iframe_events)
       .contents().mouseup(function(e) { rcmail_ui.body_mouseup(e); });
 
     if (rcmail.env.task == 'mail') {
@@ -995,22 +1034,52 @@
           .addEventListener('afterimport-messages', function(){ rcmail_ui.show_popup('uploadform', false); });
       }
 
-      if (rcmail.env.action == 'compose')
+      rcmail.init_pagejumper('#pagejumper');
+
+      // fix message list header on window resize (#1490213)
+      if (bw.ie && rcmail.message_list)
+        $(window).resize(function() {
+          setTimeout(function() { rcmail.message_list.resize(); }, 10);
+        });
+
+      if (rcmail.env.action == 'compose') {
         rcmail_ui.init_compose_form();
-      else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview')
+        rcmail.addEventListener('compose-encrypted', function(e) {
+          $("a.button.encrypt")[(e.active ? 'addClass' : 'removeClass')]('selected');
+          $("select[name='editorSelector']").prop('disabled', e.active);
+          $('a.button.attach, a.button.responses, a.button.attach, #uploadmenulink')[(e.active ? 'addClass' : 'removeClass')]('buttonPas disabled');
+          $('#responseslist a.insertresponse')[(e.active ? 'removeClass' : 'addClass')]('active');
+        });
+      }
+      else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview') {
         // add menu link for each attachment
         $('#attachment-list > li[id^="attach"]').each(function() {
-          $(this).append($('<a class="drop"></a>').bind('click keypress', function(e) {
+          $(this).append($('<a class="drop"></a>').on('click keypress', function(e) {
             if (e.type != 'keypress' || e.which == 13) {
               rcmail_ui.show_attachmentmenu(this, e);
               return false;
             }
           }));
         });
+
+        $(window).resize(function() {
+          var mvlpe = $('#messagebody.mailvelope');
+          if (mvlpe.length) {
+            var content = $('#messageframe'),
+              h = (content.length ? content.height() + content.offset().top - 25 : $(this).height()) - mvlpe.offset().top - 20;
+            mvlpe.height(h);
+          }
+        });
+      }
     }
     else if (rcmail.env.task == 'addressbook') {
       rcmail.addEventListener('afterupload-photo', function(){ rcmail_ui.show_popup('uploadform', false); })
         .gui_object('dragmenu', 'dragmenu');
     }
+    else if (rcmail.env.task == 'settings') {
+      if (rcmail.env.action == 'folders') {
+        rcmail_ui.folder_search_init($('#folder-manager'));
+      }
+    }
   });
 }

--
Gitblit v1.9.1