Changeset ee9df2


Ignore:
Timestamp:
Nov 29, 2012, 9:58:21 AM (9 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
2a443c
Parents:
b4293d
Message:

changed to support multiple windows (grr, was broken since a good while)

Location:
content
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • content/vI_rdfDataEditor.xul

    rb4293d ree9df2  
    3737
    3838<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDataEditor.js" />
    39 <script type="application/x-javascript" src="chrome://v_identity/content/vI_storage.js" />
     39
     40<!-- FillIdentityList is required from MsgComposeCommands -->
    4041<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
    41 
    4242
    4343    <dialogheader title="&vI_rdfDataEditor.header.label;"/>
  • content/vI_smartIdentity.js

    rb4293d ree9df2  
    4343       
    4444    // After Loading the MessageComposeDialog, check if smartIdentity is needed
    45     init : function() {
     45    init : function(currentWindow) {
    4646        var msgHdr;
    4747        var msgComposeTypeReference = Components.interfaces.nsIMsgCompType;
     
    6060                msgHdr = smartIdentity.messenger.
    6161                    messageServiceFromURI(gMsgCompose.originalMsgURI).messageURIToMsgHdr(gMsgCompose.originalMsgURI);
    62                 smartIdentity._smartIdentityCollection = new vI.smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("virtualIdentityExtension_msgIdentityClone").vid, newsgroup, this._getRecipients()); 
     62                smartIdentity._smartIdentityCollection = new vI.smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("virtualIdentityExtension_msgIdentityClone").vid, newsgroup, this._getRecipients(currentWindow));
    6363                smartIdentity._smartIdentityCollection.Reply();
    6464                autocreate = false; break;
     
    6868                msgHdr = smartIdentity.messenger.
    6969                    messageServiceFromURI(gMsgCompose.compFields.draftId).messageURIToMsgHdr(gMsgCompose.compFields.draftId);
    70                 smartIdentity._smartIdentityCollection = new vI.smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("virtualIdentityExtension_msgIdentityClone").vid, newsgroup, this._getRecipients()); 
     70                smartIdentity._smartIdentityCollection = new vI.smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("virtualIdentityExtension_msgIdentityClone").vid, newsgroup, this._getRecipients(currentWindow));
    7171                smartIdentity._smartIdentityCollection.Draft();
    7272                autocreate = false; break;
     
    9393    },
    9494   
    95     _getRecipients : function() {
     95    _getRecipients : function(currentWindow) {
    9696        var recipients = [];
    9797        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    98             var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     98            var recipientType = currentWindow.awGetPopupElement(row).selectedItem.getAttribute("value");
    9999            if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
    100                 vI.storage.__isDoBcc(row) || awGetInputElement(row).value.match(/^\s*$/) ) continue;
    101             recipients.push( { recipient: awGetInputElement(row).value, recipientType : recipientType } );
     100                vI.storage.isDoBcc(row, currentWindow) || currentWindow.awGetInputElement(row).value.match(/^\s*$/) ) continue;
     101            recipients.push( { recipient: currentWindow.awGetInputElement(row).value, recipientType : recipientType } );
    102102        }
    103103        return recipients;
  • content/vI_storage.js

    rb4293d ree9df2  
    6565            Log.debug("awSetInputAndPopupValue '" + inputElem.id + "'");
    6666            storage.original_functions.awSetInputAndPopupValue(inputElem, inputValue, popupElem, popupValue, rowNumber);
    67             storage.updateVIdentityFromStorage(inputElem, document);
    68         }
    69     },
    70        
    71     awOnBlur : function (element) {
     67            storage.__updateVIdentityFromStorage(inputElem, storage.currentWindow);
     68        }
     69    },
     70       
     71    awOnBlur : function (element, currentWindow) {
    7272        // only react on events triggered by addressCol2 - textinput Elements
    7373        if (!element || ! element.id.match(/^addressCol2*/)) return;
    7474        Log.debug("awOnBlur '" + element.id + "'");
    75         storage.updateVIdentityFromStorage(element, document);
     75    storage.__updateVIdentityFromStorage(element, currentWindow);
    7676        storage.focusedElement = null;
    7777    },
    7878
    79     awOnFocus : function (element) {
     79    awOnFocus : function (element, currentWindow) {
    8080        if (!element || ! element.id.match(/^addressCol2*/)) return;
    8181        storage.focusedElement = element;
    8282    },
    8383
    84     awPopupOnCommand : function (element) {
     84    awPopupOnCommand : function (element, currentWindow) {
    8585        Log.debug("awPopupOnCommand '" + element.id + "'");
    86         storage.updateVIdentityFromStorage(document.getElementById(element.id.replace(/^addressCol1/,"addressCol2")), document);
     86        storage.__updateVIdentityFromStorage(currentWindow.document.getElementById(element.id.replace(/^addressCol1/,"addressCol2")), currentWindow);
    8787        if (element.selectedItem.getAttribute("value") == "addr_reply") // if reply-to is manually entered disable AutoReplyToSelf
    88             document.getElementById("virtualIdentityExtension_autoReplyToSelfLabel").setAttribute("hidden", "true");
    89 
    90     },
    91    
    92   awGetPopupElement : function (row) {
    93     if (typeof awGetPopupElement === 'function')
    94       return awGetPopupElement(row);
    95     return document.getElementById("addressCol1#" + row);
    96   },
    97 
    98   awGetInputElement : function (row) {
    99     if (typeof awGetInputElement === 'function')
    100       return awGetInputElement(row);
    101     return document.getElementById("addressCol2#" + row);
    102   },
    103 
    104     initialized : null,
     88            currentWindow.document.getElementById("virtualIdentityExtension_autoReplyToSelfLabel").setAttribute("hidden", "true");
     89
     90    },
     91   
     92  initialized : null,
     93  currentWindow: null,
    10594    init: function() {
    10695        if (!storage.initialized) {
     
    112101            if (!top.MAX_RECIPIENTS || top.MAX_RECIPIENTS == 0) top.MAX_RECIPIENTS = 1;
    113102            for (var row = 1; row <= top.MAX_RECIPIENTS ; row ++) {
    114                 var input = storage.awGetInputElement(row);
     103                var input = window.awGetInputElement(row);
    115104                if (input) {
    116105                    var oldBlur = input.getAttribute("onblur")
    117106                    input.setAttribute("onblur", (oldBlur?oldBlur+"; ":"") +
    118                         "window.setTimeout(virtualIdentityExtension.storage.awOnBlur, 250, this);")
     107                        "window.setTimeout(virtualIdentityExtension.storage.awOnBlur, 250, this, window);")
    119108                    var oldFocus = input.getAttribute("onfocus")
    120109                    input.setAttribute("onfocus", (oldFocus?oldFocus+"; ":"") +
    121                         "window.setTimeout(virtualIdentityExtension.storage.awOnFocus, 250, this);")
     110                        "window.setTimeout(virtualIdentityExtension.storage.awOnFocus, 250, this, window);")
    122111                }
    123                 var popup = storage.awGetPopupElement(row);
     112                var popup = window.awGetPopupElement(row);
    124113                if (popup) {
    125114                    var oldCommand = popup.getAttribute("oncommand")
    126115                    popup.setAttribute("oncommand", (oldCommand?oldCommand+"; ":"") +
    127                         "window.setTimeout(virtualIdentityExtension.storage.awPopupOnCommand, 250, this);")
     116                        "window.setTimeout(virtualIdentityExtension.storage.awPopupOnCommand, 250, this, window);")
    128117                }
    129118            }
     119            storage.currentWindow = window;
    130120            storage.initialized = true;
    131121        }
     
    145135   
    146136    firstUsedInputElement : null,   // this stores the first Element for which a Lookup in the Storage was successfull
    147     updateVIdentityFromStorage: function(inputElement, refdocument) {
     137    __updateVIdentityFromStorage: function(inputElement, currentWindow) {
    148138        if (!vI.vIprefs.get("storage"))
    149139            { Log.debug("Storage deactivated"); return; }
    150         Log.debug("updateVIdentityFromStorage()");
    151     Log.debug(refdocument);
    152     Log.debug(refdocument.id);
    153     var recipientType = refdocument.getElementById(inputElement.id.replace(/^addressCol2/,"addressCol1"))
     140        var currentDocument = currentWindow.document;
     141    var recipientType = currentDocument.getElementById(inputElement.id.replace(/^addressCol2/,"addressCol1"))
    154142            .selectedItem.getAttribute("value");
    155143
    156144    var row = inputElement.id.replace(/^addressCol2#/,"")
    157         if (recipientType == "addr_reply" || recipientType == "addr_followup" || storage.__isDoBcc(row)) {
     145        if (recipientType == "addr_reply" || recipientType == "addr_followup" || storage.isDoBcc(row, currentWindow)) {
    158146            // reset firstUsedInputElement if recipientType was changed (and don't care about doBcc fields)
    159147            if (storage.firstUsedInputElement == inputElement)
     
    175163        // firstUsedInputElement was set before and we are not editing the same
    176164        var isNotFirstInputElement = (storage.firstUsedInputElement && storage.firstUsedInputElement != inputElement)
    177         var currentIdentity = refdocument.getElementById("virtualIdentityExtension_msgIdentityClone").identityData
     165        var currentIdentity = currentDocument.getElementById("virtualIdentityExtension_msgIdentityClone").identityData
    178166        var storageResult = storage._rdfDatasourceAccess.updateVIdentityFromStorage(inputElement.value, recipientType,
    179             currentIdentity, refdocument.getElementById("virtualIdentityExtension_msgIdentityClone").vid, isNotFirstInputElement, window);
     167            currentIdentity, currentDocument.getElementById("virtualIdentityExtension_msgIdentityClone").vid, isNotFirstInputElement, window);
    180168       
    181169        if (storageResult.identityCollection.number == 0) return; // return if there was no match
    182         Log.debug("updateVIdentityFromStorage result: " + storageResult.result);
     170        Log.debug("__updateVIdentityFromStorage result: " + storageResult.result);
    183171        // found storageData, so store InputElement
    184172        if (!storage.firstUsedInputElement) storage.firstUsedInputElement = inputElement;
     
    187175        if (storageResult.result != "equal") {
    188176            for (var j = 0; j < storageResult.identityCollection.number; j++) {
    189                 Log.debug("updateVIdentityFromStorage adding: " + storageResult.identityCollection.identityDataCollection[j].combinedName);
    190                 let menuItem = refdocument.getElementById("virtualIdentityExtension_msgIdentityClone")
     177                Log.debug("__updateVIdentityFromStorage adding: " + storageResult.identityCollection.identityDataCollection[j].combinedName);
     178                let menuItem = currentDocument.getElementById("virtualIdentityExtension_msgIdentityClone")
    191179                  .addIdentityToCloneMenu(storageResult.identityCollection.identityDataCollection[j])
    192180                if (!newMenuItem) newMenuItem = menuItem;
     
    194182        }
    195183        if (storageResult.result == "accept") {
    196             Log.debug("updateVIdentityFromStorage selecting: " + storageResult.identityCollection.identityDataCollection[0].combinedName);
    197             refdocument.getElementById("virtualIdentityExtension_msgIdentityClone").selectedMenuItem = newMenuItem;
    198             if (refdocument.getElementById("virtualIdentityExtension_msgIdentityClone").vid)
     184            Log.debug("__updateVIdentityFromStorage selecting: " + storageResult.identityCollection.identityDataCollection[0].combinedName);
     185            currentDocument.getElementById("virtualIdentityExtension_msgIdentityClone").selectedMenuItem = newMenuItem;
     186            if (currentDocument.getElementById("virtualIdentityExtension_msgIdentityClone").vid)
    199187                vI.StorageNotification.info(storage.stringBundle.GetStringFromName("vident.smartIdentity.vIStorageUsage") + ".");
    200188        }
    201189    },
    202190   
    203     __isDoBcc : function(row) {
    204         var recipientType = storage.awGetPopupElement(row).selectedItem.getAttribute("value");
     191    isDoBcc : function(row, currentWindow) {
     192        var recipientType = currentWindow.awGetPopupElement(row).selectedItem.getAttribute("value");
    205193        if (recipientType != "addr_bcc" || !getCurrentIdentity().doBcc) return false
    206194
     
    208196
    209197        for (var index = 0; index < doBccArray.count; index++ ) {
    210             if (doBccArray.StringAt(index) == storage.awGetInputElement(row).value) {
     198            if (doBccArray.StringAt(index) == currentWindow.awGetInputElement(row).value) {
    211199                Log.debug("ignoring doBcc field '" +
    212200                    doBccArray.StringAt(index));
  • content/v_identity.js

    rb4293d ree9df2  
    264264        vI.initReplyTo(window);
    265265        vI.storage.init();
    266         vI.smartIdentity.init();
     266        vI.smartIdentity.init(window);
    267267        Log.debug("initSystemStage2 done.")
    268268    },
Note: See TracChangeset for help on using the changeset viewer.