notification.xml 5.1 KB

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