• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    JavaScript
  • Created about 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Angular.js component for stylish and flexible top bar notifications.

ng-notifications-bar

Angular.js and Animate.css based component for stylish and flexible application notifications.

Demo

Overview

Web applications requires notify users of ongoing events. Common cases are errors, successful completion notifications etc. With ng-notifications-bar it's as easy as,

<body>
	<notifications-bar class="notifications"></notifications-bar>
	...

Installation

Npm installation,

$ npm install ng-notifications-bar --save

Or bower installation,

$ bower install ng-notifications-bar --save

Update your scripts and styles section or use the require for browserified applications.

<link rel="stylesheet" href="bower_components/ng-notifications-bar/dist/ngNotificationsBar.min.css" />
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/ng-notifications-bar/dist/ngNotificationsBar.min.js"></script>

If you use Grunt, wiredep should inject the required angular-sanitize.js for you.

For browserify applications, require module in yours application module,

require('ng-notifications-bar');

In case you are using sass in project, it's possible to just import ngNotificationsBar styles,

@import "../../node_modules/ng-notifications-bar/sass/ngNotificationsBar";

In application module,

angular.module('app', ['ngNotificationsBar', 'ngSanitize']);

ngSanitize can be omitted if HTML support isn't needed.

API

The module consists of there elements - directive, service and provider.

Directive

notifications-bar element directive, should be placed once, typically right after <body> open tag.

<notifications-bar class="notifications"></notifications-bar>

If you are using a icon library besides Glyphicons for the close button (such as Font Awesome), include a closeIcon attribute.

<notifications-bar class="notifications" closeIcon="fa fa-times-circle"></notifications-bar>

The default is the glyphicon-remove icon so don't forget to import Glyphicons if you aren't defining a closeIcon attribute.

Possible to use as attribute, as well

<div notifications-bar class="notifications"></div notifications-bar>

Service

notification service is used by controllers (or other directives), to show notifications.

app.controllers('app', function ($scope, api, notifications) {
	api.get({resource: 'tasks'})
		.then(function (tasks) {
			$scope.tasks = tasks;
		}, function (error) {
			notifications.showError({message: error.message});
		});

	$scope.submitTask = function () {
		api.post({resource: 'tasks'}, {description: this.description})
			.then(function () {
				notifications.showSuccess({message: 'Your task posted successfully'});
			}, function (error) {
				notifications.showError({message: 'Oh no! Task submission failed, <em>please try again.</em>'});
			});
	}
});

Provider

notificationsConfigProvider is used to override some notifications bar defaults.

app.config(['notificationsConfigProvider', function (notificationsConfigProvider) {
	// auto hide
	notificationsConfigProvider.setAutoHide(true)

	// delay before hide
	notificationsConfigProvider.setHideDelay(3000)
}])

Settings

It is possible to setup the whole notifications bar module in module config and each notification separately in controller

Available options:

  • autoHide
  • hideDelay
  • acceptHTML
  • autoHideAnimation
  • autoHideAniationDelay

Please note, HTML support is only configurable at a global level. If HTML is to be supported, make sure to inject the 'ngSanitize' dependency.

var app = angular.module('app', ['ngNotificationsBar', 'ngSanitize']);

During configuration

app.config(['notificationsConfigProvider'], function (notificationsConfigProvider) {
	// auto hide
	notificationsConfigProvider.setAutoHide(true);

	// delay before hide
	notificationsConfigProvider.setHideDelay(3000);

	// support HTML
	notificationsConfigProvider.setAcceptHTML(false);
	
	// Set an animation for hiding the notification
	notificationsConfigProvider.setAutoHideAnimation('fadeOutNotifications');
	
	// delay between animation and removing the nofitication
	notificationsConfigProvider.setAutoHideAnimationDelay(1200);
	
}])

Override in controller

app.controller('main', function ($scope, notifications) {
	$scope.showError = function () {
		notifications.showError({
			message: 'Oops! Something bad just happened! (hides faster)',
			hideDelay: 1500, //ms
			hide: true //bool
		});
	};
});

