Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | |
michael@0 | 3 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 6 | |
michael@0 | 7 | <!DOCTYPE bindings [ |
michael@0 | 8 | <!ENTITY % notificationDTD SYSTEM "chrome://global/locale/notification.dtd"> |
michael@0 | 9 | %notificationDTD; |
michael@0 | 10 | ]> |
michael@0 | 11 | |
michael@0 | 12 | <bindings id="notificationBindings" |
michael@0 | 13 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 14 | xmlns:xbl="http://www.mozilla.org/xbl" |
michael@0 | 15 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 16 | |
michael@0 | 17 | <binding id="notificationbox" extends="chrome://global/content/bindings/notification.xml#notificationbox"> |
michael@0 | 18 | <content> |
michael@0 | 19 | <xul:vbox xbl:inherits="hidden=notificationshidden"> |
michael@0 | 20 | <xul:spacer/> |
michael@0 | 21 | <children includes="notification"/> |
michael@0 | 22 | </xul:vbox> |
michael@0 | 23 | <children/> |
michael@0 | 24 | </content> |
michael@0 | 25 | |
michael@0 | 26 | <implementation> |
michael@0 | 27 | <constructor><![CDATA[ |
michael@0 | 28 | let temp = {}; |
michael@0 | 29 | Cu.import("resource://services-common/observers.js", temp); |
michael@0 | 30 | temp.Observers.add("weave:notification:added", this.onNotificationAdded, this); |
michael@0 | 31 | temp.Observers.add("weave:notification:removed", this.onNotificationRemoved, this); |
michael@0 | 32 | |
michael@0 | 33 | for each (var notification in Weave.Notifications.notifications) |
michael@0 | 34 | this._appendNotification(notification); |
michael@0 | 35 | ]]></constructor> |
michael@0 | 36 | |
michael@0 | 37 | <destructor><![CDATA[ |
michael@0 | 38 | let temp = {}; |
michael@0 | 39 | Cu.import("resource://services-common/observers.js", temp); |
michael@0 | 40 | temp.Observers.remove("weave:notification:added", this.onNotificationAdded, this); |
michael@0 | 41 | temp.Observers.remove("weave:notification:removed", this.onNotificationRemoved, this); |
michael@0 | 42 | ]]></destructor> |
michael@0 | 43 | |
michael@0 | 44 | <method name="onNotificationAdded"> |
michael@0 | 45 | <parameter name="subject"/> |
michael@0 | 46 | <parameter name="data"/> |
michael@0 | 47 | <body><![CDATA[ |
michael@0 | 48 | this._appendNotification(subject); |
michael@0 | 49 | ]]></body> |
michael@0 | 50 | </method> |
michael@0 | 51 | |
michael@0 | 52 | <method name="onNotificationRemoved"> |
michael@0 | 53 | <parameter name="subject"/> |
michael@0 | 54 | <parameter name="data"/> |
michael@0 | 55 | <body><![CDATA[ |
michael@0 | 56 | // If the view of the notification hasn't been removed yet, remove it. |
michael@0 | 57 | var notifications = this.allNotifications; |
michael@0 | 58 | for each (var notification in notifications) { |
michael@0 | 59 | if (notification.notification == subject) { |
michael@0 | 60 | notification.close(); |
michael@0 | 61 | break; |
michael@0 | 62 | } |
michael@0 | 63 | } |
michael@0 | 64 | ]]></body> |
michael@0 | 65 | </method> |
michael@0 | 66 | |
michael@0 | 67 | <method name="_appendNotification"> |
michael@0 | 68 | <parameter name="notification"/> |
michael@0 | 69 | <body><![CDATA[ |
michael@0 | 70 | var node = this.appendNotification(notification.description, |
michael@0 | 71 | notification.title, |
michael@0 | 72 | notification.iconURL, |
michael@0 | 73 | notification.priority, |
michael@0 | 74 | notification.buttons); |
michael@0 | 75 | node.notification = notification; |
michael@0 | 76 | ]]></body> |
michael@0 | 77 | </method> |
michael@0 | 78 | |
michael@0 | 79 | </implementation> |
michael@0 | 80 | </binding> |
michael@0 | 81 | |
michael@0 | 82 | <binding id="notification" extends="chrome://global/content/bindings/notification.xml#notification"> |
michael@0 | 83 | <content> |
michael@0 | 84 | <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type"> |
michael@0 | 85 | <xul:toolbarbutton ondblclick="event.stopPropagation();" |
michael@0 | 86 | class="messageCloseButton close-icon tabbable" |
michael@0 | 87 | xbl:inherits="hidden=hideclose" |
michael@0 | 88 | tooltiptext="&closeNotification.tooltip;" |
michael@0 | 89 | oncommand="document.getBindingParent(this).close()"/> |
michael@0 | 90 | <xul:hbox anonid="details" align="center" flex="1"> |
michael@0 | 91 | <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/> |
michael@0 | 92 | <xul:description anonid="messageText" class="messageText" xbl:inherits="xbl:text=label"/> |
michael@0 | 93 | |
michael@0 | 94 | <!-- The children are the buttons defined by the notification. --> |
michael@0 | 95 | <xul:hbox oncommand="document.getBindingParent(this)._doButtonCommand(event);"> |
michael@0 | 96 | <children/> |
michael@0 | 97 | </xul:hbox> |
michael@0 | 98 | </xul:hbox> |
michael@0 | 99 | </xul:hbox> |
michael@0 | 100 | </content> |
michael@0 | 101 | <implementation> |
michael@0 | 102 | <!-- Note: this used to be a field, but for some reason it kept getting |
michael@0 | 103 | - reset to its default value for TabNotification elements. |
michael@0 | 104 | - As a property, that doesn't happen, even though the property stores |
michael@0 | 105 | - its value in a JS property |_notification| that is not defined |
michael@0 | 106 | - in XBL as a field or property. Maybe this is wrong, but it works. |
michael@0 | 107 | --> |
michael@0 | 108 | <property name="notification" |
michael@0 | 109 | onget="return this._notification" |
michael@0 | 110 | onset="this._notification = val; return val;"/> |
michael@0 | 111 | <method name="close"> |
michael@0 | 112 | <body><![CDATA[ |
michael@0 | 113 | Weave.Notifications.remove(this.notification); |
michael@0 | 114 | |
michael@0 | 115 | // We should be able to call the base class's close method here |
michael@0 | 116 | // to remove the notification element from the notification box, |
michael@0 | 117 | // but we can't because of bug 373652, so instead we copied its code |
michael@0 | 118 | // and execute it below. |
michael@0 | 119 | var control = this.control; |
michael@0 | 120 | if (control) |
michael@0 | 121 | control.removeNotification(this); |
michael@0 | 122 | else |
michael@0 | 123 | this.hidden = true; |
michael@0 | 124 | ]]></body> |
michael@0 | 125 | </method> |
michael@0 | 126 | </implementation> |
michael@0 | 127 | </binding> |
michael@0 | 128 | |
michael@0 | 129 | </bindings> |