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
Typeisprogressthis timer will start after the progress reaches 100% - If set to 0 the message will not auto-close
- If
Typeisconfirmorinputthis will be always 0
Options is an Object with extra Options
- If
Typeisinput confirm_labelThe label of the confirm buttoncancel_labelIf set cancel button will be shown, the label of the cancel buttonplaceholderIf set, the value of theplaceholderproperty of the input fieldtypeDefault:text, value of thetypeproperty of the input field- If
Typeisconfirm confirm_labelThe label of the confirm buttoncancel_labelIf set cancel button will be shown, the label of the cancel button- If
Typeislist elementsObject of elements shown{"id":"Description"}cancel_labelIf set cancel button will be shown, the label of the cancel button
Callback will be called when the message closes.
Arguments of the callback:
eventEitherauto(if Timeout is up) oruser- If
Typeisprogress, confirm, input, listalsoaction result- If
Typeisconfirmand event isaction- Boolean if clicked on
Confirm(true) orCancel(false)
- Boolean if clicked on
- If
Typeisinputand event isaction- Content of the input box
- If
Typeislistand 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
IdId of the messageThrowIf true, throws an error if the Id is unregistered
Returns the Notification object for Id
Idof 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
Progressis 100% also triggers thesuccessanimation and timeout - If
Progressis negative also triggers theerroranimation and timeout
Closes the message and triggers the callback