Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
angular-extended-notifications
Advanced tools
Highly customizable notifications with AngularJS
With Bower:
bower install angular-extended-notifications
With NPM:
npm install angular-extended-notifications
<script src='bower_components/angular-extended-notifications/angular-extended-notifications.min.js' type='text/javascript'></script>
Replace bower_components
by node_modules
if necessary.
angular.module('my-project', [
// [...]
'angular-extended-notifications'
])
.config(function (notificationsProvider) {
// change default options (that can be overridden in a specific call later if necessary)
notificationsProvider.setDefaults({
// set the directory containing the html templates
templatesDir: 'node_modules/angular-extended-notifications/templates/',
// use font-awesome icons
faIcons: true,
// close notifications on route change
closeOnRouteChange: 'route' // or 'state' using uiRouter…
});
});
And use the service as you wish
angular.module('my-project').controller('my-controller', function(notifications) {
'use strict';
// use notifications
});
With title and message arguments:
notifications.info('Hello title', 'Message to the world!');
notifications.warning('Hello title', 'Message to the world!');
notifications.error('Hello title', 'Message to the world!');
notifications.success('Hello title', 'Message to the world!');
notifications.info('Hello title', 'Message to the world!');
With a configuration object:
notifications.info({
title: 'Hello title',
message: 'Message to the world!'
});
notifications.notify({
type: 'info'
title: 'Hello title',
message: 'Message to the world!'
});
Configure your CSS to style special notifications:
notifications.info('Hello title', 'Message to the world!', {
className: 'custom-class'
});
The library can use font-awesome icons:
notifications.info('Hello title', 'Message to the world!', {
faIcon: false // no icon
});
notifications.info('Hello title', 'Message to the world!', {
faIcon: 'fa-heart' // with a different icon
});
To always enable font-awesome icons:
notifications.setDefaults({faIcons: true});
Override the close button:
notifications.info('Hello title', 'Message to the world!', {
closeButton: false
});
Attach the notification anywhere you want (they are prepended on body by default):
notifications.info('Hello title', 'Message to the world!', {
attachTo: $('#my-div') // prepend
});
notifications.info('Hello title', 'Message to the world!', {
// describe how you want to attach the template by yourself
attachTo: function(template) {
$myDiv.append(template);
}
});
Change the notification duration on creation:
var notif = notifications.info('Hello title', 'Message to the world!', {
duration: 10000 // 10s
});
Or on the fly:
notif.changeDuration(5000); // 5s
notif.changeDuration(-1); // unlimited
Hide the notification on route or state change:
notifications.info('Hello title', 'Message to the world!', {
closeOnRouteChange: 'route' // use angular's router (would have been 'state' for uiRouter)
});
angular.config(function (notificationsProvider) {
notificationsProvider
// change default options (that can be overridden in a specific call later if necessary)
.setDefaults({
// -- any valid options like: --
faIcon: true
})
.setFaIcons({
// set one or many custom icons: info, success, error, warning
success: 'fa-heart'
})
;
});
Trigger callbacks when the notification appears or closes:
var timestamp;
notifications.info('Hello title', 'Message to the world!', {
show: function () {
console.log('The notification appears');
timestamp = +new Date();
},
close: function () {
var time = (+new Date() - timestamp) / 1000;
console.log('The notification was shown ' + time + 's')
return false; // by returning false, I can cancel the closing of the notification to let it open (if I changed my mind…)
}
});
Add custom actions in the notification (for example a 'Dismiss' button):
var notif = notifications.info('Hello title', 'Message to the world!', {
actions: [{
label: 'Dismiss',
fn: function () {
console.log('This function executes when you click on 'Dismiss'');
notif.close();
}
}]
});
Or like GMail's cancellation:
var notif;
var onError = function(err) {
notif.close();
notif = notification.error({
title: 'Error (' + err.code + ')'
message: err.message,
duration: -1
});
}
notif = notifications.info({
message: 'Sending…',
duration: -1,
actions: [{
label: 'Cancel',
fn: function () {
notif.close();
notif = notifications.warning({
message: 'Cancelling…',
duration: -1,
});
DoTheCancelling()
.then(function () {
notif.close();
notif = notifications.success({
message: 'Cancelled !'
});
})
.catch(onError)
;
},
}],
});
DoTheSending(myData)
.then(function () {
notif = notifications.success({
message: 'Sent !'
});
});
.catch(onError)
;
notifications.info('Hello title', 'Message to the world!', {
template: 'my-custom-template' // by name (without extension)
});
notifications.info('Hello title', 'Message to the world!', {
templateFile: 'my-custom-template.html' // by filename (with extension)
});
Override the template directory:
notifications.info('Hello title', 'Message to the world!', {
templatesDir: '/templates/'
});
The data object passed as parameter is available in the templates' scope:
notifications.info('Hello title', 'Message to the world!', {
username: myUser
});
See the bundled templates as examples.
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.info('Hello title', 'Message to the world!', {
webkitNotifications: {
iconFile: 'favicon.ico'
}
});
You can use HTMLNotifications if you want a custom template:
notifications.info('Hello title', 'Message to the world!', {
webkitNotifications: {
notificationUrl: 'url/to/the/notification/content'
}
});
To enable the webkitNotifications by default:
notifications.useWebkitNotifications({
// data.webkitNotifications object
iconFile: 'favicon.ico'
});
and to disable:
notifications.useWebkitNotifications(false);
Pull requests are welcome!
Pull requests are welcome! (and an issue tracker is available)
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.
FAQs
Highly customizable notifications with AngularJS
The npm package angular-extended-notifications receives a total of 0 weekly downloads. As such, angular-extended-notifications popularity was classified as not popular.
We found that angular-extended-notifications demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.