Skip to content

Commit

Permalink
fixes #13, fixes #11, fixes #21, fixes #14, fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
cgross committed Apr 12, 2015
2 parents bff3475 + d63f736 commit 4d159b6
Show file tree
Hide file tree
Showing 20 changed files with 10,935 additions and 5,965 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function myController($scope,notify){ // <-- Inject notify
The `notify` function can either be passed a string or an object. When passing an object, the object parameters can be:

* `message` - Required. The message to show.
* `duration` - Optional. The duration (in milliseconds) of message. A duration of 0 will prevent messages from closing automatically.
* `templateUrl` - Optional. A custom template for the UI of the message.
* `classes` - Optional. A list of custom CSS classes to apply to the message element.
* `messageTemplate` - Optional. A string containing any valid Angular HTML which will be shown instead of the regular `message` text. The string must contain one root element like all valid Angular HTML templates (so wrap everything in a `<span>`).
Expand All @@ -61,6 +62,7 @@ Call `config` to set the default configuration options for angular-notify. The
* `templateUrl` - The default message template.
* `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.

### notify.closeAll()

Expand All @@ -76,6 +78,12 @@ The `messageTemplate` property is also included on the scope as `$messageTemplat


## Release History
* v2.5.0 - 04/12/2015
* New `duration` property per notification.
* New `position` property per notification.
* Fix for DOM elements not being removed.
* New `maximumOpen` config option.
* Bump Angular dependency to 1.3.
* v2.0.2 - 09/06/2014
* Default template redesigned with a Bootstrap look and feel. Default template now also includes a close button.
* Default message location is now the top center.
Expand Down
8 changes: 4 additions & 4 deletions angular-notify.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="cg-notify-message" ng-class="[$classes,
$position === 'center' ? 'cg-notify-message-center' : '',
$position === 'left' ? 'cg-notify-message-left' : '',
$position === 'right' ? 'cg-notify-message-right' : '']"
ng-style="{'margin-left': $centerMargin}">
$position === 'center' ? 'cg-notify-message-center' : '',
$position === 'left' ? 'cg-notify-message-left' : '',
$position === 'right' ? 'cg-notify-message-right' : '']"
ng-style="{'margin-left': $centerMargin}">

<div ng-show="!$messageTemplate">
{{$message}}
Expand Down
22 changes: 18 additions & 4 deletions angular-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','

var startTop = 10;
var verticalSpacing = 15;
var duration = 10000;
var defaultDuration = 10000;
var defaultTemplateUrl = 'angular-notify.html';
var position = 'center';
var container = document.body;
var maximumOpen = 0;

var messageElements = [];
var openNotificationsScope = [];

var notify = function(args){

if (typeof args !== 'object'){
args = {message:args};
}

args.duration = args.duration ? args.duration : defaultDuration;
args.templateUrl = args.templateUrl ? args.templateUrl : defaultTemplateUrl;
args.container = args.container ? args.container : container;
args.classes = args.classes ? args.classes : '';
Expand All @@ -26,6 +29,13 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
scope.$classes = args.classes;
scope.$messageTemplate = args.messageTemplate;

if (maximumOpen > 0) {
var numToClose = (openNotificationsScope.length + 1) - maximumOpen;
for (var i = 0; i < numToClose; i++) {
openNotificationsScope[i].$close();
}
}

$http.get(args.templateUrl,{cache: $templateCache}).success(function(template){

var templateElement = $compile(template)(scope);
Expand All @@ -35,6 +45,7 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','

templateElement.remove();
messageElements.splice(messageElements.indexOf(templateElement),1);
openNotificationsScope.splice(openNotificationsScope.indexOf(scope),1);
layoutMessages();
}
});
Expand Down Expand Up @@ -90,10 +101,10 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
layoutMessages();
});

if (duration > 0){
if (args.duration > 0){
$timeout(function(){
scope.$close();
},duration);
},args.duration);
}

}).error(function(data){
Expand All @@ -117,17 +128,20 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile','
}
});

openNotificationsScope.push(scope);

return retVal;

};

notify.config = function(args){
startTop = !angular.isUndefined(args.startTop) ? args.startTop : startTop;
verticalSpacing = !angular.isUndefined(args.verticalSpacing) ? args.verticalSpacing : verticalSpacing;
duration = !angular.isUndefined(args.duration) ? args.duration : duration;
defaultDuration = !angular.isUndefined(args.duration) ? args.duration : defaultDuration;
defaultTemplateUrl = args.templateUrl ? args.templateUrl : defaultTemplateUrl;
position = !angular.isUndefined(args.position) ? args.position : position;
container = args.container ? args.container : container;
maximumOpen = args.maximumOpen ? args.maximumOpen : maximumOpen;
};

notify.closeAll = function(){
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dist/angular-notify.js",
"dist/angular-notify.css"
],
"version": "2.0.2",
"version": "2.5.0",
"homepage": "https://github.com/cgross/angular-notify",
"authors": [
"Chris Gross <[email protected]>"
Expand All @@ -31,6 +31,6 @@
"demo"
],
"dependencies": {
"angular": "~1.2"
"angular": "~1.3"
}
}
14 changes: 7 additions & 7 deletions bower_components/angular/.bower.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "angular",
"version": "1.2.16",
"version": "1.3.15",
"main": "./angular.js",
"ignore": [],
"dependencies": {},
"homepage": "https://github.com/angular/bower-angular",
"_release": "1.2.16",
"_release": "1.3.15",
"_resolution": {
"type": "version",
"tag": "v1.2.16",
"commit": "7ae38b4a0cfced157e3486a0d6e2d299601723bb"
"tag": "v1.3.15",
"commit": "ba7abcfa409ba852146e6ba206693cf7bac3e359"
},
"_source": "git://github.com/angular/bower-angular.git",
"_target": "~1.2.16",
"_originalSource": "angular",
"_direct": true
"_target": "~1.3",
"_originalSource": "angular"
}
26 changes: 21 additions & 5 deletions bower_components/angular/README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# bower-angular
# packaged angular

This repo is for distribution on `bower`. The source for this module is in the
This repo is for distribution on `npm` and `bower`. The source for this module is in the
[main AngularJS repo](https://github.com/angular/angular.js).
Please file issues and pull requests against that repo.

## Install

Install with `bower`:
You can install this package either with `npm` or with `bower`.

### npm

```shell
npm install angular
```

Then add a `<script>` to your `index.html`:

```html
<script src="/node_modules/angular/angular.js"></script>
```

Or `require('angular')` from your code.

### bower

```shell
bower install angular
```

Add a `<script>` to your `index.html`:
Then add a `<script>` to your `index.html`:

```html
<script src="/bower_components/angular/angular.js"></script>
Expand All @@ -27,7 +43,7 @@ Documentation is available on the

The MIT License

Copyright (c) 2010-2012 Google, Inc. http://angularjs.org
Copyright (c) 2010-2015 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 1 addition & 6 deletions bower_components/angular/angular-csp.css
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
.ng-cloak, .x-ng-cloak,
.ng-hide {
.ng-hide:not(.ng-hide-animate) {
display: none !important;
}

ng\:form {
display: block;
}

.ng-animate-block-transitions {
transition:0s all!important;
-webkit-transition:0s all!important;
}
Loading

0 comments on commit 4d159b6

Please sign in to comment.