Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Call `config` to set the default configuration options for angular-notify. The
* `position` - The default position of each message. `center`, `left` and `right` are the supported values.
* `container` - The default element that contains each notification. Defaults to `document.body`.
* `maximumOpen` - The maximum number of total notifications that can be visible at one time. Older notifications will be closed when the maximum is reached.
* `cleanupTimeout` - A timeout that cleans up the DOM after the message has faded out. This does not normally need to be set, but if you change the opacity transition duration
in `.cg-notify-message` you may want to adjust this so that the message isn't suddenly
removed before the fade-out transition is completed.

### notify.closeAll()

Expand Down
7 changes: 7 additions & 0 deletions angular-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
var position = 'center';
var container = document.body;
var maximumOpen = 0;
var cleanupTimeout = 500;

var messageElements = [];
var openNotificationsScope = [];
Expand Down Expand Up @@ -77,6 +78,11 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
scope.$close = function(){
templateElement.css('opacity',0).attr('data-closing','true');
layoutMessages();
// add a cleanup handler for the templateElement in case the transitionend event is not fired (e.g. the transition is
// interrupted by the browser).
$timeout(function() {
templateElement.remove();
}, cleanupTimeout);
};

var layoutMessages = function(){
Expand Down Expand Up @@ -142,6 +148,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
position = !angular.isUndefined(args.position) ? args.position : position;
container = args.container ? args.container : container;
maximumOpen = args.maximumOpen ? args.maximumOpen : maximumOpen;
cleanupTimeout = args.cleanupTimeout ? args.cleanupTimeout : cleanupTimeout;
};

notify.closeAll = function(){
Expand Down
7 changes: 7 additions & 0 deletions dist/angular-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
var position = 'center';
var container = document.body;
var maximumOpen = 0;
var opacityAnimationTimeout = 500;

var messageElements = [];
var openNotificationsScope = [];
Expand Down Expand Up @@ -77,6 +78,11 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
scope.$close = function(){
templateElement.css('opacity',0).attr('data-closing','true');
layoutMessages();
// add a cleanup handler for the templateElement in case the transitionend event is not fired (e.g. the transition is
// interrupted by the browser).
$timeout(function() {
templateElement.remove();
}, opacityAnimationTimeout);
};

var layoutMessages = function(){
Expand Down Expand Up @@ -142,6 +148,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
position = !angular.isUndefined(args.position) ? args.position : position;
container = args.container ? args.container : container;
maximumOpen = args.maximumOpen ? args.maximumOpen : maximumOpen;
opacityAnimationTimeout = args.opacityAnimationTimeout ? args.opacityAnimationTimeout : opacityAnimationTimeout;
};

notify.closeAll = function(){
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-notify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.