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

source: chrome/content/v_identity/vI_notificationBar.xml @ 9e9bab

Last change on this file since 9e9bab was 9e9bab, checked in by root <root@…>, 15 years ago

initial import v0.4.0

  • Property mode set to 100644
File size: 12.7 KB
Line 
1<?xml version="1.0"?>
2
3<!DOCTYPE overlay [
4<!ENTITY % versionDTD SYSTEM "chrome://v_identity/content/_version.dtd">
5%versionDTD;
6<!ENTITY % vIdentDTD SYSTEM "chrome://v_identity/locale/v_identity.dtd">
7%vIdentDTD;
8]>
9
10<bindings id="notificationBindings"
11          xmlns="http://www.mozilla.org/xbl"
12          xmlns:xbl="http://www.mozilla.org/xbl"
13          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
14
15  <binding id="notificationbox">
16    <content>
17      <xul:stack xbl:inherits="hidden=notificationshidden">
18        <xul:spacer/>
19        <children includes="notification"/>
20      </xul:stack>
21      <children/>
22    </content>
23
24    <implementation>
25      <field name="PRIORITY_INFO_LOW" readonly="true">1</field>
26      <field name="PRIORITY_INFO_MEDIUM" readonly="true">2</field>
27      <field name="PRIORITY_INFO_HIGH" readonly="true">3</field>
28      <field name="PRIORITY_WARNING_LOW" readonly="true">4</field>
29      <field name="PRIORITY_WARNING_MEDIUM" readonly="true">5</field>
30      <field name="PRIORITY_WARNING_HIGH" readonly="true">6</field>
31      <field name="PRIORITY_CRITICAL_LOW" readonly="true">7</field>
32      <field name="PRIORITY_CRITICAL_MEDIUM" readonly="true">8</field>
33      <field name="PRIORITY_CRITICAL_HIGH" readonly="true">9</field>
34      <field name="PRIORITY_CRITICAL_BLOCK" readonly="true">10</field>
35
36      <field name="currentNotification">null</field>
37      <field name="slideSteps">4</field>
38
39      <field name="_timer">null</field>
40      <field name="_closedNotification">null</field>
41      <field name="_blockBox">null</field>
42
43      <property name="notificationsHidden"
44                onget="return this.getAttribute('notificationshidden') == 'true';">
45        <setter>
46          if (val)
47            this.setAttribute('notificationshidden', true);
48          else this.removeAttribute('notificationshidden');
49        </setter>
50      </property>
51
52      <property name="allNotifications" readonly="true"
53                onget="return this.getElementsByTagName('notification');"/>
54
55      <method name="getNotificationWithValue">
56        <parameter name="aValue"/>
57        <body>
58          <![CDATA[
59            var notifications = this.allNotifications;
60            for (var n = notifications.length - 1; n >= 0; n--) {
61              if (aValue == notifications[n].value)
62                return notifications[n];
63            }
64            return null;
65          ]]>
66        </body>
67      </method>
68
69      <method name="appendNotification">
70        <parameter name="aLabel"/>
71        <parameter name="aValue"/>
72        <parameter name="aImage"/>
73        <parameter name="aPriority"/>
74        <parameter name="aButtons"/>
75        <body>
76          <![CDATA[
77            if (aPriority < this.PRIORITY_INFO_LOW ||
78                aPriority > this.PRIORITY_CRITICAL_BLOCK)
79              throw "Invalid notification priority " + aPriority;
80
81            // check for where the notification should be inserted according to
82            // priority. If two are equal, the existing one appears on top.
83            var notifications = this.allNotifications;
84            var insertPos = null;
85            for (var n = notifications.length - 1; n >= 0; n--) {
86              if (notifications[n].priority < aPriority)
87                break;
88              insertPos = notifications[n];
89            }
90
91            const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
92            var newitem = document.createElementNS(XULNS, "notification");
93            newitem.setAttribute("label", aLabel);
94            newitem.setAttribute("value", aValue);
95            newitem.setAttribute("image", aImage);
96            if (!insertPos) {
97              newitem.style.position = "fixed";
98              newitem.style.top = "100%";
99            }
100            this.insertBefore(newitem, insertPos);
101
102            if (aButtons) {
103              for (var b = 0; b < aButtons.length; b++) {
104                var button = aButtons[b];
105                var buttonElem = document.createElementNS(XULNS, "button");
106                buttonElem.setAttribute("label", button.label);
107                buttonElem.setAttribute("accesskey", button.accessKey);
108
109                newitem.appendChild(buttonElem);
110                buttonElem.buttonInfo = button;
111              }
112            }
113
114            newitem.priority = aPriority;
115            if (aPriority >= this.PRIORITY_CRITICAL_LOW)
116              newitem.type = "critical";
117            else if (aPriority <= this.PRIORITY_INFO_HIGH)
118              newitem.type = "info";
119            else
120              newitem.type = "warning";
121
122            if (!insertPos)
123              this._showNotification(newitem, true);
124
125            // Fire event for accessibility APIs
126            var event = document.createEvent("Events");
127            event.initEvent("AlertActive", true, true);
128            newitem.dispatchEvent(event);
129
130            return newitem;
131          ]]>
132        </body>
133      </method>
134
135      <method name="removeNotification">
136        <parameter name="aItem"/>
137        <body>
138          <![CDATA[
139            if (aItem == this.currentNotification)
140              this.removeCurrentNotification();
141            else
142              this.removeChild(aItem);
143            return aItem;
144          ]]>
145        </body>
146      </method>
147
148      <method name="removeCurrentNotification">
149        <body>
150          <![CDATA[
151            this._showNotification(this.currentNotification, false);
152            return null;
153          ]]>
154        </body>
155      </method>
156
157      <method name="removeAllNotifications">
158        <parameter name="aImmediate"/>
159        <body>
160          <![CDATA[
161            var notifications = this.allNotifications;
162            for (var n = notifications.length - 1; n >= 0; n--) {
163              if (aImmediate)
164                this.removeChild(notifications[n]);
165              else
166                this.removeNotification(notifications[n]);
167            }
168            this.currentNotification = null;
169          ]]>
170        </body>
171      </method>
172
173      <method name="_showNotification">
174        <parameter name="aNotification"/>
175        <parameter name="aSlideIn"/>
176        <body>
177          <![CDATA[
178            if (this._timer) {
179              clearInterval(this._timer);
180              if (this.currentNotification) {
181                this.currentNotification.style.marginTop = "0px";
182                this.currentNotification.style.opacity = 1;
183              }
184              if (this._closedNotification)
185                this._closedNotification.parentNode.
186                  removeChild(this._closedNotification);
187            }
188
189            var height = aNotification.boxObject.height;
190            var change = height / this.slideSteps;
191            if (aSlideIn) {
192              if (this.currentNotification &&
193                  this.currentNotification.boxObject.height > height)
194                height = this.currentNotification.boxObject.height;
195
196              this.currentNotification = aNotification;
197              this._closedNotification = null;
198              aNotification.style.removeProperty("position");
199              aNotification.style.removeProperty("top");
200              aNotification.style.marginTop = -height + "px";
201              aNotification.style.opacity = 0;
202            }
203            else {
204              change = -change;
205              this._closedNotification = aNotification;
206              var notifications = this.allNotifications;
207              var idx = notifications.length - 2;
208              if (idx >= 0)
209                this.currentNotification = notifications[idx];
210              else
211                this.currentNotification = null;
212            }
213            var opacitychange = change / height;
214
215            var self = this;
216            var slide = function slideInFn()
217            {
218              var done = false;
219
220              var style = window.getComputedStyle(aNotification, null);
221              var margin = style.getPropertyCSSValue("margin-top").
222                             getFloatValue(CSSPrimitiveValue.CSS_PX);
223
224              if (change > 0 && margin + change >= 0) {
225                aNotification.style.marginTop = "0px";
226                aNotification.style.opacity = 1;
227                done = true;
228              }
229              else if (change < 0 && margin + change <= -height) {
230                aNotification.style.marginTop = -height + "px";
231                done = true;
232              }
233              else {
234                aNotification.style.marginTop = (margin + change).toFixed(4) + "px";
235                if (opacitychange)
236                  aNotification.style.opacity =
237                    Number(aNotification.style.opacity) + opacitychange;
238              }
239
240              if (done) {
241                clearInterval(self._timer);
242                self._timer = null;
243                if (self._closedNotification)
244                  self._closedNotification.parentNode.
245                    removeChild(self._closedNotification);
246              }
247            }
248
249            this._timer = setInterval(slide, 50);
250          ]]>
251        </body>
252      </method>
253
254    </implementation>
255  </binding>
256     
257  <binding id="notification">
258    <content>
259      <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
260        <xul:hbox anonid="details" align="center" flex="1"
261                  oncommand="this.parentNode.parentNode._doButtonCommand(event);">
262          <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
263          <xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
264          <xul:spacer flex="1"/>
265          <children/>
266        </xul:hbox>
267        <xul:vbox><xul:spacer flex="1" /><xul:label class="v_identity_logo vINotificationLogo"
268            value="&vident.compose.vidLogo.label; &vident.version;" align="right" />
269        <xul:spacer flex="1" /></xul:vbox>
270        <xul:toolbarbutton ondblclick="event.stopPropagation();"
271                           class="messageCloseButton"
272                           xbl:inherits="hidden=hideclose"
273                           oncommand="vI_notificationBar.clear();"/>
274      </xul:hbox>
275    </content>
276    <resources>
277      <stylesheet src="chrome://global/skin/notification.css"/>
278    </resources>
279    <implementation implements="nsIAccessibleProvider">
280      <property name="accessible" readonly="true">
281        <getter>
282          <![CDATA[
283            var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
284            return accService.createXULAlertAccessible(this);
285          ]]>
286        </getter>
287      </property>
288
289      <property name="label" onset="return this.setAttribute('label', val);"
290                             onget="return this.getAttribute('label');"/>
291      <property name="value" onset="return this.setAttribute('value', val);"
292                             onget="return this.getAttribute('value');"/>
293      <property name="image" onset="return this.setAttribute('image', val);"
294                             onget="return this.getAttribute('image');"/>
295      <property name="type" onget="return this.getAttribute('type');"
296                            onset="this.setAttribute('type', val); return val;"/>
297      <property name="priority" onget="return this.getAttribute('priority');"
298                                onset="this.setAttribute('priority', val); return val;"/>
299
300      <property name="control" readonly="true">
301        <getter>
302          <![CDATA[
303            var parent = this.parentNode;
304            while (parent) {
305              if (parent.localName == "notificationbox")
306                return parent;
307              parent = parent.parentNode;
308            }
309            return null;
310          ]]>
311        </getter>
312      </property>
313
314      <method name="close">
315        <body>
316          <![CDATA[
317            var control = this.control;
318            if (control)
319              control.removeNotification(this);
320            else
321              this.hidden = true;
322          ]]>
323        </body>
324      </method>
325
326      <method name="_doButtonCommand">
327        <parameter name="aEvent"/>
328        <body>
329          <![CDATA[
330            if (!("buttonInfo" in aEvent.target))
331              return;
332
333            var button = aEvent.target.buttonInfo;
334            if (button.popup) {
335              document.getElementById(button.popup).
336                showPopup(aEvent.originalTarget, -1, -1, "popup", "bottomleft", "topleft");
337              aEvent.stopPropagation();
338            }
339            else {
340              var callback = button.callback;
341              if (callback) {
342                var result = callback(this, button);
343                if (!result)
344                  this.close();
345                aEvent.stopPropagation();
346              }
347            }
348          ]]>
349        </body>
350      </method>
351    </implementation>
352  </binding>
353</bindings>
Note: See TracBrowser for help on using the repository browser.