XUL:NotificationBox: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== <notificationbox> ==
= <notificationbox> =


'''<code>&lt;notificationbox&gt;</code>''' is used to display notifications above an element. Typically the element will be a browser, but any element may be used. The &lt;notification&gt; element is used for each notification, and will be created automatically for each item. Each notification will slide in and out as needed.
'''<code>&lt;notificationbox&gt;</code>''' is used to display notifications above an element. Typically the element will be a browser, but any element may be used. The &lt;notification&gt; element is used for each notification, and will be created automatically for each item. Each notification will slide in and out as needed.


The notification box is a vertical box which may have children. The notifications appear at the top of the box. The notifications may be placed at the bottom setting the dir attribute to reverse.
The notification box is a vertical box which may have children. The notifications appear at the top of the box. The notifications may be placed at the bottom by setting the <code>dir</code> attribute to <code>"reverse"</code>.


== XUL Syntax ==
== XUL Syntax ==
Line 9: Line 9:
   <browser src="<nowiki>http://www.mozilla.org</nowiki>"/>
   <browser src="<nowiki>http://www.mozilla.org</nowiki>"/>
  </notificationbox>
  </notificationbox>
== Priority Levels ==
Notifications with higher priority levels appear above those with lower priorities.
; PRIORITY_INFO_LOW
; PRIORITY_INFO_MEDIUM
; PRIORITY_INFO_HIGH
; PRIORITY_WARNING_LOW
; PRIORITY_WARNING_MEDIUM
; PRIORITY_WARNING_HIGH
; PRIORITY_CRITICAL_LOW
; PRIORITY_CRITICAL_MEDIUM
; PRIORITY_CRITICAL_HIGH
; PRIORITY_CRITICAL_BLOCK


== Properties ==
== Properties ==


; currentItem : The currently displayed notification
; currentNotification : The currently displayed notification. (Needs a more elaborate description.)
; allItems : NodeList of all notifications
; allNotifications : ''readonly'' NodeList of all notifications
; notificationsHidden : boolean indicating whether the notification area should be hidden


== Methods ==
== Methods ==


; appendItem( priority , label , value , image , buttons ) : Create a new notification and display it. If another notification is already present with a higher priority, the new notification will be added behind it. This method returns the notification.
; appendNotification( label , value , image , priority , buttons ) : Create a new notification and display it. If another notification is already present with a higher priority, the new notification will be added behind it. This method returns the notification.
 
  Arguments:
    priority - notification priority
    label - label to appear on the notification
    value - value used to identify the notification
    image - url of image to appear on the notification
    buttons - array of buttons to appear on the notification
; getItemWithValue ( value ) : Retrieve the notification with a particular value. The value is specified when adding the notification with appendItem.
; removeAllItems ( immediate ) : Remove all notifications. If immediate is true, the messages are removed immediately. If immediate is false, the notification is slid away.
; removeCurrentItem ( ) : Remove the current notification
; removeItem( item ) : Remove a notification, displaying the next one if the removed item is the current one
 
The buttons argument to appendItem is an array of button descriptions. Each description is an object of the following form:


