This is just some static backup of the original site, don't expect every link to work!

source: content/vI_rdfDataEditor.js @ 49c74e

ng_0.9
Last change on this file since 49c74e was 49c74e, checked in by rene <rene@…>, 10 years ago

extra-data was always stored, fixed this

  • Property mode set to 100644
File size: 6.5 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2    This program is free software; you can redistribute it and/or modify
3    it under the terms of the GNU General Public License as published by
4    the Free Software Foundation; either version 2 of the License, or
5    (at your option) any later version.
6
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
15
16    The Original Code is the Virtual Identity Extension.
17
18    The Initial Developer of the Original Code is Rene Ejury.
19    Portions created by the Initial Developer are Copyright (C) 2007
20    the Initial Developer. All Rights Reserved.
21
22    Contributor(s):
23 * ***** END LICENSE BLOCK ***** */
24
25Components.utils.import("resource://v_identity/vI_nameSpaceWrapper.js");
26virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
27
28Components.utils.import("resource://v_identity/vI_identityData.js", virtualIdentityExtension);
29let Log = vI.setupLogging("virtualIdentity.rdfDataEditor");
30Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension);
31
32var rdfDataEditor = {
33    __rdfDatasource : null,
34    __rdfDataTree : null,
35    __type : null,
36    __recipient : null,
37    __identityData : null,
38   
39    __populateIdentityMenu : function() {
40        var listitem = document.createElement("menuitem");
41        listitem.setAttribute("label", "");
42        document.getElementById("virtualIdentityExtension_IdentityListPopup").appendChild(listitem);
43        document.getElementById("virtualIdentityExtension_IdentityList").selectedItem = listitem;
44        var separator = document.createElement("menuseparator");
45        document.getElementById("virtualIdentityExtension_IdentityListPopup").appendChild(separator);
46
47        FillIdentityList(document.getElementById("virtualIdentityExtension_IdentityList"))
48    },
49
50    init : function() {
51        if (window.arguments[0]["recipientCol"])
52            rdfDataEditor.__recipient = window.arguments[0]["recipientCol"];
53        rdfDataEditor.__type = window.arguments[1];
54        rdfDataEditor.__rdfDatasource = window.arguments[2];
55        rdfDataEditor.__rdfDataTree = window.arguments[3];
56        ;
57        rdfDataEditor.__identityData = new vI.identityData();
58        rdfDataEditor.__identityData.copy(window.arguments[0].identityData);
59
60       
61        // set recipient
62        document.getElementById("recipient").value = rdfDataEditor.__recipient;
63       
64        // set type of entry (and populate Menu)
65        var typeMenuPopup = document.getElementById("type_menu_popup")
66        for each (var typeField in Array("email", "maillist", "newsgroup", "filter")) {
67            var menuitem = document.createElement("menuitem");
68            var label = Components.classes["@mozilla.org/intl/stringbundle;1"]
69              .getService(Components.interfaces.nsIStringBundleService)
70              .createBundle("chrome://v_identity/locale/vI_rdfDataEditor.properties")
71              .GetStringFromName("vI_rdfDataTree.dataType." + typeField);
72            menuitem.setAttribute("label", label);
73            menuitem.setAttribute("key", typeField);
74            typeMenuPopup.appendChild(menuitem);
75            if (typeField == rdfDataEditor.__type) document.getElementById("type_menu").selectedItem = menuitem
76        }
77       
78        // set sender
79        document.getElementById("sender").value = rdfDataEditor.__identityData.combinedName;
80
81        // set Identity
82        rdfDataEditor.__populateIdentityMenu();
83        var MenuItems = document.getElementById("virtualIdentityExtension_IdentityListPopup").childNodes;
84        for (var index = 0; index < MenuItems.length; index++) {
85            if (MenuItems[index].getAttribute("value") == rdfDataEditor.__identityData.id.key) {
86                document.getElementById("virtualIdentityExtension_IdentityList").selectedItem =
87                        MenuItems[index];
88                break;
89            }
90        }
91
92        // set SMTP
93        document.getElementById("virtualIdentityExtension_smtpServerListHbox").addNoneServer(); // add non (not stored) Server
94        document.getElementById("virtualIdentityExtension_smtpServerListHbox").smtp = rdfDataEditor.__identityData.smtp.keyNice;
95       
96        // set extra values
97        rdfDataEditor.__identityData.extras.setValuesToEnvironment();
98        this.hideUnusedEditorFields();
99        Log.debug("init done");
100    },
101   
102    hideUnusedEditorFields : function() {
103      var allHidden = true;
104      var hide = (document.getElementById("vI_storageExtras_hideUnusedEditorFields").getAttribute("checked") == "true")
105      rdfDataEditor.__identityData.extras.loopThroughExtras(
106        function(extra) {
107          var hidden = hide && !vI.vIprefs.get(extra.option);
108          document.getElementById("vI_" + extra.option).setAttribute("hidden", hidden)
109          document.getElementById("vI_" + extra.option + "_store").setAttribute("hidden", hidden)
110          if (!hidden) allHidden = false
111        } );
112      document.getElementById("storeValue").setAttribute("hidden", allHidden)
113      // resize the window to the content
114      window.sizeToContent();
115    },
116
117    identityExtras_adapt: function(sourceId, targetId) {
118      var checked = document.getElementById(sourceId).getAttribute("checked");
119      if (targetId) var target = document.getElementById(targetId)
120      else var target = document.getElementById(sourceId.replace(/_store/,""))
121      if (checked == "true") target.removeAttribute("disabled")
122      else target.setAttribute("disabled", "true");
123    },
124 
125    blurEvent : function(elementId) {
126        var elem = document.getElementById(elementId);
127        var localIdentityData = new vI.identityData(elem.value, null, null, null, null, null, null);
128        elem.value = localIdentityData.combinedName;                   
129    },
130   
131    accept : function() {
132        Log.debug("accept");
133        var localIdentityData = new vI.identityData(document.getElementById("sender").value, null,
134            document.getElementById("virtualIdentityExtension_IdentityList").selectedItem.getAttribute("value"),
135            document.getElementById("virtualIdentityExtension_SmtpServerList").selectedItem.getAttribute("key"));
136        localIdentityData.extras.getValuesFromEnvironment();
137        rdfDataEditor.__rdfDatasource.updateRDF(
138                document.getElementById("recipient").value,
139                document.getElementById("type_menu").selectedItem.getAttribute("key"),
140                localIdentityData,
141                true, true, rdfDataEditor.__recipient, rdfDataEditor.__type, true);
142        Log.debug("updateRDF done " + localIdentityData.extras.status());
143        return document.getElementById("type_menu").selectedItem.getAttribute("key");
144    }
145}
146vI.rdfDataEditor = rdfDataEditor;
147}});
Note: See TracBrowser for help on using the repository browser.