LightAlertJS
A lightweight javascript notification library with customisable templates and layout in just 3kB.
Start by creating a service provider
var notificationService = $elem: ;
Then use service to create notifications
notificationService
Add an image to the notification:
notificationService
Add a class, in this case changing background and text:
notificationService notificationService notificationService notificationService notificationService notificationService
Add a debounce timer to the service, preventing the user from receiving a notification more than once per x seconds. Makes use of sessionStorage to persist timer countdown across page loads.
var notificationService = $elem: debounce_seconds: 10;
Change the template:
var notificationService = $elem: template: "<div class='notification {{class}} id='{{uid}}'><img src='{{imageUrl}}'>{{content}}</div>'";
Change whether new notifications are appended or prepended to the stack:
var notificationService = $elem: append: false;
These settings can be changed after instantiation via properties:
notificationServicedebounce_seconds = 5;
Requirements
- Bootstrap 3.3 (For default template, no CSS requirements if you provide your own)
- jQuery 1.8+