If you want to show quick notifications in the corner of the screen (or at the bottom on mobile), you can create Admin2.Toast
objects.
The toasts all appear in a container (#toasts-container
) created when the plugin is loaded.
Creating a toast
Showing a toast to the user is pretty straight-forward:
Duration
If you want to make the toast a little longer or make it disappear more quickly, you can use the second parameter:
Default values
3 values are defined by default
Feel free to use these constants if you need. You can also override them if you need.
Note: Admin2.Toast.DURATION_MEDIUM
is used by default when you don't manually set a duration for the toast.
Transition time
The script allows for a transition before deleting the toasts when it is dismissed. You can define or override the duration of this transition
If you can to remove this delay, you can just set it to zero.
Other options
The Admin2.Toast
constructor admits a third parameter to pass some other options as an object.
Adding some styles
If you need to customize some toasts, you can either set a class
of apply some hard-coded CSS: