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): Thunderbird Developers |
---|
23 | * ***** END LICENSE BLOCK ***** */ |
---|
24 | |
---|
25 | var vI_notificationBar = { |
---|
26 | timer : null, |
---|
27 | timeout : 5000, |
---|
28 | |
---|
29 | preferences : Components.classes["@mozilla.org/preferences-service;1"] |
---|
30 | .getService(Components.interfaces.nsIPrefService) |
---|
31 | .getBranch("extensions.virtualIdentity."), |
---|
32 | |
---|
33 | Obj_vINotification : null, |
---|
34 | |
---|
35 | init : function() { |
---|
36 | vI_notificationBar.Obj_vINotification = document.getElementById("vINotification"); |
---|
37 | }, |
---|
38 | |
---|
39 | clear : function() { |
---|
40 | // workaround, seems that my usage of notificationbox doesn't display multiple lines |
---|
41 | vI_notificationBar.Obj_vINotification.height = 0; |
---|
42 | vI_notificationBar.Obj_vINotification.removeAllNotifications(false); |
---|
43 | }, |
---|
44 | |
---|
45 | dump : function(note) { |
---|
46 | dump(note); // maybe this will be changed later, not by now ;) |
---|
47 | }, |
---|
48 | |
---|
49 | hide : function() { |
---|
50 | vI_notificationBar.timer = null; |
---|
51 | vI_notificationBar.clear() |
---|
52 | }, |
---|
53 | |
---|
54 | setNote: function(note, prefstring) { |
---|
55 | if (vI_notificationBar.Obj_vINotification) vI_notificationBar.clear(); |
---|
56 | vI_notificationBar.addNote(note, prefstring); |
---|
57 | }, |
---|
58 | |
---|
59 | addNote: function(note, prefstring) { |
---|
60 | if (!vI_notificationBar.preferences.getBoolPref(prefstring)) return; |
---|
61 | if (!vI_notificationBar.Obj_vINotification) vI_notificationBar.init(); |
---|
62 | if (vI_notificationBar.timer) window.clearTimeout(vI_notificationBar.timer); |
---|
63 | var oldNotification = vI_notificationBar.Obj_vINotification.currentNotification |
---|
64 | |
---|
65 | var newNotification; |
---|
66 | if (oldNotification) { |
---|
67 | var oldLabel = oldNotification.label |
---|
68 | vI_notificationBar.clear(); |
---|
69 | newNotification = vI_notificationBar.Obj_vINotification |
---|
70 | .appendNotification(oldLabel + note, "", "chrome://messenger/skin/icons/flag.png"); |
---|
71 | } |
---|
72 | else newNotification = vI_notificationBar.Obj_vINotification |
---|
73 | .appendNotification(note, "", "chrome://messenger/skin/icons/flag.png"); |
---|
74 | |
---|
75 | // workaround, seems that my usage of notificationbox doesn't display multiple lines |
---|
76 | vI_notificationBar.Obj_vINotification.height = newNotification.boxObject.height; |
---|
77 | |
---|
78 | if (vI_notificationBar.preferences.getIntPref("notification_timeout") != 0) |
---|
79 | vI_notificationBar.timer = window.setTimeout(vI_notificationBar.hide, |
---|
80 | vI_notificationBar.preferences.getIntPref("notification_timeout") * 1000); |
---|
81 | }, |
---|
82 | |
---|
83 | } |
---|