angular-extended-notifications
Highly customizable notifications with AngularJS
Setup
Install the library
With Bower:
bower install angular-extended-notifications
With NPM:
npm install angular-extended-notifications
Then, include the js file in your project:
<script src='bower_components/angular-extended-notifications/angular-extended-notifications.min.js' type='text/javascript'></script>
Replace bower_components
by node_modules
if necessary.
Finally, include the module in your app:
angular ;
And use the service as you wish
angular;
Documentation
Simple call
With title and message arguments:
notifications;notifications;notifications;notifications;notifications;
With a configuration object:
notifications; notifications;
Style it a little…
Change CSS classes
Configure your CSS to style special notifications:
notifications;
Display font-awesome icons
The library can use font-awesome icons:
notifications; notifications;
To always enable font-awesome icons:
notifications;
Configure it a little further…
Close button
Override the close button:
notifications;
Notification positionning
Attach the notification anywhere you want (they are prepended on body by default):
notifications; notifications;
Duration and close conditions
Change the notification duration on creation:
var notif = notifications;
Or on the fly:
notif; // 5snotif; // unlimited
Hide the notification on route or state change:
notifications;
Configure default options in config phase:
angular;
Try some more powerful stuff…
Callbacks
Trigger callbacks when the notification appears or closes:
var timestamp;notifications;
Custom actions
Add custom actions in the notification (for example a 'Dismiss' button):
var notif = notifications;
Or like GMail's cancellation:
var notif; var { notif; notif = notification;} notif = notifications; ; ;
Use a custom template
notifications; notifications;
Override the template directory:
notifications;
The data object passed as parameter is available in the templates' scope:
notifications;
See the bundled templates as examples.
Use webkitNotifications (html5 notifications)
Webkit notifications are available as described in the draft spec.
To enhance the browser compatibilities, you can include the bundled shim for Firefox 22+ if necessary.
notifications;
You can use HTMLNotifications if you want a custom template:
notifications;
To enable the webkitNotifications by default:
notifications;
and to disable:
notifications;
Tests
Pull requests are welcome!
You've seen a bug, you'd like a feature
Pull requests are welcome! (and an issue tracker is available)
License
The library "angular-extended-notifications" is freely distributable under the terms of the MIT license.
Copyright (c) 2013 Etienne Folio
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.