Changeset 509348 for modules/identityDataExtras/characterEncoding.js
- Timestamp:
- Nov 3, 2014, 12:35:40 PM (8 years ago)
- Branches:
- ng_0.9
- Children:
- 7204cb
- Parents:
- 3c9c29
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/identityDataExtras/characterEncoding.js
r3c9c29 r509348 34 34 let legacy = false; // use pre TB-32 legacy code 35 35 try { 36 36 Cu.import("resource://gre/modules/CharsetMenu.jsm"); 37 37 } catch (e) { 38 38 legacy = true; // pre TB-32-version, might be removed in the future 39 39 } 40 40 41 41 42 42 let Log = setupLogging("virtualIdentity.identityDataExtras.characterEncoding"); … … 44 44 function identityDataExtrasObject_characterEncoding(currentWindow) { 45 45 this.currentWindow = currentWindow; 46 this.field = "charEnc";// description of the option47 this.option = "storageExtras_characterEncoding"; 46 this.field = "charEnc"; // description of the option 47 this.option = "storageExtras_characterEncoding"; // option string to get preference settings 48 48 } 49 49 identityDataExtrasObject_characterEncoding.prototype = { 50 50 __proto__: identityDataExtrasObject.prototype, 51 52 get valueHtml() { return this.valueNice; }, 51 52 get valueHtml() { 53 return this.valueNice; 54 }, 53 55 get valueNice() { 54 return this.value?this.currentWindow.gCharsetConvertManager55 .getCharsetTitle(this.currentWindow.gCharsetConvertManager.getCharsetAlias(this.value)):"";56 return this.value ? this.currentWindow.gCharsetConvertManager 57 .getCharsetTitle(this.currentWindow.gCharsetConvertManager.getCharsetAlias(this.value)) : ""; 56 58 }, 57 59 58 60 // pre TB-32-version, might be removed in the future -------------------------------- 59 _setMenuMark: function () {61 _setMenuMark: function () { 60 62 var maileditCharsetMenu = this.currentWindow.document.getElementById("maileditCharsetMenu") 61 63 var value = maileditCharsetMenu.getAttribute("unmarkedValue") 62 64 if (value) { 63 64 65 66 65 var menuitem = this.currentWindow.document.getElementById(value); 66 if (menuitem) 67 menuitem.setAttribute('checked', 'true'); 68 maileditCharsetMenu.removeAttribute("unmarkedValue") 67 69 } 68 70 }, 69 71 // ---------------------------------------------------------------------------------- 70 71 setValueToEnvironment_msgCompose: function () {72 73 setValueToEnvironment_msgCompose: function () { 72 74 if (!this.value) 73 75 return; 74 76 // pre TB-32-version, might be removed in the future -------------------------------- 75 77 if (legacy) { 76 77 78 78 // old style 79 var menuitem = this.currentWindow.document.getElementById(this.value); 80 if (menuitem) 79 81 menuitem.setAttribute('checked', 'true'); 80 else {// set menumark later if menu is not ready yet82 else { // set menumark later if menu is not ready yet 81 83 var maileditCharsetMenu = this.currentWindow.document.getElementById("maileditCharsetMenu") 82 84 maileditCharsetMenu.setAttribute("unmarkedValue", this.value) 83 85 var onpopupshowing = maileditCharsetMenu.getAttribute("onpopupshowing") 84 86 this.currentWindow.document.getElementById("maileditCharsetMenu").setAttribute("onpopupshowing", 85 86 87 onpopupshowing + ";this._setMenuMark();") 88 } 87 89 } 88 90 // ---------------------------------------------------------------------------------- … … 90 92 this.currentWindow.SetDocumentCharacterSet(this.value); 91 93 }, 92 93 setValueToEnvironment_dataEditor: function () {94 95 setValueToEnvironment_dataEditor: function () { 94 96 // pre TB-32-version, might be removed in the future -------------------------------- 95 97 if (legacy) { 96 98 this.currentWindow.CreateMenu('mailedit'); // this is part of the magic included by the xul-binding 97 98 99 100 99 if (this.value != null) { 100 this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem = this.currentWindow.document.getElementById(this.value); 101 this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true"); 102 } 101 103 } 102 104 // ---------------------------------------------------------------------------------- 103 105 else { 104 105 106 107 this.currentWindow.document.getElementById("maileditCharsetMenu").setAttribute("label",CharsetMenu._getCharsetLabel(this.value));108 109 106 CharsetMenu.build(this.currentWindow.document.getElementById("charsetPopup"), false, false) 107 if (this.value != null) { 108 CharsetMenu.update(this.currentWindow.document.getElementById("maileditCharsetMenu"), this.value); 109 this.currentWindow.document.getElementById("maileditCharsetMenu").setAttribute("label", CharsetMenu._getCharsetLabel(this.value)); 110 this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true"); 111 } 110 112 } 111 113 this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand(); 112 114 }, 113 114 getValueFromEnvironment_msgCompose: function () {115 116 getValueFromEnvironment_msgCompose: function () { 115 117 // read the value from the internal vI object, global object might not be available any more 116 118 // happens especially while storing after sending the message … … 119 121 var charsetAlias = this.currentWindow.gCharsetConvertManager.getCharsetAlias(this.value); 120 122 if (charsetAlias == "us-ascii") 121 this.value = "ISO-8859-1"; 123 this.value = "ISO-8859-1"; // no menu item for "us-ascii" 122 124 } 123 125 }, 124 125 getValueFromEnvironment_dataEditor: function () {126 127 getValueFromEnvironment_dataEditor: function () { 126 128 if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true") 127 129 // check if element is selected (list might not contain relevant entry) 128 130 if (this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem) 129 131 // pre TB-32-version, might be removed in the future -------------------------------- 130 132 if (legacy) { 131 133 this.value = this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem.id 132 134 } 133 135 // ---------------------------------------------------------------------------------- 134 136 else { 135 this.value = this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem.getAttribute('charset'); 136 } 137 else 137 this.value = this.currentWindow.document.getElementById("maileditCharsetMenu").selectedItem.getAttribute('charset'); 138 } else 138 139 this.value = null; 139 140 }
Note: See TracChangeset
for help on using the changeset viewer.