Changeset a72ca3


Ignore:
Timestamp:
Oct 27, 2007, 7:37:39 PM (12 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
fd8981
Parents:
35e142
Message:

rewrote auto-reply-to, still experimental, not fully working

Location:
chrome/content/v_identity
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_msgIdentityClone.js

    r35e142 ra72ca3  
    124124    LoadIdentity : function()
    125125    {
    126         vI_msgIdentityClone.cleanupReplyTo(true);
     126        vI_msgIdentityClone.cleanupReplyTo();
    127127        if (vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.selectedItem.value != "vid") {
    128128            vI_msgIdentityClone.copySelectedIdentity();
     
    136136            vI.helper.getAccountname(vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.selectedItem));
    137137        vI_msgIdentityClone.markAsNewAccount(vI_msgIdentityClone.isNewIdentity());
    138         vI_msgIdentityClone.searchReplyToRow();
     138        vI_msgIdentityClone.initReplyToFields();
    139139    },
    140140   
     
    162162    },
    163163   
    164     replyToInputElem : null,
    165     replyToPopupElem : null,
     164    replyToInputElem : null,    // it is important to store the Elements and not the row
     165    replyToPopupElem : null,    // cause row might change if one above gets removed
    166166    replyToStoredLastValue : null,
    167     replyToStoredInitValue : null,
    168167    replyToSynchronize : true,
    169168   
    170     searchReplyToRow : function() {
     169    // called directly after a change of the Identity with the dropdown menu
     170    // searches the first reply-to row and assumes that this is the one we like to adapt
     171    initReplyToFields : function() {
    171172        if (!vI.preferences.getBoolPref("experimental")) return
    172         vI_notificationBar.dump("#X searchReplyToRow\n");
     173        var replyTo = gAccountManager.getIdentity(vI_msgIdentityClone.elements.
     174                Obj_MsgIdentity_clone.selectedItem.value).replyTo
     175        vI_notificationBar.dump("#X initReplyToFields identity.replyTo: " + replyTo + "\n");
     176        if (replyTo == "") return
     177       
    173178        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    174             var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
    175             if (recipientType == "addr_reply") {
     179            var awType = awGetPopupElement(row).selectedItem.getAttribute("value");
     180            var awValue = awGetInputElement(row).value
     181            if (awType == "addr_reply" && awValue == replyTo) {
    176182                vI_notificationBar.dump("#X vI_msgIdentityClone: Reply-To found in row " + row + "\n");
    177                 vI_msgIdentityClone.replyToPopupElem = document.getElementById("addressCol1#" + row)
    178                 vI_msgIdentityClone.replyToInputElem = document.getElementById("addressCol2#" + row)
    179                 vI_msgIdentityClone.replyToStoredInitValue = document.getElementById("addressCol2#" + row).value
     183                vI_msgIdentityClone.replyToPopupElem = awGetPopupElement(row)
     184                vI_msgIdentityClone.replyToInputElem = awGetInputElement(row)
    180185                break;
    181186                }
    182187        }
    183         if (!vI_msgIdentityClone.replyToInputElem) vI_notificationBar.dump("#X vI_msgIdentityClone: no reply-to row found\n");
    184     },
    185    
    186     cleanupReplyTo : function(force) {
     188        if (!vI_msgIdentityClone.replyToInputElem) vI_notificationBar.dump("#X vI_msgIdentityClone: no Reply-To row found\n");
     189    },
     190   
     191    cleanupReplyTo : function() {
    187192        if (!vI.preferences.getBoolPref("experimental")) return
     193        if (!vI_msgIdentityClone.replyToSynchronize) return
    188194        vI_notificationBar.dump("#X cleanupReplyTo\n");
    189         if  (vI_msgIdentityClone.replyToInputElem &&
    190                 (vI_msgIdentityClone.replyToInputElem.value == vI_msgIdentityClone.replyToStoredLastValue)) {
     195        if (vI_msgIdentityClone.replyToInputElem) {
    191196                vI_notificationBar.dump("#X restore ReplyTo\n");
    192                 vI_msgIdentityClone.replyToInputElem.value = vI_msgIdentityClone.replyToStoredInitValue
    193             }
    194         if (force) {
    195             vI_msgIdentityClone.replyToInputElem = null;
    196             vI_msgIdentityClone.replyToPopupElem = null;
    197             vI_msgIdentityClone.replyToStoredInitValue = null;
    198         }
     197                vI_msgIdentityClone.replyToInputElem.value =
     198                    gAccountManager.getIdentity(vI_msgIdentityClone.elements.
     199                        Obj_MsgIdentity_clone.selectedItem.value).replyTo
     200                vI_msgIdentityClone.replyToInputElem.setAttribute("value",
     201                    gAccountManager.getIdentity(vI_msgIdentityClone.elements.
     202                        Obj_MsgIdentity_clone.selectedItem.value).replyTo)
     203            }
     204        vI_msgIdentityClone.replyToInputElem = null;
     205        vI_msgIdentityClone.replyToPopupElem = null;
    199206        vI_msgIdentityClone.replyToStoredLastValue = null;
    200207    },
    201208   
     209    // updateReplyTo is called on every change in the From: field, if its a virtual Identity
    202210    updateReplyTo : function(newIdentity) {
    203211        if (!vI.preferences.getBoolPref("experimental")) return
    204212        if (!vI.preferences.getBoolPref("autoReplyToSelf")) return
    205         vI_notificationBar.dump("#X updateReplyTo\n");
    206 
     213        if (!vI_msgIdentityClone.replyToSynchronize) {
     214            vI_notificationBar.dump("#X updateReplyTo stopped Synchronizing\n")
     215            return
     216        }
     217        vI_notificationBar.dump("#X updateReplyTo replyToStoredLastValue="
     218                + vI_msgIdentityClone.replyToStoredLastValue + "\n");
     219
     220        // if replyToInputElem not set (so no initial Reply-To row was found) add a row now
    207221        if (!vI_msgIdentityClone.replyToInputElem) {
    208222            awAddRecipient("addr_reply",vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.value)
    209             vI_msgIdentityClone.replyToPopupElem = document.getElementById("addressCol1#" + top.MAX_RECIPIENTS)
    210             vI_msgIdentityClone.replyToInputElem = document.getElementById("addressCol2#" + top.MAX_RECIPIENTS)
    211             vI_msgIdentityClone.replyToStoredInitValue = document.getElementById("addressCol2#" + top.MAX_RECIPIENTS).value
     223            //~ vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.focus()
     224            vI_msgIdentityClone.replyToPopupElem = awGetPopupElement(top.MAX_RECIPIENTS - 1)
     225            vI_msgIdentityClone.replyToInputElem = awGetInputElement(top.MAX_RECIPIENTS - 1)
     226            //~ vI_notificationBar.dump("#X vI_msgIdentityClone: Reply-To created in row " + top.MAX_RECIPIENTS + "\n");
     227        }
     228       
     229        // check if sychronizing should still be done (will be stopped if value was modified by hand)
     230        if ( (vI_msgIdentityClone.replyToPopupElem.selectedItem.value != "addr_reply") ||
     231            (vI_msgIdentityClone.replyToStoredLastValue &&
     232            vI_msgIdentityClone.replyToInputElem.value != vI_msgIdentityClone.replyToStoredLastValue)) {
     233            vI_msgIdentityClone.replyToSynchronize = false;
     234            vI_notificationBar.dump("#X vI_msgIdentityClone: (former) Reply-To entry changed, stop synchronizing\n");
    212235        }
    213236        else {
    214             // check if reply-to field was changed individually, then stop adapting the field
    215             if ((vI_msgIdentityClone.replyToPopupElem.selectedItem.getAttribute("value") != "addr_reply") ||
    216                 (vI_msgIdentityClone.replyToStoredLastValue &&
    217                 vI_msgIdentityClone.replyToInputElem.value != vI_msgIdentityClone.replyToStoredLastValue)) {
    218                 replyToSynchronize = false;
    219                 vI_notificationBar.dump("#X vI_msgIdentityClone: (former) Reply-To entry changed, stop synchronizing\n");
    220             }
    221             else {
    222                 vI_msgIdentityClone.replyToInputElem.value = vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.value
    223                 vI_msgIdentityClone.replyToStoredLastValue = vI_msgIdentityClone.replyToInputElem.value
    224             }
    225         }
     237            vI_msgIdentityClone.replyToInputElem.value =
     238                vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.value
     239            //~ vI_msgIdentityClone.replyToInputElem.setAttribute("value",
     240                //~ vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.value)
     241            vI_msgIdentityClone.replyToStoredLastValue = vI_msgIdentityClone.replyToInputElem.value
     242        }
     243        vI_msgIdentityClone.elements.Obj_MsgIdentityTextbox_clone.focus()
    226244    },
    227245   
     
    278296            try { if (ss_signature.length > 0) ss_main.signatureSwitch(); }
    279297            catch(vErr) { };
    280            
    281             //~ vI_msgIdentityClone.cleanupReplyTo(false);
    282298        }
    283299    },
  • chrome/content/v_identity/v_identity.js

    r35e142 ra72ca3  
    112112        NotifyComposeFieldsReady: function() {
    113113            vI_notificationBar.dump("## v_identity: NotifyComposeFieldsReady\n");
    114             vI_msgIdentityClone.searchReplyToRow();
     114            vI_msgIdentityClone.initReplyToFields();
    115115            vI_addressBook.init();
    116116            vI_smartIdentity.init();
Note: See TracChangeset for help on using the changeset viewer.