Changeset a44922


Ignore:
Timestamp:
Oct 26, 2007, 4:13:44 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
949c5e
Parents:
44bbd7
Message:

changed to accept drag&drop addresses, also checked for reply-to or followup-to fields

Location:
chrome/content/v_identity
Files:
2 edited

Legend:

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

    r44bbd7 ra44922  
    3333    VIdentityString : null,
    3434   
     35    lastCheckedEmail : {}, // array of last checked emails per row, to prevent ugly double dialogs
     36   
    3537    elements : { Obj_aBookSave : null },
    3638   
     
    4042    rdfService : Components.classes["@mozilla.org/rdf/rdf-service;1"]
    4143            .getService(Components.interfaces.nsIRDFService),
    42 
    43 
     44   
     45    original_functions : {
     46        awSetInputAndPopupValue : null,
     47    },
     48
     49    replacement_functions : {
     50        awSetInputAndPopupValue : function (inputElem, inputValue, popupElem, popupValue, rowNumber) {
     51            vI_notificationBar.dump("## vI_addressBook: awSetInputAndPopupValue '" + inputElem.id +"'\n");
     52            vI_addressBook.original_functions.awSetInputAndPopupValue(inputElem, inputValue, popupElem, popupValue, rowNumber);
     53            vI_addressBook.updateVIdentityFromABook(inputElem);
     54        },
     55    },
     56   
     57   
    4458    init: function() {
    4559        vI_addressBook.elements.Obj_aBookSave = document.getElementById("aBook_save");
     
    4761                    !vI.preferences.getBoolPref("aBook_use_non_vI"));
    4862        vI_addressBook.elements.Obj_aBookSave.checked = vI.preferences.getBoolPref("aBook_storedefault");
    49     },
    50 
     63       
     64        // better approach would be to use te onchange event, but this one is not fired in any change case
     65        // see https://bugzilla.mozilla.org/show_bug.cgi?id=355367
     66        // same seems to happen with the ondragdrop event
     67        awGetInputElement(1).setAttribute("onblur",
     68            "window.setTimeout(vI_addressBook.awOnBlur, 250, this.parentNode.parentNode.parentNode);")
     69        awGetPopupElement(1).setAttribute("oncommand",
     70            "window.setTimeout(vI_addressBook.awPopupOnCommand, 250, this);")
     71        vI_addressBook.original_functions.awSetInputAndPopupValue = awSetInputAndPopupValue;
     72        awSetInputAndPopupValue = function (inputElem, inputValue, popupElem, popupValue, rowNumber) {
     73            vI_addressBook.replacement_functions.awSetInputAndPopupValue (inputElem, inputValue, popupElem, popupValue, rowNumber) }
     74    },
     75   
     76    awOnBlur : function (element) {
     77        // only react on events triggered by addressCol2 - textinput Elements
     78        if (! element.id.match(/^addressCol2*/)) return;
     79        vI_notificationBar.dump("## v_identity: awOnBlur '" + element.id +"'\n");
     80        vI_addressBook.updateVIdentityFromABook(element);
     81    },
     82
     83    awPopupOnCommand : function (element) {
     84        vI_notificationBar.dump("## v_identity: awPopupOnCommand'" + element.id +"'\n");
     85        vI_addressBook.updateVIdentityFromABook(document.getElementById(element.id.replace(/^addressCol1/,"addressCol2")))
     86    },
     87   
    5188    removeVIdentityFromABook: function(remove) {
    5289        // this function will be called exclusivly from vI_prefDialog. So it is used in different context than the rest of
     
    104141        var parentDir = vI_addressBook.rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    105142        var enumerator = parentDir.childNodes;
    106         if (!enumerator) return null; // uups, no addressbooks?
     143        if (!enumerator) {vI_notificationBar.dump("## vI_addressBook: no addressbooks?\n"); return null;} // uups, no addressbooks?
    107144       
    108145        var splitted = { number : 0, emails : {}, fullNames : {}, combinedNames : {} };
     
    111148        var recipient_email = splitted.emails.value[0]
    112149        var recipient_fullName = splitted.fullNames.value[0]
    113         if (!recipient_email) return null;
    114    
     150        if (!recipient_email) {vI_notificationBar.dump("## vI_addressBook: no recipient_email?\n"); return null;}
     151       
    115152        vI_notificationBar.dump("## vI_addressBook: Search '" + recipient_email + "' in addressbooks.\n")
    116153       
     
    230267    },
    231268   
    232     updateVIdentityFromABook: function(email) {
    233         if (!vI.preferences.getBoolPref("aBook_use")) return;
     269    updateVIdentityFromABook: function(inputElement) {
     270        if (!vI.preferences.getBoolPref("aBook_use")) {
     271            vI_notificationBar.dump("## vI_addressBook: usage deactivated.\n")
     272            return all_addresses;
     273        }
     274       
     275        var recipientType = document.getElementById(inputElement.id.replace(/^addressCol2/,"addressCol1"))
     276                    .selectedItem.getAttribute("value");
     277        if (recipientType == "addr_reply" || recipientType == "addr_followup") {
     278            vI_notificationBar.dump("## vI_addressBook: field is a 'reply-to' or 'followup-to'. not searched.\n")
     279            return;
     280        }
     281        var email = inputElement.value
     282        if (email == "") {
     283            vI_notificationBar.dump("## vI_addressBook: no email found, not checked.\n"); return;
     284        }
     285       
     286        var row = inputElement.id.replace(/^addressCol2#/,"")
     287        if (vI_addressBook.lastCheckedEmail[row] && vI_addressBook.lastCheckedEmail[row] == email) {
     288            vI_notificationBar.dump("## vI_addressBook: same email than before, not checked again.\n"); return;
     289        }
     290        vI_addressBook.lastCheckedEmail[row] = email;
     291       
    234292        var Card = vI_addressBook.getCardForAddress(email); if (!Card) return;
    235293        var addresses = vI_addressBook.readVIdentityFromCard(Card)
     
    327385        // var all_addresses = { number : 0, emails : {}, fullNames : {},
    328386        //          combinedNames : {}, id_keys : {}, smtp_keys : {} };
     387        if (!vI.preferences.getBoolPref("aBook_use")) {
     388            vI_notificationBar.dump("## vI_addressBook: usage deactivated.\n")
     389            return all_addresses;
     390        }
    329391        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
     392            var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     393            if (recipientType == "addr_reply" || recipientType == "addr_followup") continue;
    330394            var Card = vI_addressBook.getCardForAddress(awGetInputElement(row).value);
    331395            if (!Card) continue;
  • chrome/content/v_identity/v_identity.js

    r44bbd7 ra44922  
    112112        NotifyComposeFieldsReady: function() {
    113113            vI_notificationBar.dump("## v_identity: NotifyComposeFieldsReady\n");
     114            vI_addressBook.init();
    114115            vI_smartIdentity.init();
    115116        },
     
    133134        },
    134135       
    135         awOnBlur : function (element) {
    136             vI_notificationBar.dump("## v_identity: awOnBlur\n");
    137             vI_addressBook.updateVIdentityFromABook(element.value);
    138         },
    139 
    140136        GenericSendMessage: function (msgType) {
    141137            var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
     
    222218        vI.elements.init_rest();
    223219       
    224         vI_addressBook.init();
    225220        vI_smtpSelector.init();
    226221        vI_msgIdentityClone.init();
     
    240235                    vI_addressBook.storeVIdentityToAllRecipients(msgType); } }
    241236       
    242         // better approach would be to use te onchange event, but this one is not fired in any change case
    243         // see https://bugzilla.mozilla.org/show_bug.cgi?id=355367
    244         awGetInputElement(1).setAttribute("onblur",
    245             "window.setTimeout(vI.replacement_functions.awOnBlur, 250, this);")
    246        
    247237        gMsgCompose.RegisterStateListener(vI.ComposeStateListener);
    248238        window.removeEventListener("load", vI.init, false);
Note: See TracChangeset for help on using the changeset viewer.