<pre>
: Arguments:
button {
:* <code>label</code> - label to appear on the notification
  accesskey,
:* <code>value</code> - value used to identify the notification
  callback,
:* <code>image</code> - URL of image to appear on the notification
  label,
:* <code>priority</code> - notification priority, see [[#Priority Levels|Priority Levels]].
  popup
:* <code>buttons</code> - array of button descriptions to appear on the notification, see below for details.
}
; getNotificationWithValue ( value ) : Retrieve the notification with a particular value. The value is specified when adding the notification with appendNotification.
</pre>
; removeAllNotifications ( immediate ) : Remove all notifications. If immediate is true, the messages are removed immediately. If immediate is false, the notification is slid away.
; removeCurrentNotification ( ) : Remove the current notification
; removeNotification( item ) : Remove a notification, displaying the next one if the removed item is the current one


accesskey - the accesskey to appear on the button
=== Button Descriptions ===
callback - function to be called when the button is activated.
The <code>buttons</code> argument to <code>appendNotification</code> is an array of button descriptions. Each description is an object with the following properties:
            This function is passed two arguments, the &lt;notification&gt;
* accesskey - the accesskey to appear on the button
            the button is associated with and the button description.
* callback - function to be called when the button is activated. This function is passed two arguments:
label - the label to appear on the button
** the &lt;notification&gt; the button is associated with
popup - the id of a popup for the button. If null, the button is a button popup.
** the button description as passed to <code>appendNotification</code>.
* label - the label to appear on the button
* popup - the id of a popup for the button. If <code>null</code>, the button is a button popup.


== &lt;notification&gt; ==
= &lt;notification&gt; =


'''<code>&lt;notification&gt;</code>''' is used to display an informative message. It will
'''<code>&lt;notification&gt;</code>''' is used to display an informative message. It will
Line 78: Line 55:
; image : URL of an image to appear on the notification.
; image : URL of an image to appear on the notification.
; label : The label displayed on the notification.
; label : The label displayed on the notification.
; priority : The message priority, used by the enclosing &lt;notificationbox&gt;
; priority : The message priority, used by the enclosing &lt;notificationbox&gt;. See [[#Priority Levels|Priority Levels]].
; type : Notification type. There are three types, which specify the importance of the notification.
; type : Notification type (string). There are three types, which specify the importance of the notification.
  info - informative message
:* "info" - informative message
  warning - warning message
:* "warning" - warning message
  critical - critical message
:* "critical" - critical message
; value : A value associated with the notification.
; value : A value associated with the notification.


== Methods ==
== Methods ==


; close : Closes the notification and removes it from its enclosing &lt;notificationbox&gt;
; close ( ) : Closes the notification and removes it from its enclosing &lt;notificationbox&gt;
 
= Priority Levels =
 
Notifications with higher priority levels appear above those with lower priorities. These constants are defined on the notificationbox binding and can be obtained from any <notificationbox> element.
 
; PRIORITY_INFO_LOW
; PRIORITY_INFO_MEDIUM
; PRIORITY_INFO_HIGH
; PRIORITY_WARNING_LOW
; PRIORITY_WARNING_MEDIUM
; PRIORITY_WARNING_HIGH
; PRIORITY_CRITICAL_LOW
; PRIORITY_CRITICAL_MEDIUM
; PRIORITY_CRITICAL_HIGH
; PRIORITY_CRITICAL_BLOCK

Latest revision as of 17:03, 9 August 2006

<notificationbox>

<notificationbox> is used to display notifications above an element. Typically the element will be a browser, but any element may be used. The <notification> element is used for each notification, and will be created automatically for each item. Each notification will slide in and out as needed.

The notification box is a vertical box which may have children. The notifications appear at the top of the box. The notifications may be placed at the bottom by setting the dir attribute to "reverse".

XUL Syntax

<notificationbox flex="1">
  <browser src="http://www.mozilla.org"/>
</notificationbox>

Properties

currentNotification
The currently displayed notification. (Needs a more elaborate description.)
allNotifications
readonly NodeList of all notifications
notificationsHidden
boolean indicating whether the notification area should be hidden

Methods

appendNotification( label , value , image , priority , buttons )
Create a new notification and display it. If another notification is already present with a higher priority, the new notification will be added behind it. This method returns the notification.
Arguments:
  • label - label to appear on the notification
  • value - value used to identify the notification
  • image - URL of image to appear on the notification
  • priority - notification priority, see Priority Levels.
  • buttons - array of button descriptions to appear on the notification, see below for details.
getNotificationWithValue ( value )
Retrieve the notification with a particular value. The value is specified when adding the notification with appendNotification.
removeAllNotifications ( immediate )
Remove all notifications. If immediate is true, the messages are removed immediately. If immediate is false, the notification is slid away.
removeCurrentNotification ( )
Remove the current notification
removeNotification( item )
Remove a notification, displaying the next one if the removed item is the current one

Button Descriptions

The buttons argument to appendNotification is an array of button descriptions. Each description is an object with the following properties:

  • accesskey - the accesskey to appear on the button
  • callback - function to be called when the button is activated. This function is passed two arguments:
    • the <notification> the button is associated with
    • the button description as passed to appendNotification.
  • label - the label to appear on the button
  • popup - the id of a popup for the button. If null, the button is a button popup.

<notification>

<notification> is used to display an informative message. It will normally be used as part of a <notificationbox>.

XUL Syntax

<notification label="This is a warning"/>

Properties

accessible
Returns the accessibility object for the notification.
control
The enclosing <notificationbox> if any.
image
URL of an image to appear on the notification.
label
The label displayed on the notification.
priority
The message priority, used by the enclosing <notificationbox>. See Priority Levels.
type
Notification type (string). There are three types, which specify the importance of the notification.
  • "info" - informative message
  • "warning" - warning message
  • "critical" - critical message
value
A value associated with the notification.

Methods

close ( )
Closes the notification and removes it from its enclosing <notificationbox>

Priority Levels

Notifications with higher priority levels appear above those with lower priorities. These constants are defined on the notificationbox binding and can be obtained from any <notificationbox> element.

PRIORITY_INFO_LOW
PRIORITY_INFO_MEDIUM
PRIORITY_INFO_HIGH
PRIORITY_WARNING_LOW
PRIORITY_WARNING_MEDIUM
PRIORITY_WARNING_HIGH
PRIORITY_CRITICAL_LOW
PRIORITY_CRITICAL_MEDIUM
PRIORITY_CRITICAL_HIGH
PRIORITY_CRITICAL_BLOCK