Too many different javascript notification libraries, each one with different API's... what about using all them with the same parameters and API?
That's what notification.js does: Extend the same parameters and behaviour to different notification libraries around the internet. So you can change from one to another with zero effort.
At this time notification.js supports:
- amaranJS [https://github.com/hakanersu/AmaranJS]
- jquery-toast-plugin [https://github.com/kamranahmedse/jquery-toast-plugin]
- toastr [https://github.com/CodeSeven/toastr]
Include both notification.min.js
and notification.min.css
in your document.
<script src="notification.min.js"></script>
<link href="notification.min.css" type="text/css" rel="stylesheet" media="screen">
To install the notification libraries look at the instructions on their github pages.
Demo can be found at https://github.ppizarror.com/notification.js/
NotificationJS.init({options});
Option | Type | Default | Description |
---|---|---|---|
core | string | "jquery-toast-plugin" | Notification library, avaiable: amaranjs,jquery-toast-plugin,toastr |
enabled | boolean | true | Enable/disables notifications |
exceptionTitle | string | "Exception" | Title of exception notification |
maxStack | number | 5 | Max notification stack |
timeout | number | 5000 | Notification time before hide (ms) |
- Info
NotificationJS.info(message, options);
- Success
NotificationJS.success(message, options);
- Warning
NotificationJS.warning(message, options);
- Error
NotificationJS.error(message, options);
- Exception
NotificationJS.exception(Error, options);
- Other
NotificationJS.other(message, options);
Where options:
Option | Type | Default | Description |
---|---|---|---|
persistent | boolean | false | Notification doesn't close after timeout |
closebutton | boolean | false | Show close button |
doubletime | boolean | false | Doubles timeout |
onclick | function | null | Onclick function |
- Close all notifications
NotificationJS.closeall();
- Close last notification
NotificationJS.closelast();
- Add more configurations
- Fix clearlast() method
- Add more libraries
This project is licensed under MIT [https://opensource.org/licenses/MIT]
Pablo Pizarro R. | 2018 - 2019