Skip to content

Commit 8968d69

Browse files
author
Jurgen Van de Moere
committed
Update growlNotifications service to support cssPrefix
1 parent 9081d25 commit 8968d69

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/growlNotifications/services/growlNotifications.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ angular.module('growlNotifications.services')
44
// Default options
55
var options = {
66
ttl: 5000,
7-
type: 'info'
7+
type: 'info',
8+
9+
// Default css prefix that is used to construct growl css classes
10+
// 2 classes will be added: cssPrefix and cssPrefix-type to support
11+
// Bootstrap alerts out of the box
12+
cssPrefix: 'alert'
813
};
914

1015
/**
@@ -25,10 +30,10 @@ angular.module('growlNotifications.services')
2530
*/
2631
this.ttl = function(ttl){
2732
if(angular.isDefined(ttl)){
28-
this.options.ttl = ttl;
33+
options.ttl = ttl;
2934
return this;
3035
}
31-
return this.options.ttl;
36+
return options.ttl;
3237
};
3338

3439
/**
@@ -39,10 +44,24 @@ angular.module('growlNotifications.services')
3944
*/
4045
this.type = function(type){
4146
if(angular.isDefined(type)){
42-
this.options.type = type;
47+
options.type = type;
48+
return this;
49+
}
50+
return options.type;
51+
};
52+
53+
/**
54+
* Provider convenience method to get or set default type
55+
*
56+
* @param type
57+
* @returns {*}
58+
*/
59+
this.cssPrefix = function(cssPrefix){
60+
if(angular.isDefined(cssPrefix)){
61+
options.cssPrefix = cssPrefix;
4362
return this;
4463
}
45-
return this.options.type;
64+
return options.cssPrefix;
4665
};
4766

4867
/**
@@ -59,6 +78,8 @@ angular.module('growlNotifications.services')
5978
this._notifications = {};
6079
this._index = 0;
6180

81+
this.options = options;
82+
6283
Object.defineProperty(this, 'notifications', {
6384
get: function(){
6485
return this._notifications;

0 commit comments

Comments
 (0)