Bug 208628 - Copies & Folders: Initialize Bcc field to the current address. r=Standard8,ui-review=bwinton
authoraceman <acelists@atlas.sk>
Tue, 21 Feb 2012 12:27:59 +0000
changeset 10877 4fd77b4c57ca0e4f88433c74af2fa1feef76fbd5
parent 10876 c3184f1b35342dbd35a6757f2513f8e403897c96
child 10878 61c6cbd61566227ed1f9eca6de38d1a5496ebaab
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs208628
Bug 208628 - Copies & Folders: Initialize Bcc field to the current address. r=Standard8,ui-review=bwinton
mailnews/base/prefs/content/am-copies.js
--- a/mailnews/base/prefs/content/am-copies.js
+++ b/mailnews/base/prefs/content/am-copies.js
@@ -49,17 +49,17 @@ function onPreInit(account, accountValue
 {
   gAccount = account;
   var type = parent.getAccountValue(account, accountValues, "server", "type", null, false);
   hideShowControls(type);
 }
 
 /*
  * Set the global radio element choices and initialize folder/account pickers.
- * Also, initialize other UI elements (bcc self, fcc picker controller checkboxes).
+ * Also, initialize other UI elements (cc, bcc, fcc picker controller checkboxes).
  */
 function onInit(aPageId, aServerId)
 {
   gCurrentServerId = aServerId;
     onInitCopiesAndFolders();
 }
 
 function onInitCopiesAndFolders()
@@ -85,18 +85,18 @@ function onInitCopiesAndFolders()
                      "msgArchivesFolderPicker");
 
     SetFolderDisplay(gTmplRadioElemChoice, gTmplRadioElemChoiceLocked,
                      "tmpl",
                      "msgStationeryAccountPicker",
                      "identity.stationeryFolder",
                      "msgStationeryFolderPicker");
 
-    setupCcTextbox();
-    setupBccTextbox();
+    setupCcTextbox(true);
+    setupBccTextbox(true);
     setupFccItems();
     setupArchiveItems();
 
     SetSpecialFolderNamesWithDelims();
 }
 
 // Initialize the picker mode choices (account/folder picker) into global vars
 function SetGlobalRadioElemChoices()
@@ -351,31 +351,51 @@ function setupFccItems()
                 break;
         }
     }
     else
         broadcaster.setAttribute("disabled", "true");
 }
 
 // Disable CC textbox if CC checkbox is not checked
-function setupCcTextbox()
+function setupCcTextbox(init)
 {
     var ccChecked = document.getElementById("identity.doCc").checked;
     var ccTextbox = document.getElementById("identity.doCcList");
 
     ccTextbox.disabled = !ccChecked;
+
+    if (ccChecked) {
+        if (ccTextbox.value == "") {
+            ccTextbox.value = document.getElementById("identity.email").value;
+            if (!init)
+                ccTextbox.select();
+        }
+    } else if ((ccTextbox.value == document.getElementById("identity.email").value) ||
+               (init && ccTextbox.getAttribute("value") == ""))
+        ccTextbox.value = "";
 }
 
 // Disable BCC textbox if BCC checkbox is not checked
-function setupBccTextbox()
+function setupBccTextbox(init)
 {
     var bccChecked = document.getElementById("identity.doBcc").checked;
     var bccTextbox = document.getElementById("identity.doBccList");
 
     bccTextbox.disabled = !bccChecked;
+
+    if (bccChecked) {
+        if (bccTextbox.value == "") {
+            bccTextbox.value = document.getElementById("identity.email").value;
+            if (!init)
+                bccTextbox.select();
+        }
+    } else if ((bccTextbox.value == document.getElementById("identity.email").value) ||
+               (init && bccTextbox.getAttribute("value") == ""))
+        bccTextbox.value = "";
 }
 
 // Enable and disable pickers based on the radio element clicked
 function SetPickerEnabling(enablePickerId, disablePickerId)
 {
     var activePicker = document.getElementById(enablePickerId);
     activePicker.removeAttribute("disabled");