NOTE: This API is WIP! Methods might not exist at this point
new Notifications($(".notifications"))
This creates a new Notifications object with the HTML element with class notifications
Id
must be a unique id for the message (if empty a new random id is assigned)
Type
must be one of: done, success, error, ask, progress, confirm, input, select
Body
can be either a HTML node or a string
Timeout
is the time after which the message will auto-close
- If
Type
isprogress
this timer will start after the progress reaches 100% - If set to 0 the message will not auto-close
- If
Type
isconfirm
orinput
this will be always 0
Options
is an Object with extra Options
- If
Type
isinput
confirm_label
The label of the confirm buttoncancel_label
If set cancel button will be shown, the label of the cancel buttonplaceholder
If set, the value of theplaceholder
property of the input fieldtype
Default:text
, value of thetype
property of the input field- If
Type
isconfirm
confirm_label
The label of the confirm buttoncancel_label
If set cancel button will be shown, the label of the cancel button- If
Type
islist
elements
Object of elements shown{"id":"Description"}
cancel_label
If set cancel button will be shown, the label of the cancel button
Callback
will be called when the message closes.
Arguments of the callback:
event
Eitherauto
(if Timeout is up) oruser
- If
Type
isprogress, confirm, input, list
alsoaction
result
- If
Type
isconfirm
and event isaction
- Boolean if clicked on
Confirm
(true) orCancel
(false)
- Boolean if clicked on
- If
Type
isinput
and event isaction
- Content of the input box
- If
Type
islist
and event isaction
- When the cancel button is clicked:
false
- When a list item is clicked: id of the list item
- When the cancel button is clicked:
Returns an instance of Notification
Id
Id of the messageThrow
If true, throws an error if the Id is unregistered
Returns the Notification
object for Id
Id
of the message
Closes the message Id
Throws an error if the Id is unregistered
Closes all messages
Returns a random message id
Same as add(randomId(), Type, Body,{} , Timeout, Callback)
Same as add(randomId(), "confirm", Message, 0, {confirm_label,cancel_label}, Callback)
Same as add(randomId(), "prompt", Message, 0, {confirm_label,cancel_label}, Callback)
Set the notification content to Body
If Type
is progress
- Set the progress of the spinner to
Progress
- If
Progress
is 100% also triggers thesuccess
animation and timeout - If
Progress
is negative also triggers theerror
animation and timeout
Closes the message and triggers the callback