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

source: content/vI_statusmenu.js @ ab83a7

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

removed everything related to smtp-storage

  • Property mode set to 100644
File size: 10.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    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//       objFccSwitch: null,
45      objStatusText: null,
46      objStatusLogo: null,
47
48      observe: function (self, subject, topic, data) {
49        //         Log.debug("statusmenu observe " + data);
50        switch (data) {
51        case "show_status":
52          statusmenu.objStatusMenu.setAttribute("hidden", !vI.vIprefs.get(data));
53          statusmenu.objStatusLogo.setAttribute("hidden", !vI.vIprefs.get(data));
54          // no break, continue like with doFcc           
55//         case "fcc_show_switch":
56//           statusmenu.objFccSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
57//           // no break, continue like with doFcc         
58//         case "doFcc":
59//           statusmenu.objFccSwitch.setAttribute("checked", vI.vIprefs.get(data));
60//           break;
61//         case "storage_show_switch":
62//           statusmenu.objSaveSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
63//           break;
64//         case "storage_show_baseID_switch":
65//           statusmenu.objSaveBaseIDSwitch.setAttribute("hidden", !vI.vIprefs.get(data));
66//           break;
67        case "storage_store":
68          statusmenu.objStorageSaveMenuItem.setAttribute("checked", vI.vIprefs.get(data));
69          break;
70        case "storage_store_base_id":
71          statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", vI.vIprefs.get(data));
72          break;
73        case "storage_colorIndication":
74          document.getElementById("identityHbox").setAttribute("colorize", vI.vIprefs.get(data))
75          document.getElementById("baseIDHbox").setAttribute("colorize", vI.vIprefs.get(data))
76          break;
77        case "storage":
78          if (vI.vIprefs.get(data)) {
79            statusmenu.objStorageSaveMenuItem.removeAttribute("hidden");
80            statusmenu.objSaveBaseIDMenuItem.removeAttribute("hidden");
81            statusmenu.objStatusMenuSeparator.removeAttribute("hidden");
82          } else {
83            statusmenu.objStorageSaveMenuItem.setAttribute("hidden", "true");
84            statusmenu.objSaveBaseIDMenuItem.setAttribute("hidden", "true");
85            statusmenu.objStatusMenuSeparator.setAttribute("hidden", "true");
86          }
87          break;
88        }
89        statusmenu.menuConstraint(statusmenu.objStorageSaveMenuItem);
90      },
91
92      addObserver: function () {
93        vI.vIprefs.addObserver("show_status", this.observe, this);
94//         vI.vIprefs.addObserver("fcc_show_switch", this.observe, this);
95        vI.vIprefs.addObserver("doFcc", this.observe, this);
96        vI.vIprefs.addObserver("storage", this.observe, this);
97//         vI.vIprefs.addObserver("storage_show_switch", this.observe, this);
98//         vI.vIprefs.addObserver("storage_show_baseID_switch", this.observe, this);
99        vI.vIprefs.addObserver("storage_colorIndication", this.observe, this);
100        vI.vIprefs.addObserver("storage_store", this.observe, this);
101        vI.vIprefs.addObserver("storage_store_base_id", this.observe, this);
102      },
103
104      removeObserver: function () {
105        vI.vIprefs.removeObserver("show_status", this.observe);
106//         vI.vIprefs.removeObserver("fcc_show_switch", this.observe);
107        vI.vIprefs.removeObserver("doFcc", this.observe);
108        vI.vIprefs.removeObserver("storage", this.observe);
109//         vI.vIprefs.removeObserver("storage_show_switch", this.observe);
110//         vI.vIprefs.removeObserver("storage_show_baseID_switch", this.observe);
111        vI.vIprefs.removeObserver("storage_colorIndication", this.observe);
112        vI.vIprefs.removeObserver("storage_store", this.observe);
113        vI.vIprefs.removeObserver("storage_store_base_id", this.observe);
114      },
115
116      init: function () {
117        statusmenu.objStatusMenu = document.getElementById("virtualIdentityExtension_vIStatusMenu");
118        statusmenu.objStatusLogo = document.getElementById("virtualIdentityExtension_Logo");
119        statusmenu.objSaveBaseIDMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_saveBaseID");
120        statusmenu.objStorageSaveMenuItem = document.getElementById("virtualIdentityExtension_statusMenu_storage_save");
121        statusmenu.objStatusMenuSeparator = document.getElementById("virtualIdentityExtension_statusMenu_separator");
122//         statusmenu.objSaveSwitch = document.getElementById("virtualIdentityExtension_saveSwitch");
123//         statusmenu.objSaveBaseIDSwitch = document.getElementById("virtualIdentityExtension_saveBaseIDSwitch");
124//         statusmenu.objFccSwitch = document.getElementById("virtualIdentityExtension_fccSwitch");
125        statusmenu.objStatusText = document.getElementById("statusText");
126        statusmenu.objStatusTooltipLine1 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine1");
127        statusmenu.objStatusTooltipLine2 = document.getElementById("virtualIdentityExtension_statusMenuTooltip_StatusValueLine2");
128
129        statusmenu.addObserver();
130        statusmenu.observe(this, null, null, "show_status");
131//         statusmenu.observe(this, null, null, "fcc_show_switch");
132//         statusmenu.observe(this, null, null, "storage_show_switch");
133//         statusmenu.observe(this, null, null, "storage_show_baseID_switch");
134        statusmenu.observe(this, null, null, "storage_colorIndication");
135        statusmenu.observe(this, null, null, "storage_store_base_id");
136        statusmenu.observe(this, null, null, "storage_store");
137        statusmenu.observe(this, null, null, "storage");
138      },
139
140      __timeout: 5, // timeout for status messages in seconds
141      __addStatusMessage: function (save) {
142        if (vI.vIprefs.get("show_status")) {
143          var sourceString = "vident.statusText.save." + save;
144          var messageLine1 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line1");
145          var messageLine2 = statusmenu.stringBundle.GetStringFromName(sourceString + ".line2");
146          if (!messageLine2) {
147            statusmenu.objStatusText.setAttribute("label", messageLine1);
148            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
149            statusmenu.objStatusTooltipLine2.setAttribute("hidden", "true");
150          } else {
151            statusmenu.objStatusText.setAttribute("label", messageLine1 + " " + messageLine2);
152            statusmenu.objStatusTooltipLine1.setAttribute("value", messageLine1);
153            statusmenu.objStatusTooltipLine2.setAttribute("value", messageLine2);
154            statusmenu.objStatusTooltipLine2.removeAttribute("hidden");
155          }
156          window.setTimeout(virtualIdentityExtension.statusmenu.__clearStatusMessage, statusmenu.__timeout * 1000);
157        }
158      },
159
160      __clearStatusMessage: function () {
161        statusmenu.objStatusText.setAttribute("label", "");
162      },
163
164      changeBaseIDStatus: function (elem) {
165        statusmenu.objSaveBaseIDMenuItem.setAttribute("checked", elem.getAttribute("checked"));
166        statusmenu.menuConstraint();
167      },
168
169      changeSaveStatus: function (elem) {
170        statusmenu.objStorageSaveMenuItem.setAttribute("checked", elem.getAttribute("checked"));
171        statusmenu.menuConstraint();
172      },
173
174      menuConstraint: function () {
175        var save = "off";
176        if (statusmenu.objStorageSaveMenuItem.getAttribute("checked") == "true") {
177          statusmenu.objSaveBaseIDMenuItem.removeAttribute("disabled");
178          if (vI.vIprefs.get("storage")) {
179            if (statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true") save = "base";
180            else save = "ok";
181          }
182        } else {
183          statusmenu.objSaveBaseIDMenuItem.setAttribute("disabled", "true");
184        }
185        statusmenu.objStatusMenu.setAttribute("save", save);
186        statusmenu.__addStatusMessage(save);
187      },
188
189      clicked: function (button) {
190        if (button != 0) return; // only react on left mouse button
191        if (!vI.vIprefs.get("storage")) return;
192
193        var curSaveStatus = vI.vIprefs.get("storage_store")
194        var curSaveBaseIDStatus = vI.vIprefs.get("storage_store_base_id")
195        var newSaveStatus = ((!curSaveStatus) || (curSaveStatus && !curSaveBaseIDStatus))
196        var newSaveBaseIDStatus = (curSaveStatus && !curSaveBaseIDStatus)
197
198        vI.vIprefs.set("storage_store", newSaveStatus)
199        vI.vIprefs.set("storage_store_base_id", newSaveBaseIDStatus)
200
201        statusmenu.menuConstraint();
202      }
203    }
204    vI.statusmenu = statusmenu;
205  }
206});
Note: See TracBrowser for help on using the repository browser.