Skip to content

I created a new classes option #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ The options list:
| closeOnClick | true, false | true | If true, messages are closed on click |
| maxCount | Any integer | 0 | Show only [maxCount] last messages. Old messages will be killed. 0 - do not kill |
| priority | Any integer | 10 | The highier the priority is, the higher the notification will be |
| classes | Any string or array of it | [] | a classes that can be added to the whole notification div |

Also you can pass the "scope" option. This is an angular scope option Notification scope will be inherited from. This option can be passed only in the methods. The default value is $rootScope

Expand Down
10 changes: 8 additions & 2 deletions src/angular-ui-notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ angular.module('ui-notification').provider('Notification', function() {
closeOnClick: true,
maxCount: 0, // 0 - Infinite
container: 'body',
priority: 10
priority: 10,
classes: []
};

this.setOptions = function(options) {
Expand Down Expand Up @@ -54,7 +55,8 @@ angular.module('ui-notification').provider('Notification', function() {
args.closeOnClick = (args.closeOnClick !== null && args.closeOnClick !== undefined) ? args.closeOnClick : options.closeOnClick;
args.container = args.container ? args.container : options.container;
args.priority = args.priority ? args.priority : options.priority;

args.classes = args.classes ? (Array.isArray(args.classes)?args.classes:[args.classes]): options.classes;

var template=$templateCache.get(args.template);

if(template){
Expand Down Expand Up @@ -143,6 +145,10 @@ angular.module('ui-notification').provider('Notification', function() {
templateElement._positionX = args.positionX;
templateElement._priority = args.priority;
templateElement.addClass(args.type);
args.classes.forEach(function(item) {
templateElement.addClass(item);
});


var closeEvent = function(e) {
e = e.originalEvent || e;
Expand Down