Bug #9334: Rework Cc/Bcc display in DIMP
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 28 Oct 2010 22:51:31 +0000 (16:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 Oct 2010 20:43:22 +0000 (14:43 -0600)
ONLY show Cc/Bcc fields in dimp if compose_[b]cc pref is set.  Locked
value is irrelevant. This matches behavior in IMP.

Improved location of Show Cc/Bcc button in dimp.

imp/compose-dimp.php
imp/js/compose-dimp.js
imp/lib/Ajax/Application.php
imp/lib/Views/Compose.php
imp/message-dimp.php
imp/templates/dimp/compose/compose.html
imp/themes/dimp/screen.css

index 85770cf..0c0cd0a 100644 (file)
@@ -200,7 +200,13 @@ case 'new':
 if ($vars->type == 'redirect') {
     $imp_ui->attachAutoCompleter(array('redirect_to'));
 } else {
-    $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc', 'redirect_to'));
+    $acomplete = array('to', 'redirect_to');
+    foreach (array('cc', 'bcc') as $val) {
+        if ($prefs->getValue('compose_' . $val)) {
+            $acomplete[] = $val;
+        }
+    }
+    $imp_ui->attachAutoCompleter($acomplete);
     $imp_ui->attachSpellChecker();
     $sig = $identity->getSignature($show_editor ? 'html' : 'text');
     if ($get_sig && !empty($sig)) {
index edd404e..59dc8fc 100644 (file)
@@ -68,8 +68,8 @@ var DimpCompose = {
         }
 
         $('composeCache').clear();
-        $('qreply', 'sendcc', 'sendbcc').invoke('hide');
-        [ $('msgData'), $('togglecc'), $('togglebcc') ].invoke('show');
+        $('qreply', 'sendcc', 'sendbcc').compact().invoke('hide');
+        $('msgData', 'togglecc', 'togglebcc').compact().invoke('show');
         if (IMP_Compose_Base.editor_on) {
             this.toggleHtmlEditor();
         }
@@ -86,7 +86,9 @@ var DimpCompose = {
         var identity = IMP_Compose_Base.getIdentity($F('identity'));
 
         this.setPopdownLabel('sm', identity.id.smf_name, identity.id.smf_display);
-        $('bcc').setValue(identity.id.bcc);
+        if (DIMP.conf_compose.bcc) {
+            $('bcc').setValue(identity.id.bcc);
+        }
         this.setSaveSentMail(identity.id.smf_save);
 
         IMP_Compose_Base.replaceSignature($F('identity'));
@@ -523,26 +525,26 @@ var DimpCompose = {
         opts = opts || {};
 
         $('to').setValue(header.to);
-        if (header.cc) {
+        if (DIMP.conf_compose.cc && header.cc) {
             $('cc').setValue(header.cc);
-        }
-        if (DIMP.conf_compose.cc || header.cc) {
-            this.toggleCC('cc', true);
+            this.toggleCC('cc');
         }
         this.setPopdownLabel('sm', identity.id.smf_name, identity.id.smf_display);
         this.setSaveSentMail(identity.id.smf_save);
-        if (header.bcc) {
-            $('bcc').setValue(header.bcc);
-        }
-        if (identity.id.bcc) {
-            bcc_add = $F('bcc');
-            if (bcc_add) {
-                bcc_add += ', ';
+        if (DIMP.conf_compose.bcc) {
+            if (header.bcc) {
+                $('bcc').setValue(header.bcc);
+            }
+            if (identity.id.bcc) {
+                bcc_add = $F('bcc');
+                if (bcc_add) {
+                    bcc_add += ', ';
+                }
+                $('bcc').setValue(bcc_add + identity.id.bcc);
+            }
+            if ($F('bcc')) {
+                this.toggleCC('bcc');
             }
-            $('bcc').setValue(bcc_add + identity.id.bcc);
-        }
-        if (DIMP.conf_compose.bcc || header.bcc) {
-            this.toggleCC('bcc', true);
         }
         $('subject').setValue(header.subject);
 
@@ -600,7 +602,7 @@ var DimpCompose = {
             !this.auto_save_interval) {
             this.auto_save_interval = new PeriodicalExecuter(function() {
                 if ($('compose').visible()) {
-                    var hdrs = MD5.hash($('to', 'cc', 'bcc', 'subject').invoke('getValue').join('\0')), msg;
+                    var hdrs = MD5.hash($('to', 'cc', 'bcc', 'subject').compact().invoke('getValue').join('\0')), msg;
                     if (this.md5_hdrs) {
                         msg = this.msgHash();
                         if (this.md5_hdrs != hdrs || this.md5_msg != msg) {
@@ -831,20 +833,18 @@ var DimpCompose = {
         DimpCore.doActionComplete({ responseJSON: doc.body.innerHTML.evalJSON(true) }, this.uniqueSubmitCallback.bind(this));
     },
 
-    toggleCC: function(type, immediate)
+    toggleCC: function(type)
     {
-        var t = $('toggle' + type);
+        var t;
 
         $('send' + type).show();
-        if (immediate) {
-            t.hide();
-            this.resizeMsgArea();
+        t = $('toggle' + type);
+        if (t.siblings().size()) {
+            t.remove();
         } else {
-            t.fade({
-                afterFinish: this.resizeMsgArea.bind(this),
-                duration: 0.4
-            });
+            t.up('TR').remove();
         }
+        this.resizeMsgArea();
     },
 
     /* Open the addressbook window. */
@@ -1069,12 +1069,16 @@ var DimpCompose = {
 
         // Automatically resize compose address fields.
         new TextareaResize('to');
-        new TextareaResize('cc');
-        new TextareaResize('bcc');
+        if (DIMP.conf_compose.cc) {
+            new TextareaResize('cc');
+        }
+        if (DIMP.conf_compose.bcc) {
+            new TextareaResize('bcc');
+        }
 
         /* Add addressbook link formatting. */
         if (DIMP.conf_compose.URI_ABOOK) {
-            $('sendto', 'sendcc', 'sendbcc', 'redirect_sendto').each(function(a) {
+            $('sendto', 'sendcc', 'sendbcc', 'redirect_sendto').compact().each(function(a) {
                 a.down('TD.label SPAN').addClassName('composeAddrbook');
             });
         }
index b3a9132..cbba8a1 100644 (file)
@@ -1797,12 +1797,10 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
 
         $imp_ui = $injector->getInstance('IMP_Ui_Compose');
         $headers['to'] = $imp_ui->getAddressList($this->_vars->to);
-        if ($prefs->getValue('compose_cc') ||
-            !$prefs->isLocked('compose_cc')) {
+        if ($prefs->getValue('compose_cc')) {
             $headers['cc'] = $imp_ui->getAddressList($this->_vars->cc);
         }
-        if ($prefs->getValue('compose_bcc') ||
-            !$prefs->isLocked('compose_bcc')) {
+        if ($prefs->getValue('compose_bcc')) {
             $headers['bcc'] = $imp_ui->getAddressList($this->_vars->bcc);
         }
         $headers['subject'] = $this->_vars->subject;
index 098c4d0..fb8b1ca 100644 (file)
@@ -173,6 +173,9 @@ class IMP_Views_Compose
             ), true));
         }
 
+        $t->set('bcc', $prefs->getValue('compose_bcc'));
+        $t->set('cc', $prefs->getValue('compose_cc'));
+        $t->set('bcc_or_cc', $t->get('bcc') || $t->get('cc'));
         $t->set('compose_enable', IMP::canCompose());
         $t->set('forminput', Horde_Util::formInput());
         $t->set('redirect_button', IMP_Dimp::actionButton(array(
@@ -180,6 +183,7 @@ class IMP_Views_Compose
             'id' => 'send_button_redirect',
             'title' => _("Redirect")
         )));
+
         $result['html'] = $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose.html');
 
         return $result;
index 1c32a13..e9a0fea 100644 (file)
@@ -84,7 +84,13 @@ if (!$disable_compose) {
 
     /* Attach spellchecker & auto completer. */
     $imp_ui = new IMP_Ui_Compose();
-    $imp_ui->attachAutoCompleter(array('to', 'cc', 'bcc', 'redirect_to'));
+    $acomplete = array('to', 'redirect_to');
+    foreach (array('cc', 'bcc') as $val) {
+        if ($prefs->getValue('compose_' . $val)) {
+            $acomplete[] = $val;
+        }
+    }
+    $imp_ui->attachAutoCompleter($acomplete);
     $imp_ui->attachSpellChecker();
 
     $js_out = array_merge($js_out, $compose_result['js']);
index e07a292..e58e89c 100644 (file)
  <div id="writemsg">
   <div class="msgwrite">
    <div class="dimpOptions">
-    <div id="togglecc">
-     <label>
-      <input name="togglecc" type="checkbox" class="checkbox" /><gettext>Show Cc</gettext>
-     </label>
-    </div>
-    <div id="togglebcc">
-     <label>
-      <input name="togglebcc" type="checkbox" class="checkbox" /><gettext>Show Bcc</gettext>
-     </label>
-    </div>
 <if:rte>
     <div>
      <label>
@@ -96,6 +86,7 @@
       <span id="to_loading_img" class="loadingImg" style="display:none"></span>
      </td>
     </tr>
+<if:cc>
     <tr id="sendcc" style="display:none">
      <td class="label">
       <span><gettext>Cc:</gettext></span>
       <span id="cc_loading_img" class="loadingImg" style="display:none"></span>
      </td>
     </tr>
+</if:cc>
+<if:bcc>
     <tr id="sendbcc" style="display:none">
      <td class="label">
       <span><gettext>Bcc:</gettext></span>
       <span id="bcc_loading_img" class="loadingImg" style="display:none"></span>
      </td>
     </tr>
+</if:bcc>
+<if:bcc_or_cc>
+    <tr>
+     <td></td>
+     <td>
+<if:cc>
+      <span id="togglecc"><gettext>Add Cc</gettext></span>
+</if:cc>
+<if:bcc>
+      <span id="togglebcc"><gettext>Add Bcc</gettext></span>
+</if:bcc>
+     </td>
+    </tr>
+</if:bcc_or_cc>
     <tr>
      <td class="label">
       <gettext>Subject:</gettext>
index cef6b99..e632618 100644 (file)
@@ -615,14 +615,20 @@ div.dimpActionsCompose, div.dimpActionsMsg {
 }
 
 /* Message Composition. */
-.composeAddrbook {
+.composeAddrbook, #togglebcc, #togglecc {
     color: blue;
     cursor: pointer;
     text-decoration: underline;
 }
+#togglebcc, #togglecc {
+    padding-right: 5px;
+}
 .composeAddrbook:hover {
     font-weight: bold;
 }
+#togglebcc:hover, #togglecc:hover {
+    color: red;
+}
 
 #writemsg input.checkbox {
     margin-right: 2px;