Changeset e21b59


Ignore:
Timestamp:
Apr 19, 2008, 3:03:17 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
aa47dc
Parents:
4dfe1d
Message:

moved comparison of StorageData? to identityData-Object.
modified onblur and oncommand-Settings

File:
1 edited

Legend:

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

    r4dfe1d re21b59  
    4040    email : null,
    4141    fullName : null,
    42     id_key : null,
    43     smtp_key : null,
     42    id : null,
     43    smtp : null,
    4444    extras : null,
    4545    __keyTranslator : null,
    4646    __combineStrings : function(stringA, stringB) {
    47         var A = stringA.replace(/^\s+|\s+$/g,"");
    48         var B = stringB.replace(/^\s+|\s+$/g,"");
     47        var A = (stringA)?stringA.replace(/^\s+|\s+$/g,""):"";
     48        var B = (stringB)?stringB.replace(/^\s+|\s+$/g,""):"";
    4949        if (!A) return B;
    5050        if (!B) return A;
     
    5858        return senderName + " (" +
    5959            this.__combineStrings(this.__combineStrings(idName, smtpName), extras) +  ")"
     60    },
     61    __equalCurrentSMTP : function() {
     62        var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
     63        return (!this.__keyTranslator.getSMTP(this.smtp) && !smtp_key ||
     64            smtp_key == this.smtp)
     65    },
     66    __equalCurrentID : function() {
     67        var id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("oldvalue");
     68        if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
     69        return ((!this.__keyTranslator.getID(this.id) && (id_key == gAccountManager.defaultAccount.defaultIdentity.key)) ||
     70            id_key == this.id)
     71    },
     72    equalsCurrentIdentity : function() {
     73        var curAddress = vI_helper.getAddress();       
     74        var curExtras = new vI_storageExtras();
     75        curExtras.readValues(); // initialize with current MsgComposeDialog Values
     76       
     77        var equal = (   (this.__equalCurrentID()) &&
     78                (this.__equalCurrentSMTP()) &&
     79                (curAddress.email == this.email) &&
     80                (curAddress.name == this.fullName) &&
     81                (this.extras.equal(curExtras))  )
     82        if (equal) vI_notificationBar.dump("## identityData: Identities are the same.\n")
     83        else vI_notificationBar.dump("## identityData: Identities differ.\n")
     84        return equal;
    6085    }
    6186}
     
    150175            // see https://bugzilla.mozilla.org/show_bug.cgi?id=355367
    151176            // same seems to happen with the ondragdrop event
    152             awGetInputElement(1).setAttribute("onblur",
    153                 "window.setTimeout(vI_storage.awOnBlur, 250, this.parentNode.parentNode.parentNode);")
    154             awGetPopupElement(1).setAttribute("oncommand",
    155                 "window.setTimeout(vI_storage.awPopupOnCommand, 250, this);")
     177            for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
     178                var input = awGetInputElement(row);
     179                if (input) {
     180                    var oldBlur = input.getAttribute("onblur")
     181                    input.setAttribute("onblur", (oldBlur?oldBlur+"; ":"") +
     182                        "window.setTimeout(vI_storage.awOnBlur, 250, this.parentNode.parentNode.parentNode);")
     183                }
     184                var popup = awGetPopupElement(row);
     185                if (popup) {
     186                    var oldCommand = popup.getAttribute("oncommand")
     187                    popup.setAttribute("oncommand", (oldCommand?oldCommand+"; ":"") +
     188                        "window.setTimeout(vI_storage.awPopupOnCommand, 250, this);")
     189                }
     190            }
    156191        }
    157192        vI_storage.original_functions.awSetInputAndPopupValue = awSetInputAndPopupValue;
     
    217252        }
    218253        // only update fields if new Identity is different than old one.
    219         else if (!vI_storage.__equalsCurrentIdentity(storageData)) {
     254        else if (!storageData.equalsCurrentIdentity()) {
    220255            // add Identity to dropdown-menu
    221256            vI_msgIdentityClone.addIdentityToCloneMenu(
     
    245280        else return { recDesc : recipient, recType : "email" }
    246281    },
    247    
    248     __equalsCurrentIdentity : function(storageData) {
    249         var curAddress = vI_helper.getAddress();       
    250         var id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("oldvalue");
    251         if (!id_key) id_key = vI_msgIdentityClone.elements.Obj_MsgIdentity_clone.getAttribute("value");
    252         var smtp_key = vI_smtpSelector.elements.Obj_SMTPServerList.selectedItem.getAttribute('key');
    253         var extras = new vI_storageExtras();
    254         extras.readValues(); // initialize with current MsgComposeDialog Values
    255 
    256         var equal = (   (id_key == storageData.id) &&
    257                 (smtp_key == storageData.smtp) &&
    258                 (curAddress.email == storageData.email) &&
    259                 (curAddress.name == storageData.fullName) &&
    260                 (extras.equal(storageData.extras))  )
    261         if (equal) vI_notificationBar.dump("## vI_storage: Identities are the same.\n")
    262         else vI_notificationBar.dump("## vI_storage: Identities differ.\n")
    263         return equal;
    264     },
    265    
     282       
    266283    storeVIdentityToAllRecipients : function(msgType) {
    267284        if (msgType != nsIMsgCompDeliverMode.Now) return;
     
    354371        var storageData = vI_rdfDatasource.readVIdentityFromRDF(recipient.recDesc, recipient.recType);
    355372        if (storageData) {
    356             if (!vI_storage.__equalsCurrentIdentity(storageData) &&
     373            if (!storageData.equalsCurrentIdentity(storageData) &&
    357374                !dontUpdateMultipleNoEqual) {
    358375                var warning = vI_storage.__getOverwriteStorageWarning(recipient, storageData);
Note: See TracChangeset for help on using the changeset viewer.