Link save attach option with save sent mail
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 19:21:44 +0000 (12:21 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Nov 2009 21:41:07 +0000 (14:41 -0700)
imp/js/compose-dimp.js
imp/templates/chunks/compose.php

index be704a3..98d8a8e 100644 (file)
@@ -66,20 +66,17 @@ var DimpCompose = {
         }
     },
 
-    change_identity: function()
+    changeIdentity: function()
     {
         var lastSignature, msg, nextSignature, pos,
             id = $F('identity'),
-            last = this.get_identity($F('last_identity')),
+            last = this.getIdentity($F('last_identity')),
             msgval = $('composeMessage'),
-            next = this.get_identity(id),
-            ssm = $('save_sent_mail');
+            next = this.getIdentity(id);
 
         this.setSentMailLabel(next.id[3], next.id[5], true);
         $('bcc').setValue(next.id[6]);
-        if (ssm) {
-            ssm.writeAttribute('checked', next.id[4]);
-        }
+        this.setSaveSentMail(next.id[4]);
 
         // Finally try and replace the signature.
         if (this.editor_on) {
@@ -119,6 +116,20 @@ var DimpCompose = {
         }
     },
 
+    setSaveSentMail: function(set)
+    {
+        var ssm = $('save_sent_mail'), tmp;
+
+        if (ssm) {
+            ssm.setValue(set);
+
+            tmp = $('attach_cell').down('LABEL');
+            if (tmp) {
+                [ tmp ].invoke(set ? 'show' : 'hide');
+            }
+        }
+    },
+
     setSentMailLabel: function(s, l, sel)
     {
         var label = $('sent_mail_folder_label');
@@ -142,7 +153,7 @@ var DimpCompose = {
         }
     },
 
-    get_identity: function(id, editor_on)
+    getIdentity: function(id, editor_on)
     {
         editor_on = Object.isUndefined(editor_on) ? this.editor_on : editor_on;
         return {
@@ -372,7 +383,7 @@ var DimpCompose = {
                 this.rte = CKEDITOR.replace('composeMessage', config);
             }
         }
-        $('htmlcheckbox').checked = this.editor_on;
+        $('htmlcheckbox').setValue(this.editor_on);
         $('html').setValue(this.editor_on ? 1 : 0);
     },
 
@@ -452,7 +463,7 @@ var DimpCompose = {
         }
 
         var bcc_add,
-            identity = this.get_identity($F('last_identity')),
+            identity = this.getIdentity($F('last_identity')),
             msgval = $('composeMessage');
 
         if (!this.last_msg.empty() &&
@@ -495,6 +506,7 @@ var DimpCompose = {
             this.toggleCC('cc', true);
         }
         this.setSentMailLabel(identity.id[3], identity.id[5], true);
+        this.setSaveSentMail(identity.id[4]);
         if (header.bcc) {
             $('bcc').setValue(header.bcc);
             this.resizebcc.resizeNeeded();
@@ -648,7 +660,7 @@ var DimpCompose = {
             break;
 
         case 'sig':
-            pos = $F('composeMessage').replace(/\r\n/g, '\n').lastIndexOf(this.get_identity($F('last_identity')).sig) - 1;
+            pos = $F('composeMessage').replace(/\r\n/g, '\n').lastIndexOf(this.getIdentity($F('last_identity')).sig) - 1;
             break;
 
         default:
@@ -712,7 +724,7 @@ var DimpCompose = {
                 if (!this.editor_on || window.confirm(DIMP.text_compose.toggle_html)) {
                     this.toggleHtmlEditor();
                 } else {
-                    $('htmlcheckbox').checked = true;
+                    $('htmlcheckbox').setValue(true);
                 }
                 break;
 
@@ -732,6 +744,10 @@ var DimpCompose = {
                     DimpCore.popupWindow(DimpCore.addURLParam(DIMP.conf.URI_VIEW, { composeCache: $F('composeCache'), actionID: 'compose_attach_preview', id: atc_num }), $F('composeCache') + '|' + atc_num);
                 }
                 break;
+
+            case 'save_sent_mail':
+                this.setSaveSentMail($F(elt));
+                break;
             }
 
             elt = elt.up();
@@ -747,7 +763,7 @@ var DimpCompose = {
 
         switch (id) {
         case 'identity':
-            this.change_identity();
+            this.changeIdentity();
             break;
 
         case 'upload':
@@ -793,7 +809,7 @@ var DimpCompose = {
                 list: DIMP.conf_compose.flist,
                 onChoose: this.setSentMailLabel.bind(this)
             });
-            this.knl.setSelected(this.get_identity($F('identity'))[3]);
+            this.knl.setSelected(this.getIdentity($F('identity'))[3]);
             $('sent_mail_folder_label').insert({ after: new Element('SPAN', { className: 'popdownImg' }).observe('click', function(e) { this.knl.show(); this.knl.ignoreClick(e); e.stop(); }.bindAsEventListener(this)) });
         }
 
index 761504d..9ad2995 100644 (file)
@@ -64,7 +64,7 @@ $compose_disable = !IMP::canCompose();
 <?php if ($GLOBALS['conf']['user']['allow_folders'] && !$GLOBALS['prefs']->isLocked('save_sent_mail')): ?>
    <div style="display:none">
     <label>
-     <input id="save_sent_mail" name="save_sent_mail" type="checkbox" class="checkbox"<?php if ($identity->saveSentmail()) echo ' checked="checked"' ?> /> <?php echo _("Save in") ?>
+     <input id="save_sent_mail" name="save_sent_mail" type="checkbox" class="checkbox" /> <?php echo _("Save in") ?>
      <span id="sent_mail_folder_label"></span>
     </label>
     <input id="save_sent_mail_folder" name="save_sent_mail_folder" type="hidden" />
@@ -122,7 +122,7 @@ $compose_disable = !IMP::canCompose();
     <td id="attach_cell">
      <input type="file" id="upload" name="file_1" />
 <?php if (strpos($save_attach, 'prompt') !== false): ?>
-     <label><input type="checkbox" class="checkbox" name="save_attachments_select"<?php if (strpos($save_attach, 'yes') !== false) echo ' checked="checked"' ?> /> <?php echo _("Save Attachments in sent folder") ?></label><br />
+     <label style="display:none"><input type="checkbox" class="checkbox" name="save_attachments_select"<?php if (strpos($save_attach, 'yes') !== false) echo ' checked="checked"' ?> /> <?php echo _("Save Attachments in sent folder") ?></label><br />
 <?php endif; ?>
      <ul id="attach_list" style="display:none"></ul>
     </td>