ppizarror / notification.js

Notification wrapper that offers an common interface to many javascript notification libraries around there

Home Page:https://github.ppizarror.com/notification.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

notification.js

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.

Libraries supported

At this time notification.js supports:

Setup

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.

Usage

Demo can be found at https://github.ppizarror.com/notification.js/

Init the notification manager

NotificationJS.init({options});

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)

API

Notification

  • 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

Other methods

  • Close all notifications
NotificationJS.closeall();
  • Close last notification
NotificationJS.closelast();

TO-DO

  • Add more configurations
  • Fix clearlast() method
  • Add more libraries

License

This project is licensed under MIT [https://opensource.org/licenses/MIT]

Author

Pablo Pizarro R. | 2018 - 2019

About

Notification wrapper that offers an common interface to many javascript notification libraries around there

https://github.ppizarror.com/notification.js

License:MIT License


Languages

Language:JavaScript 74.6%Language:CSS 13.2%Language:HTML 10.9%Language:Python 1.3%