browser/base/content/sync/notification.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/sync/notification.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.9 +
    1.10 +<!DOCTYPE bindings [
    1.11 +<!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd">
    1.12 +%notificationDTD;
    1.13 +]>
    1.14 +
    1.15 +<bindings id="notificationBindings"
    1.16 +          xmlns="http://www.mozilla.org/xbl"
    1.17 +          xmlns:xbl="http://www.mozilla.org/xbl"
    1.18 +          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.19 +
    1.20 +  <binding id="notificationbox" extends="chrome://global/content/bindings/notification.xml#notificationbox">
    1.21 +    <content>
    1.22 +      <xul:vbox xbl:inherits="hidden=notificationshidden">
    1.23 +        <xul:spacer/>
    1.24 +        <children includes="notification"/>
    1.25 +      </xul:vbox>
    1.26 +      <children/>
    1.27 +    </content>
    1.28 +
    1.29 +    <implementation>
    1.30 +      <constructor><![CDATA[
    1.31 +        let temp = {};
    1.32 +        Cu.import("resource://services-common/observers.js", temp);
    1.33 +        temp.Observers.add("weave:notification:added", this.onNotificationAdded, this);
    1.34 +        temp.Observers.add("weave:notification:removed", this.onNotificationRemoved, this);
    1.35 +
    1.36 +        for each (var notification in Weave.Notifications.notifications)
    1.37 +          this._appendNotification(notification);
    1.38 +      ]]></constructor>
    1.39 +
    1.40 +      <destructor><![CDATA[
    1.41 +        let temp = {};
    1.42 +        Cu.import("resource://services-common/observers.js", temp);
    1.43 +        temp.Observers.remove("weave:notification:added", this.onNotificationAdded, this);
    1.44 +        temp.Observers.remove("weave:notification:removed", this.onNotificationRemoved, this);
    1.45 +      ]]></destructor>
    1.46 +
    1.47 +      <method name="onNotificationAdded">
    1.48 +        <parameter name="subject"/>
    1.49 +        <parameter name="data"/>
    1.50 +        <body><![CDATA[
    1.51 +          this._appendNotification(subject);
    1.52 +        ]]></body>
    1.53 +      </method>
    1.54 +
    1.55 +      <method name="onNotificationRemoved">
    1.56 +        <parameter name="subject"/>
    1.57 +        <parameter name="data"/>
    1.58 +        <body><![CDATA[
    1.59 +          // If the view of the notification hasn't been removed yet, remove it.
    1.60 +          var notifications = this.allNotifications;
    1.61 +          for each (var notification in notifications) {
    1.62 +            if (notification.notification == subject) {
    1.63 +              notification.close();
    1.64 +              break;
    1.65 +            }
    1.66 +          }
    1.67 +        ]]></body>
    1.68 +      </method>
    1.69 +
    1.70 +      <method name="_appendNotification">
    1.71 +        <parameter name="notification"/>
    1.72 +        <body><![CDATA[
    1.73 +          var node = this.appendNotification(notification.description,
    1.74 +                                             notification.title,
    1.75 +                                             notification.iconURL,
    1.76 +                                             notification.priority,
    1.77 +                                             notification.buttons);
    1.78 +          node.notification = notification;
    1.79 +        ]]></body>
    1.80 +      </method>
    1.81 +
    1.82 +    </implementation>
    1.83 +  </binding>
    1.84 +
    1.85 +  <binding id="notification" extends="chrome://global/content/bindings/notification.xml#notification">
    1.86 +    <content>
    1.87 +      <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
    1.88 +        <xul:toolbarbutton ondblclick="event.stopPropagation();"
    1.89 +                           class="messageCloseButton close-icon tabbable"
    1.90 +                           xbl:inherits="hidden=hideclose"
    1.91 +                           tooltiptext="&closeNotification.tooltip;"
    1.92 +                           oncommand="document.getBindingParent(this).close()"/>
    1.93 +        <xul:hbox anonid="details" align="center" flex="1">
    1.94 +          <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
    1.95 +          <xul:description anonid="messageText" class="messageText" xbl:inherits="xbl:text=label"/>
    1.96 +
    1.97 +          <!-- The children are the buttons defined by the notification. -->
    1.98 +          <xul:hbox oncommand="document.getBindingParent(this)._doButtonCommand(event);">
    1.99 +            <children/>
   1.100 +          </xul:hbox>
   1.101 +        </xul:hbox>
   1.102 +      </xul:hbox>
   1.103 +    </content>
   1.104 +    <implementation>
   1.105 +      <!-- Note: this used to be a field, but for some reason it kept getting
   1.106 +         - reset to its default value for TabNotification elements.
   1.107 +         - As a property, that doesn't happen, even though the property stores
   1.108 +         - its value in a JS property |_notification| that is not defined
   1.109 +         - in XBL as a field or property.  Maybe this is wrong, but it works.
   1.110 +         -->
   1.111 +      <property name="notification"
   1.112 +                onget="return this._notification"
   1.113 +                onset="this._notification = val; return val;"/>
   1.114 +      <method name="close">
   1.115 +        <body><![CDATA[
   1.116 +          Weave.Notifications.remove(this.notification);
   1.117 +
   1.118 +          // We should be able to call the base class's close method here
   1.119 +          // to remove the notification element from the notification box,
   1.120 +          // but we can't because of bug 373652, so instead we copied its code
   1.121 +          // and execute it below.
   1.122 +          var control = this.control;
   1.123 +          if (control)
   1.124 +            control.removeNotification(this);
   1.125 +          else
   1.126 +            this.hidden = true;
   1.127 +        ]]></body>
   1.128 +      </method>
   1.129 +    </implementation>
   1.130 +  </binding>
   1.131 +
   1.132 +</bindings>

mercurial