Bug 1505288 - adapt comm-central to notification box for changes in bug 1471403 (Migrate <notificationbox> to a JS class). r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sun, 11 Nov 2018 15:25:05 +0200
changeset 33697 d55eedb42e086de9afcbdbe64d60435ce6ba4f6b
parent 33696 4020b651ce70ee7076ae1be6e035f6c9c7ecb840
child 33698 1499532bcad2f634b09bf111917795a907cc0984
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersjorgk
bugs1505288, 1471403
Bug 1505288 - adapt comm-central to notification box for changes in bug 1471403 (Migrate <notificationbox> to a JS class). r=jorgk - calendarCreation.xul was still using the toolkit notificationbox binding - notification changed a bit, so easiest to copy that binding too and de-XBL it at the same time as comm-central notificationbox
calendar/resources/content/calendarCreation.xul
common/bindings/notificationbox.xml
mail/base/content/bindings.css
--- a/calendar/resources/content/calendarCreation.xul
+++ b/calendar/resources/content/calendarCreation.xul
@@ -1,14 +1,15 @@
 <?xml version="1.0"?>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://messenger/content/bindings.css" type="text/css"?>
 <?xml-stylesheet href="chrome://calendar-common/skin/calendar-creation-wizard.css" type="text/css"?>
 
 <!DOCTYPE dialog [
   <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/calendarCreation.dtd" > %dtd1;
   <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
 ]>
 
 <wizard id="calendar-wizard"
--- a/common/bindings/notificationbox.xml
+++ b/common/bindings/notificationbox.xml
@@ -391,9 +391,108 @@
       <handler event="transitionend"><![CDATA[
         if (event.target.localName == "notification" &&
             event.propertyName == "margin-top")
           this._finishAnimation();
       ]]></handler>
     </handlers>
 
   </binding>
+
+  <binding id="notification">
+    <content>
+      <xul:hbox anonid="details" align="center" flex="1"
+                oncommand="this.parentNode._doButtonCommand(event);">
+        <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image,type,value"/>
+        <xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
+        <xul:spacer flex="1"/>
+        <children/>
+      </xul:hbox>
+      <xul:toolbarbutton ondblclick="event.stopPropagation();"
+                         class="messageCloseButton close-icon tabbable"
+                         anonid="close-button"
+                         xbl:inherits="hidden=hideclose"
+                         tooltiptext="&closeNotification.tooltip;"
+                         oncommand="document.getBindingParent(this).dismiss();"/>
+    </content>
+    <implementation>
+      <property name="label" onset="this.setAttribute('label', val); return val;"
+                             onget="return this.getAttribute('label');"/>
+      <property name="value" onset="this.setAttribute('value', val); return val;"
+                             onget="return this.getAttribute('value');"/>
+      <property name="image" onset="this.setAttribute('image', val); return val;"
+                             onget="return this.getAttribute('image');"/>
+      <property name="type" onset="this.setAttribute('type', val); return val;"
+                            onget="return this.getAttribute('type');"/>
+      <property name="priority" onget="return parseInt(this.getAttribute('priority')) || 0;"
+                                onset="this.setAttribute('priority', val); return val;"/>
+      <property name="persistence" onget="return parseInt(this.getAttribute('persistence')) || 0;"
+                                   onset="this.setAttribute('persistence', val); return val;"/>
+      <field name="timeout">0</field>
+
+      <property name="control" readonly="true">
+        <getter>
+          <![CDATA[
+            var parent = this.parentNode;
+            while (parent) {
+              if (parent.localName == "notificationbox")
+                return parent;
+              parent = parent.parentNode;
+            }
+            return null;
+          ]]>
+        </getter>
+      </property>
+
+      <!-- This method should only be called when the user has
+           manually closed the notification. If you want to
+           programmatically close the notification, you should
+           call close() instead. -->
+      <method name="dismiss">
+        <body>
+          <![CDATA[
+            if (this.eventCallback) {
+              this.eventCallback("dismissed");
+            }
+            this.close();
+          ]]>
+        </body>
+      </method>
+
+      <method name="close">
+        <body>
+          <![CDATA[
+            var control = this.control;
+            if (control)
+              control.removeNotification(this);
+            else
+              this.hidden = true;
+          ]]>
+        </body>
+      </method>
+
+      <method name="_doButtonCommand">
+        <parameter name="aEvent"/>
+        <body>
+          <![CDATA[
+            if (!("buttonInfo" in aEvent.target))
+              return;
+
+            var button = aEvent.target.buttonInfo;
+            if (button.popup) {
+              document.getElementById(button.popup).
+                openPopup(aEvent.originalTarget, "after_start", 0, 0, false, false, aEvent);
+              aEvent.stopPropagation();
+            } else {
+              var callback = button.callback;
+              if (callback) {
+                var result = callback(this, button, aEvent.target, aEvent);
+                if (!result)
+                  this.close();
+                aEvent.stopPropagation();
+              }
+            }
+          ]]>
+        </body>
+      </method>
+    </implementation>
+  </binding>
 </bindings>
--- a/mail/base/content/bindings.css
+++ b/mail/base/content/bindings.css
@@ -42,16 +42,23 @@ toolbarpaletteitem[place="palette"] {
   -moz-box-orient: vertical;
   -moz-binding: url("chrome://messenger/content/toolbar.xml#toolbarpaletteitem-palette");
 }
 
 notificationbox {
   -moz-binding: url("chrome://messenger/content/notificationbox.xml#notificationbox");
   -moz-box-orient: vertical;
 }
+.notificationbox-stack {
+  overflow: -moz-hidden-unscrollable;
+}
+
+notification {
+  -moz-binding: url("chrome://messenger/content/notificationbox.xml#notification");
+}
 
 button[type="menu-button"] {
   -moz-binding: url("chrome://messenger/content/menubutton.xml#menu-button");
 }
 
 menulist[type="description"] {
   -moz-binding: url("chrome://messenger/content/mailWidgets.xml#menulist-description");
 }