Changeset 4eb23a


Ignore:
Timestamp:
Nov 16, 2011, 11:23:31 PM (8 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
750887
Parents:
435a0f
Message:

keep reference of current window

Location:
modules
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • modules/identityDataExtras/PGPEncryption.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.PGPEncryption");
    3535
    36 function identityDataExtrasObject_PGPEncryption() {
    37     this.field  = "PGPEnc";                        // description of the option
    38     this.option = "storageExtras_openPGP_messageEncryption";    // option string to get preference settings
    39     this.elementID_msgCompose = "enigmail_encrypted_send";
    40     this.updateFunction_msgCompose = function() {
    41       (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
     36function identityDataExtrasObject_PGPEncryption(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "PGPEnc";                        // description of the option
     39  this.option = "storageExtras_openPGP_messageEncryption";    // option string to get preference settings
     40  this.elementID_msgCompose = "enigmail_encrypted_send";
     41  this.updateFunction_msgCompose = function() {
     42    (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
    4243}
    4344identityDataExtrasObject_PGPEncryption.prototype = {
  • modules/identityDataExtras/PGPMIME.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.PGPMIME");
    3535
    36 function identityDataExtrasObject_PGPMIME() {
    37     this.field  = "PGPMIME";                        // description of the option
    38     this.option = "storageExtras_openPGP_PGPMIME";    // option string to get preference settings
    39     this.elementID_msgCompose = "enigmail_sendPGPMime";
    40     this.updateFunction_msgCompose = function() {
    41       (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
     36function identityDataExtrasObject_PGPMIME(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "PGPMIME";                        // description of the option
     39  this.option = "storageExtras_openPGP_PGPMIME";    // option string to get preference settings
     40  this.elementID_msgCompose = "enigmail_sendPGPMime";
     41  this.updateFunction_msgCompose = function() {
     42    (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
    4243}
    4344identityDataExtrasObject_PGPMIME.prototype = {
  • modules/identityDataExtras/PGPSignature.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.PGPSignature");
    3535
    36 function identityDataExtrasObject_PGPSignature() {
    37     this.field  = "PGPSig";                        // description of the option
    38     this.option = "storageExtras_openPGP_messageSignature";    // option string to get preference settings
    39     this.elementID_msgCompose = "enigmail_signed_send";
    40     this.updateFunction_msgCompose = function() {
    41       (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
     36function identityDataExtrasObject_PGPSignature(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "PGPSig";                        // description of the option
     39  this.option = "storageExtras_openPGP_messageSignature";    // option string to get preference settings
     40  this.elementID_msgCompose = "enigmail_signed_send";
     41  this.updateFunction_msgCompose = function() {
     42    (typeof(enigSetMenuSettings)=='function')?enigSetMenuSettings(''):null };
    4243}
    4344identityDataExtrasObject_PGPSignature.prototype = {
  • modules/identityDataExtras/characterEncoding.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.characterEncoding");
    3535
    36 function identityDataExtrasObject_characterEncoding() {
    37     this.field  = "charEnc";                        // description of the option
    38     this.option = "storageExtras_characterEncoding";    // option string to get preference settings
     36function identityDataExtrasObject_characterEncoding(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "charEnc";                        // description of the option
     39  this.option = "storageExtras_characterEncoding";    // option string to get preference settings
    3940}
    4041identityDataExtrasObject_characterEncoding.prototype = {
     
    4344  get valueHtml() { return this.valueNice; },
    4445  get valueNice() {
    45       return this.value?this._currentWindow.gCharsetConvertManager
    46                   .getCharsetTitle(this._currentWindow.gCharsetConvertManager.getCharsetAlias(this.value)):"";
     46      return this.value?this.currentWindow.gCharsetConvertManager
     47                  .getCharsetTitle(this.currentWindow.gCharsetConvertManager.getCharsetAlias(this.value)):"";
    4748  },
    4849
    4950  _setMenuMark: function() {
    50     var maileditCharsetMenu = this._currentWindow.document.getElementById("maileditCharsetMenu")
     51    var maileditCharsetMenu = this.currentWindow.document.getElementById("maileditCharsetMenu")
    5152    var value = maileditCharsetMenu.getAttribute("unmarkedValue")
    5253    if (value) {
    53         var menuitem = this._currentWindow.document.getElementById(value);
     54        var menuitem = this.currentWindow.document.getElementById(value);
    5455        if (menuitem)
    5556          menuitem.setAttribute('checked', 'true');
     
    6162    if (!this.value)
    6263      return;
    63     var menuitem = this._currentWindow.document.getElementById(this.value);
     64    var menuitem = this.currentWindow.document.getElementById(this.value);
    6465    if (menuitem)
    6566      menuitem.setAttribute('checked', 'true');
    6667    else {  // set menumark later if menu is not ready yet
    67       var maileditCharsetMenu = this._currentWindow.document.getElementById("maileditCharsetMenu")
     68      var maileditCharsetMenu = this.currentWindow.document.getElementById("maileditCharsetMenu")
    6869      maileditCharsetMenu.setAttribute("unmarkedValue", this.value)
    6970      var onpopupshowing = maileditCharsetMenu.getAttribute("onpopupshowing")
    70       this._currentWindow.document.getElementById("maileditCharsetMenu").setAttribute("onpopupshowing",
     71      this.currentWindow.document.getElementById("maileditCharsetMenu").setAttribute("onpopupshowing",
    7172        onpopupshowing + ";this.setMenuMark();")
    7273    }
    73     this._currentWindow.gMsgCompose.compFields.characterSet = this.value;
    74     this._currentWindow.SetDocumentCharacterSet(this.value);
     74    this.currentWindow.gMsgCompose.compFields.characterSet = this.value;
     75    this.currentWindow.SetDocumentCharacterSet(this.value);
    7576  },
    7677 
    7778  setValueToEnvironment_dataEditor: function() {
    78     this._currentWindow.CreateMenu('mailedit'); // this is part of the magic included by the xul-binding
     79    this.currentWindow.CreateMenu('mailedit'); // this is part of the magic included by the xul-binding
    7980    if (this.value != null) {
    80       this._currentWindow.document.getElementById("maileditCharsetMenu").selectedItem = this._currentWindow.document.getElementById(this.value);
    81       this._currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
     81      this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem = this.currentWindow.document.getElementById(this.value);
     82      this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
    8283    }
    83     this._currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
     84    this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
    8485  },
    8586 
     
    8788    // read the value from the internal vI object, global object might not be available any more
    8889    // happens especially while storing after sending the message
    89     this.value = this._currentWindow.gMsgCompose.compFields.characterSet;
    90     if (this._currentWindow.gCharsetConvertManager) {
    91       var charsetAlias = this._currentWindow.gCharsetConvertManager.getCharsetAlias(this.value);
     90    this.value = this.currentWindow.gMsgCompose.compFields.characterSet;
     91    if (this.currentWindow.gCharsetConvertManager) {
     92      var charsetAlias = this.currentWindow.gCharsetConvertManager.getCharsetAlias(this.value);
    9293      if (charsetAlias == "us-ascii")
    9394        this.value = "ISO-8859-1";   // no menu item for "us-ascii"
     
    9697 
    9798  getValueFromEnvironment_dataEditor: function() {
    98     if (this._currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true")
     99    if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true")
    99100      // check if element is selected (list might not contain relevant entry)
    100       if (this._currentWindow.document.getElementById("maileditCharsetMenu").selectedItem)
    101         this.value = this._currentWindow.document.getElementById("maileditCharsetMenu").selectedItem.id
     101      if (this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem)
     102        this.value = this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem.id
    102103    else
    103104      this.value = null;
  • modules/identityDataExtras/fccSwitch.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.fccSwitch");
    3535
    36 function identityDataExtrasObject_fccSwitch() {
    37     this.field  = "fcc";                        // description of the option
    38     this.option = "storageExtras_fcc";    // option string to get preference settings
    39     this.elementID_msgCompose = "virtualIdentityExtension_fccSwitch";
     36function identityDataExtrasObject_fccSwitch(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "fcc";                        // description of the option
     39  this.option = "storageExtras_fcc";    // option string to get preference settings
     40  this.elementID_msgCompose = "virtualIdentityExtension_fccSwitch";
    4041}
    4142identityDataExtrasObject_fccSwitch.prototype = {
  • modules/identityDataExtras/messageFormat.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.messageFormat");
    3535
    36 function identityDataExtrasObject_messageFormat() {
    37     this.field  = "msgFormat";                        // description of the option
    38     this.option = "storageExtras_messageFormat";    // option string to get preference settings
     36function identityDataExtrasObject_messageFormat(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "msgFormat";                        // description of the option
     39  this.option = "storageExtras_messageFormat";    // option string to get preference settings
    3940}
    4041identityDataExtrasObject_messageFormat.prototype = {
     
    4445  get valueHtml() { return this.valueNice; },
    4546  get valueNice() {
    46     return this.value?this._currentWindow.document.getElementById(this.value).label:"";
     47    return this.value?this.currentWindow.document.getElementById(this.value).label:"";
    4748  },
    4849
     
    5051    if (this.value == null)
    5152      return
    52     this._currentWindow.document.getElementById(this.value).setAttribute("checked","true");
    53     OutputFormatMenuSelect(this._currentWindow.document.getElementById(this.value))
     53    this.currentWindow.document.getElementById(this.value).setAttribute("checked","true");
     54    OutputFormatMenuSelect(this.currentWindow.document.getElementById(this.value))
    5455  },
    5556 
    5657  setValueToEnvironment_dataEditor: function() {
    5758    if (this.value != null) {
    58       this._currentWindow.document.getElementById("outputFormatMenu").selectedItem = this._currentWindow.document.getElementById(this.value);
    59       this._currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
     59      this.currentWindow.document.getElementById("outputFormatMenu").selectedItem = this.currentWindow.document.getElementById(this.value);
     60      this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
    6061    }
    61     this._currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
     62    this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
    6263 },
    6364 
    6465  getValueFromEnvironment_msgCompose: function() {
    6566    const nsIMsgCompSendFormat = Components.interfaces.nsIMsgCompSendFormat;
    66     switch (this._currentWindow.gSendFormat) {
     67    switch (this.currentWindow.gSendFormat) {
    6768      case nsIMsgCompSendFormat.AskUser: this.value = "format_auto"; break;
    6869      case nsIMsgCompSendFormat.PlainText: this.value = "format_plain"; break;
     
    7374 
    7475  getValueFromEnvironment_dataEditor: function() {
    75     if (this._currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true")
    76       this.value = this._currentWindow.document.getElementById("outputFormatMenu").selectedItem.id
     76    if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true")
     77      this.value = this.currentWindow.document.getElementById("outputFormatMenu").selectedItem.id
    7778    else
    7879      this.value = null;
  • modules/identityDataExtras/returnReceipt.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.returnReceipt");
    3535
    36 function identityDataExtrasObject_ReturnReceipt() {
    37     this.field  = "receipt";                        // description of the option
    38     this.option = "storageExtras_returnReciept";    // option string to get preference settings
    39     this.elementID_msgCompose = "returnReceiptMenu";
     36function identityDataExtrasObject_ReturnReceipt(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "receipt";                        // description of the option
     39  this.option = "storageExtras_returnReciept";    // option string to get preference settings
     40  this.elementID_msgCompose = "returnReceiptMenu";
    4041}
    4142identityDataExtrasObject_ReturnReceipt.prototype = {
  • modules/identityDataExtras/sMimeEncryption.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.sMimeEncryption");
    3535
    36 function identityDataExtrasObject_sMimeEncryption() {
    37     this.field  = "sMimeEnc";                        // description of the option
    38     this.option = "storageExtras_sMime_messageEncryption";    // option string to get preference settings
    39     this.elementID_msgCompose = "menu_securityEncryptRequire1";
    40     this.updateFunction_msgCompose = function() {
    41       (typeof(setSecuritySettings)=='function')?setSecuritySettings(1):null };
     36function identityDataExtrasObject_sMimeEncryption(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "sMimeEnc";                        // description of the option
     39  this.option = "storageExtras_sMime_messageEncryption";    // option string to get preference settings
     40  this.elementID_msgCompose = "menu_securityEncryptRequire1";
     41  this.updateFunction_msgCompose = function() {
     42    (typeof(setSecuritySettings)=='function')?setSecuritySettings(1):null };
    4243}
    4344identityDataExtrasObject_sMimeEncryption.prototype = {
  • modules/identityDataExtras/sMimeSignature.js

    r435a0f r4eb23a  
    3434let Log = setupLogging("virtualIdentity.identityDataExtras.sMimeSignature");
    3535
    36 function identityDataExtrasObject_sMimeSignature() {
    37     this.field  = "sMimeSig";                        // description of the option
    38     this.option = "storageExtras_sMime_messageSignature";    // option string to get preference settings
    39     this.elementID_msgCompose = "menu_securitySign1";
    40     this.updateFunction_msgCompose = function() {
    41       (typeof(setSecuritySettings)=='function')?setSecuritySettings(1):null };
     36function identityDataExtrasObject_sMimeSignature(currentWindow) {
     37  this.currentWindow = currentWindow;
     38  this.field  = "sMimeSig";                        // description of the option
     39  this.option = "storageExtras_sMime_messageSignature";    // option string to get preference settings
     40  this.elementID_msgCompose = "menu_securitySign1";
     41  this.updateFunction_msgCompose = function() {
     42    (typeof(setSecuritySettings)=='function')?setSecuritySettings(1):null };
    4243}
    4344identityDataExtrasObject_sMimeSignature.prototype = {
  • modules/vI_identityDataExtras.js

    r435a0f r4eb23a  
    4646function identityDataExtras(rdfDatasource, resource) {
    4747  this.extras = [];
     48  let currentWindow = Cc["@mozilla.org/appshell/window-mediator;1"]
     49    .getService(Ci.nsIWindowMediator)
     50    .getMostRecentWindow(null);
    4851  for each (let [, identityDataExtrasObject] in Iterator(idExtrasObjects)) {
    49     this.extras.push(new identityDataExtrasObject());
     52    this.extras.push(new identityDataExtrasObject(currentWindow));
    5053  }
    5154  if (rdfDatasource)
     
    151154}
    152155
    153 function identityDataExtrasObject() { };
     156function identityDataExtrasObject(currentWindow) {
     157  this.currentWindow = currentWindow;
     158}
    154159identityDataExtrasObject.prototype = {
    155160  value :   null,   // will contain the current value of the object and can be accessed from outside
    156161  field :   null,   // short description of the field
    157162  option :  null,   // option from preferences, boolean
     163  window :  null,   // the current Window the object was created for
    158164 
    159165  lastCompareValue : "",
     
    186192  // function to read the value from a given identity (probably not part of identity)
    187193  readIdentityValue : function(identity) { },
    188   get _currentWindow() {
    189     return Cc["@mozilla.org/appshell/window-mediator;1"]
    190       .getService(Ci.nsIWindowMediator)
    191       .getMostRecentWindow(null);
    192   },
    193194  // function to set or read the value from/to the environment
    194195  setValueToEnvironment : function() {
    195     let id = this._currentWindow.document.documentElement.id;
     196    let id = this.currentWindow.document.documentElement.id;
    196197    switch(id) {
    197198      case "msgcomposeWindow":
     
    210211  },
    211212  getValueFromEnvironment : function() {
    212     let id = this._currentWindow.document.documentElement.id;
     213    let id = this.currentWindow.document.documentElement.id;
    213214    switch(id) {
    214215      case "msgcomposeWindow":
     
    247248
    248249
    249 function identityDataExtrasCheckboxObject() { };
     250function identityDataExtrasCheckboxObject(currentWindow) {
     251  this.currentWindow = currentWindow;
     252}
    250253identityDataExtrasCheckboxObject.prototype = {
    251254  __proto__: identityDataExtrasObject.prototype,
     
    260263
    261264  setValueToEnvironment_msgCompose: function() {
    262     var element = this._currentWindow.document.getElementById(this.elementID_msgCompose);
     265    var element = this.currentWindow.document.getElementById(this.elementID_msgCompose);
    263266    if (!this.active || (this.value == null) || !element)
    264267      return;
     
    273276  setValueToEnvironment_dataEditor: function() {
    274277    if (this.value != null) {
    275       this._currentWindow.document.getElementById("vI_" + this.option).setAttribute("checked", this.value);
    276       this._currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
    277     }
    278     this._currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
     278      this.currentWindow.document.getElementById("vI_" + this.option).setAttribute("checked", this.value);
     279      this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true");
     280    }
     281    this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand();
    279282  },
    280283 
    281284  getValueFromEnvironment_msgCompose: function() {
    282     var element = this._currentWindow.document.getElementById(this.elementID_msgCompose)
     285    var element = this.currentWindow.document.getElementById(this.elementID_msgCompose)
    283286    if (this.active && element) {
    284287      this.updateFunction_msgCompose();
     
    288291 
    289292  getValueFromEnvironment_dataEditor: function() {
    290     if (this._currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true") {
    291       var elementValue = this._currentWindow.document.getElementById("vI_" + this.option).getAttribute("checked");
     293    if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true") {
     294      var elementValue = this.currentWindow.document.getElementById("vI_" + this.option).getAttribute("checked");
    292295      this.value = (elementValue == "true")?"true":"false"
    293296    }
Note: See TracChangeset for help on using the changeset viewer.