require(["deliteful/Toaster"], function (Toaster) {
new Toaster();
});
Toaster widget. Displays instances of ToasterMessage
.
Messages are posted through postMessage
, which takes either
a full ToasterMessage
instance or a message as a string.
ToasterMessage
instances are displayed for a finite or infinite duration.
(see the duration
property of ToasterMessage
).
Example
<d-toaster id="t"></d-toaster>
<d-button onclick="t.postMessage('button clicked', {duration: 1000})">...</d-button>
Extends
- delite/Widget
Members
-
<static> animationEndClass :string
-
A CSS class which is inserted after
animationQuitClass
has completed.If no
transitionend
oranimationend
event is heard, this class is never inserted.Type:
- string
- Default Value:
- "d-toaster-fadefinish"
- Source:
-
<static> animationEnterClass :string
-
A CSS class which is inserted to make the message visible in DOM (ex: a fade-in CSS transition). It is removed as soon as the animation has completed.
If no
transitionend
oranimationend
event is heard, this class is never removed.Type:
- string
- Default Value:
- "d-toaster-fadein"
- Source:
-
<static> animationInitialClass :string
-
A CSS class which is added to each message inserted in the DOM without being visible yet.
It is toggled to
animationEnterClass
. This class is useful when you want to set an initial state foranimationEnterClass
.Type:
- string
- Default Value:
- "d-toaster-initial"
- Source:
-
<static> animationQuitClass :string
-
A CSS class which is inserted to make the message invisible in DOM (ex: a fade-out CSS transition). It is toggled to
animationQuitClass
when the animation has completed.If no
transitionend
oranimationend
event is heard, this class is never removed.Type:
- string
- Default Value:
- "d-toaster-fadeout"
- Source:
-
<static> invertOrder :boolean
-
If
true
, the messages are displayed bottom to top.Type:
- boolean
- Default Value:
- false
- Source:
-
<static> messages :Array.<module:deliteful/ToasterMessage>
-
A list containing all
ToasterMessage
instances posted.Type:
- Array.<module:deliteful/ToasterMessage>
- Default Value:
- null
- Source:
-
<static> placementClass :string
-
The name of the CSS class that specifies the placement of toaster's messages.
The toaster comes with 7 classes which can be used out-of-the-box.
d-toaster-placement-default
for the default positiond-toaster-placement-tl
for top-leftd-toaster-placement-tc
for top-centerd-toaster-placement-tr
for top-rightd-toaster-placement-bl
for bottom-leftd-toaster-placement-bc
for bottom-centerd-toaster-placement-br
for bottom-right
This property can be set to any string as long as it references the name of a CSS class properly defined.
Type:
- string
- Default Value:
- `d-toaster-placement-default`
- Source:
Methods
-
<static> postMessage(message, props) → {module:deliteful/ToasterMessage}
-
Posts a message in the toaster.
The message can be either a full
ToasterMessage
instance or a simple string, in which case the proprieties of the message are specified through theprops
argument which is passed to theToasterMessage
constructor.Parameters:
Name Type Argument Description message
string | module:deliteful/ToasterMessage Either the content of the message as a string or an instance of
deliteful/ToasterMessage
.props
Object <optional>
A hash used to initialize a message instance (only relevant when
message
passed is a string).Returns:
The message instance passed as a parameter or created from the string.