Development

Install bower dependencies,

$ bower install

Install npm dependencies,

$ npm install

Run grunt build,

$ grunt

as result, /dist folder is created with ready to use .js and .css file.

Project doesn't have tests at the moment, so run example and check the functionality,

$ grunt start:example

Licence

Copyright (c) 2014, [email protected]

MIT

More Repositories

1

backbone-express-spa

Backbone.js + Express.js single page application boilerplate
JavaScript
431
star
2

elmah-mvc

Painless integration of ELMAH into ASP.NET MVC application
C#
266
star
3

backbone-computedfields

Computed fields for Backbone.Model
JavaScript
135
star
4

brick

My boilerplate project for Node.js / React.js development
JavaScript
71
star
5

github-commits-widget

Simple javascript widget to show recent github commits
JavaScript
41
star
6

foundstyles

Cool looking and ready to use themes based on Foundation framework
JavaScript
30
star
7

candidate

Simple and nice continuous delivery for .NET web applications.
JavaScript
23
star
8

machiatto

Behaviour driven test framework.
JavaScript
23
star
9

toml-js

TOML parser implementation (node.js + browser)
JavaScript
23
star
10

dokku-bower-install

Dokku pluging to install bower dependecies
Shell
21
star
11

tdd.demand

A Web Crawler that crawle some job looking sites, analyze them, store data
C#
19
star
12

trackyt.net

New task tracking/time management application
JavaScript
17
star
13

ddp-server-event

The implementation of DDP server based on EventEmitter.
JavaScript
15
star
14

react-restify-isomorphic

Isomorphic, react-based application.
JavaScript
13
star
15

wonka

Sweet blog engine with github powered backend for ASP.NET MVC applications.
C#
9
star
16

sparkling

Building Reactive API's with Express.js and MongoDB
JavaScript
9
star
17

todomvc-aura

TodoMVC based on Aura
JavaScript
9
star
18

aspnet.mobile

Mobile Web Application for ASP.NET portal fans
JavaScript
9
star
19

beerncode

Kyiv Beer'n'Code website
C#
9
star
20

react-notifications-bar

The port of ng-notifications-bar to React
JavaScript
6
star
21

react-grunt-es6

React + Grunt + ES6
JavaScript
6
star
22

react-gulp-es6

React + Gulp + ES6
JavaScript
6
star
23

github-fs

Convenient way of working with Git (Github) remote repository as file system
C#
5
star
24

backbone-clickdebounce

Debounce multiple clicks for Backbone.Views
JavaScript
5
star
25

themailer

Demo application I've created for my conference talk
JavaScript
5
star
26

rest.mvc.example

Example of REST service by ASP.net MVC2 framework (for blog)
JavaScript
5
star
27

node-dev-server

Ideal for local single page applications development
JavaScript
3
star
28

10k

My humble attempt to participate 10K Appart competetion
JavaScript
3
star
29

freeze

Easy way of making a snapshot of dynamic web site.
JavaScript
3
star
30

js-training

js-training
JavaScript
2
star
31

certificates

My archivements on online courses and other official stuff
2
star
32

benchmark-js

Very simple, javascript Date() dependable, console based benchmarking.
JavaScript
2
star
33

tdd-starter

Ready to use sandbox for TDD with JS
JavaScript
2
star
34

copter

Front-end apps deployment
1
star
35

alexbeletsky.github.io

My personal page and development blog
HTML
1
star
36

canteen

Node.js chat application with real time collaboration
JavaScript
1
star
37

ml-python

Materials created during studying Python Machine Learning book.
Jupyter Notebook
1
star
38

next-error

Express.js module that would which eliminates if / return for error handling.
JavaScript
1
star
39

numa-app

JavaScript
1
star
40

docker-deploy

Deploy tool for remote docker server
Shell
1
star
41

gameoflife

The Game of Life
JavaScript
1
star
42

backbone-aspnetmvc-spa

Backbone.js + ASP.NET MVC (Web API) single page application boilerplate
JavaScript
1
star