flash-messenger
A jQuery plugin provides a simple flash messages and interface.
Demo
Download
Compress JS
Compress CSS
Uncompress JS
Uncompress CSS
Installation
You can also install flash-messenger by using Bower.
bower install flash-messenger
Requirements
Usage
flash('Messange'); flash('Messange', options);
Options
success
)
type: string (default: Sets the message type, it could be: 'error', 'danger', 'info', 'notice', 'success', 'warning', 'alert' in default theme. You can call methods with the same name like flash.error()
, flash.alert()
...
3000
)
time: number (default: Sets how long the message stay in seconds.
false
)
sticky: boolean (default: Sets if the message should be sticky. The default value will be true if type is 'error' or 'danger'.
1000
)
fadeOut: number (default: Sets the duration to fade out in seconds.
true
)
closable: boolean (default: Sets the message can be closed or not.
true
)
scrollTo: boolean (default: Scroll to message position if true.
false
)
html: boolean (default: Sets the message if it can be html.
Default Setting
You can change default setting.
flash.setting = { appendTo: 'body', container: '<div class="flash-messages"></div>', message: '<div class="flash-message {type}">{message}<span class="flash-message-close">✖</span></div>', closeHandler: '.flash-message-close', default: { type: 'success', time: 3000, sticky: false, fadeOut: 1000, closable: true, scrollTo: true, html: false }, typesDefault: { error: { sticky: true }, danger: { sticky: true } } };
Example
flash('Messange'); flash('Messange', {type: 'error'}); flash.error('Message'); flash.info('Message', {sticky: true});
Custom
flash.setting.method = function (message, options) { // overwrite implementation };
License
The project is released under the MIT license.
Contact
The project's website is located at https://github.com/emn178/flash-messenger
Author: Chen, Yi-Cyuan ([email protected])