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

source: content/vI_statusmenu.js @ d0fa65

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

rewrite of the interface

  • Property mode set to 100644
File size: 12.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 () {
27  with(virtualIdentityExtension.LIB) {
28
29    let Log = vI.setupLogging("virtualIdentity.statusmenu");
30
31    Components.utils.import("resource://v_identity/vI_prefs.js", virtualIdentityExtension);
32
33    var statusmenu = {
34      stringBundle: Components.classes["@mozilla.org/intl/stringbundle;1"]
35        .getService(Components.interfaces.nsIStringBundleService)
36        .createBundle("chrome://v_identity/locale/v_identity.properties"),
37
38      objStatusMenu: null,
39      objSaveBaseIDMenuItem: null,
40      objStorageSaveMenuItem: null,
41      objStatusMenuSeparator: null,
42//       objSaveSwitch: null,
43//       objSaveBaseIDSwitch: null,
44//       objSaveSMTPSwitch: null,
45//       objFccSwitch: null,
46      objStatusText: null,
47      objStatusLogo: null,
48
49      observe: function (self, subject, topic, data) {
50        //         Log.debug("statusmenu observe " + data);
51        switch (data) {
52        case "show_status":
53          statusmenu.objStatusMenu.setAttribute("hidden", !vI.vIprefs.get(data));
54          statusmenu.objStatusLogo.setAttribute("hidden", !vI.vIprefs.get(data));
55          // no break, continue like with doFcc           
56//         case "fcc_show_switch":
57//           statusmenu.objFccSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
58//           // no break, continue like with doFcc         
59//         case "doFcc":
60//           statusmenu.objFccSwitch.setAttribute("checked", vI.vIprefs.get(data));
61//           break;
62//         case "storage_show_switch":
63//           statusmenu.objSaveSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
64//           break;
65//         case "storage_show_baseID_switch":
66//           statusmenu.objSaveBaseIDSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
67//           break;
68//         case "storage_show_SMTP_switch":
69//           //                 Log.debug("changed storage_show_SMTP_switch to " + statusmenu.objSaveSMTPMenuItem + "=" + vI.vIprefs.get(data));
70//           statusmenu.objSaveSMTPSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
71//           break;
72        case "storage_store":
73          statusmenu.objStorageSaveMenuItem.setAttribute("checked", vI.vIprefs.get(data));
74          break;
75        case "storage_store_base_id":
76          statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", vI.vIprefs.get(data));
77          break;
78        case "storage_store_SMTP":
79          //                 Log.debug("changed storage_store_SMTP to " + statusmenu.objSaveSMTPMenuItem + "=" + vI.vIprefs.get(data));
80          statusmenu.objSaveSMTPMenuItem.setAttribute("checked", vI.vIprefs.get(data));
81          //                 Log.debug("changed storage_store_SMTP done");
82          break;
83        case "storage_colorIndication":
84          document.getElementById("identityHbox").setAttribute("colorize", vI.vIprefs.get(data))
85          document.getElementById("baseIDHbox").setAttribute("colorize", vI.vIprefs.get(data))
86//           document.getElementById("smtpServerHbox").setAttribute("colorize", vI.vIprefs.get(data))
87          break;
88        case "storage":
89          if (vI.vIprefs.get(data)) {
90            statusmenu.objStorageSaveMenuItem.removeAttribute("hidden");
91            statusmenu.objSaveBaseIDMenuItem.removeAttribute("hidden");
92//             statusmenu.objSaveSMTPMenuItem.removeAttribute("hidden");
93            statusmenu.objStatusMenuSeparator.removeAttribute("hidden");
94          } else {
95            statusmenu.objStorageSaveMenuItem.setAttribute("hidden", "true");
96            statusmenu.objSaveBaseIDMenuItem.setAttribute("hidden", "true");
97//             statusmenu.objSaveSMTPMenuItem.setAttribute("hidden", "true");
98            statusmenu.objStatusMenuSeparator.setAttribute("hidden", "true");
99          }
100          break;
101        }
102        statusmenu.menuConstraint(statusmenu.objStorageSaveMenuItem);
103      },
104
105      addObserver: function () {
106        vI.vIprefs.addObserver("show_status", this.observe, this);
107//         vI.vIprefs.addObserver("fcc_show_switch", this.observe, this);
108        vI.vIprefs.addObserver("doFcc", this.observe, this);
109        vI.vIprefs.addObserver("storage", this.observe, this);
110//         vI.vIprefs.addObserver("storage_show_switch", this.observe, this);
111//         vI.vIprefs.addObserver("storage_show_baseID_switch", this.observe, this);
112//         vI.vIprefs.addObserver("storage_show_SMTP_switch", this.observe, this);
113        vI.vIprefs.addObserver("storage_colorIndication", this.observe, this);
114        vI.vIprefs.addObserver("storage_store", this.observe, this);
115        vI.vIprefs.addObserver("storage_store_base_id", this.observe, this);
116//         vI.vIprefs.addObserver("storage_store_SMTP", this.observe, this);
117      },
118
119      removeObserver: function () {
120        vI.vIprefs.removeObserver("show_status", this.observe);
121//         vI.vIprefs.removeObserver("fcc_show_switch", this.observe);
122        vI.vIprefs.removeObserver("doFcc", this.observe);
123        vI.vIprefs.removeObserver("storage", this.observe);
124//         vI.vIprefs.removeObserver("storage_show_switch", this.observe);
125//         vI.vIprefs.removeObserver("storage_show_baseID_switch", this.observe);
126//         vI.vIprefs.removeObserver("storage_show_SMTP_switch", this.observe);
127        vI.vIprefs.removeObserver("storage_colorIndication", this.observe);
128        vI.vIprefs.removeObserver("storage_store", this.observe);
129        vI.vIprefs.removeObserver("storage_store_base_id", this.observe);
130//         vI.vIprefs.removeObserver("storage_store_SMTP", this.observe);
131      },
132
133      init: function () {
134        statusmenu.objStatusMenu = document.getElementById("virtualIdentityExtension_vIStatusMenu");
135        statusmenu.objStatusLogo = document.getElementById("virtualIdentityExtension_Logo");
136        statusmenu.objSaveBaseIDMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_saveBaseID");
137//         statusmenu.objSaveSMTPMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_saveSMTP");
138        statusmenu.objStorageSaveMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_save");
139        statusmenu.objStatusMenuSeparator = document.getElementById("virtualIdentityExtension_statusMenu_separator");
140//         statusmenu.objSaveSwitch = document.getElementById("virtualIdentityExtension_saveSwitch");
141//         statusmenu.objSaveBaseIDSwitch = document.getElementById("virtualIdentityExtension_saveBaseIDSwitch");
142//         statusmenu.objSaveSMTPSwitch = document.getElementById("virtualIdentityExtension_SaveSmtpSwitch");
143//         statusmenu.objFccSwitch = document.getElementById("virtualIdentityExtension_fccSwitch");
144        statusmenu.objStatusText = document.getElementById("statusText");
145        statusmenu.objStatusTooltipLine1 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine1");
146        statusmenu.objStatusTooltipLine2 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine2");
147
148        statusmenu.addObserver();
149        statusmenu.observe(this, null, null, "show_status");
150//         statusmenu.observe(this, null, null, "fcc_show_switch");
151//         statusmenu.observe(this, null, null, "storage_show_switch");
152//         statusmenu.observe(this, null, null, "storage_show_baseID_switch");
153//         statusmenu.observe(this, null, null, "storage_show_SMTP_switch");
154        statusmenu.observe(this, null, null, "storage_colorIndication");
155        statusmenu.observe(this, null, null, "storage_store_base_id");
156//         statusmenu.observe(this, null, null, "storage_store_SMTP");
157        statusmenu.observe(this, null, null, "storage_store");
158        statusmenu.observe(this, null, null, "storage");
159      },
160
161      __timeout: 5, // timeout for status messages in seconds
162      __addStatusMessage: function (save, smtp) {
163        if (vI.vIprefs.get("show_status")) {
164          var sourceString = "vident.statusText.save." + save;
165          if (smtp != "off") sourceString = sourceString + ".smtp"
166          var messageLine1 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line1");
167          var messageLine2 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line2");
168          if (!messageLine2) {
169            statusmenu.objStatusText.setAttribute("label", messageLine1);
170            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
171            statusmenu.objStatusTooltipLine2.setAttribute("hidden", "true");
172          } else {
173            statusmenu.objStatusText.setAttribute("label", messageLine1 + " " + messageLine2);
174            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
175            statusmenu.objStatusTooltipLine2.setAttribute("value", messageLine2);
176            statusmenu.objStatusTooltipLine2.removeAttribute("hidden");
177          }
178          window.setTimeout(virtualIdentityExtension.statusmenu.__clearStatusMessage, statusmenu.__timeout * 1000);
179        }
180      },
181
182      __clearStatusMessage: function () {
183        statusmenu.objStatusText.setAttribute("label", "");
184      },
185
186      changeSMTPStatus: function (elem) {
187//         statusmenu.objSaveSMTPMenuItem.setAttribute("checked", elem.getAttribute("checked"));
188        statusmenu.menuConstraint();
189      },
190
191      changeBaseIDStatus: function (elem) {
192        statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", elem.getAttribute("checked"));
193        statusmenu.menuConstraint();
194      },
195
196      changeSaveStatus: function (elem) {
197        statusmenu.objStorageSaveMenuItem.setAttribute("checked", elem.getAttribute("checked"));
198        statusmenu.menuConstraint();
199      },
200
201      menuConstraint: function () {
202        var save = "off";
203        var smtp = "off";
204        if (statusmenu.objStorageSaveMenuItem.getAttribute("checked") == "true") {
205//           statusmenu.objSaveSMTPMenuItem.removeAttribute("disabled");
206          statusmenu.objSaveBaseIDMenuItem.removeAttribute("disabled");
207          if (vI.vIprefs.get("storage")) {
208            if (statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true") save = "base";
209            else save = "ok";
210//             if (statusmenu.objSaveSMTPMenuItem.getAttribute("checked") == "true") smtp = "save";
211          }
212        } else {
213//           statusmenu.objSaveSMTPMenuItem.setAttribute("disabled", "true");
214          statusmenu.objSaveBaseIDMenuItem.setAttribute("disabled", "true");
215        }
216        statusmenu.objStatusMenu.setAttribute("save", save);
217        statusmenu.objStatusMenu.setAttribute("smtp", smtp);
218        statusmenu.__addStatusMessage(save, smtp);
219      },
220
221      clicked: function (button) {
222        if (button != 0) return; // only react on left mouse button
223        if (!vI.vIprefs.get("storage")) return;
224
225        var curSaveStatus = vI.vIprefs.get("storage_store")
226        var curSaveSMTPStatus = vI.vIprefs.get("storage_store_SMTP")
227        var curSaveBaseIDStatus = vI.vIprefs.get("storage_store_base_id")
228        var newSaveStatus = ((!curSaveStatus) || (curSaveStatus && !curSaveSMTPStatus) || (curSaveStatus && !curSaveBaseIDStatus))
229        var newSaveSMTPStatus = ((!curSaveSMTPStatus && curSaveStatus) || (curSaveBaseIDStatus && !curSaveSMTPStatus))
230        var newSaveBaseIDStatus = ((curSaveSMTPStatus && curSaveStatus && !curSaveBaseIDStatus) || (curSaveBaseIDStatus && !curSaveSMTPStatus))
231
232        vI.vIprefs.set("storage_store", newSaveStatus)
233        vI.vIprefs.set("storage_store_SMTP", newSaveSMTPStatus)
234        vI.vIprefs.set("storage_store_base_id", newSaveBaseIDStatus)
235
236        statusmenu.menuConstraint();
237      }
238    }
239    vI.statusmenu = statusmenu;
240  }
241});
Note: See TracBrowser for help on using the repository browser.