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

source: content/vI_rdfDataEditor.js @ 509348

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

code formatting (no code changes)

  • Property mode set to 100644
File size: 7.0 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 () {
27  with(virtualIdentityExtension.LIB) {
28
29    Components.utils.import("resource://v_identity/vI_identityData.js", virtualIdentityExtension);
30    let Log = vI.setupLogging("virtualIdentity.rdfDataEditor");
31    Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension);
32
33    var rdfDataEditor = {
34      __rdfDatasource: null,
35      __rdfDataTree: null,
36      __type: null,
37      __recipient: null,
38      __identityData: null,
39
40      __populateIdentityMenu: function () {
41        var listitem = document.createElement("menuitem");
42        listitem.setAttribute("label", "");
43        document.getElementById("virtualIdentityExtension_IdentityListPopup").appendChild(listitem);
44        document.getElementById("virtualIdentityExtension_IdentityList").selectedItem = listitem;
45        var separator = document.createElement("menuseparator");
46        document.getElementById("virtualIdentityExtension_IdentityListPopup").appendChild(separator);
47
48        FillIdentityList(document.getElementById("virtualIdentityExtension_IdentityList"))
49      },
50
51      init: function () {
52        if (window.arguments[0]["recipientCol"])
53          rdfDataEditor.__recipient = window.arguments[0]["recipientCol"];
54        rdfDataEditor.__type = window.arguments[1];
55        rdfDataEditor.__rdfDatasource = window.arguments[2];
56        rdfDataEditor.__rdfDataTree = window.arguments[3];;
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    }
146    vI.rdfDataEditor = rdfDataEditor;
147  }
148});
Note: See TracBrowser for help on using the repository browser.