Skip to content

Commit bc4cfd7

Browse files
committed
Close #1 globalTTL will now accept a hash or integer
1 parent 302c6bd commit bc4cfd7

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

build/angular-growl.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* angular-growl-v2 - v0.5.2 - 2014-03-19
2+
* angular-growl-v2 - v0.5.3 - 2014-03-20
33
* http://janstevens.github.io/angular-growl-2
44
* Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT
55
*/
@@ -76,9 +76,26 @@ angular.module('angular-growl').directive('growl', [
7676
]);
7777
angular.module('angular-growl').provider('growl', function () {
7878
'use strict';
79-
var _ttl = null, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _referenceId = 0, _inline = false, _disableCloseButton = false;
79+
var _ttl = {
80+
success: null,
81+
error: null,
82+
warning: null,
83+
info: null
84+
}, _enableHtml = false, _messagesKey = 'messages', _messageTextKey = 'text', _messageSeverityKey = 'severity', _onlyUniqueMessages = true, _referenceId = 0, _inline = false, _disableCloseButton = false;
8085
this.globalTimeToLive = function (ttl) {
81-
_ttl = ttl;
86+
if (typeof ttl === 'object') {
87+
for (var k in ttl) {
88+
if (ttl.hasOwnProperty(k)) {
89+
_ttl[k] = ttl[k];
90+
}
91+
}
92+
} else {
93+
for (var severity in _ttl) {
94+
if (_ttl.hasOwnProperty(severity)) {
95+
_ttl[severity] = ttl;
96+
}
97+
}
98+
}
8299
};
83100
this.globalEnableHtml = function (enableHtml) {
84101
_enableHtml = enableHtml;
@@ -143,7 +160,7 @@ angular.module('angular-growl').provider('growl', function () {
143160
message = {
144161
text: text,
145162
severity: severity,
146-
ttl: _config.ttl || _ttl,
163+
ttl: _config.ttl || _ttl[severity],
147164
enableHtml: _config.enableHtml || _enableHtml,
148165
disableCloseButton: _config.disableCloseButton || _disableCloseButton,
149166
referenceId: _config.referenceId || _referenceId

build/angular-growl.min.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* angular-growl-v2 - v0.5.2 - 2014-03-19
2+
* angular-growl-v2 - v0.5.3 - 2014-03-20
33
* http://janstevens.github.io/angular-growl-2
44
* Copyright (c) 2014 Marco Rinck,Jan Stevens; Licensed MIT
55
*/

build/angular-growl.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/growlFactory.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
angular.module("angular-growl").provider("growl", function() {
22
"use strict";
33

4-
var _ttl = null,
4+
var _ttl = {success: null, error: null, warning: null, info: null},
55
_enableHtml = false,
66
_messagesKey = 'messages',
77
_messageTextKey = 'text',
@@ -17,7 +17,19 @@ angular.module("angular-growl").provider("growl", function() {
1717
* @param ttl in seconds
1818
*/
1919
this.globalTimeToLive = function(ttl) {
20-
_ttl = ttl;
20+
if(typeof ttl === 'object') {
21+
for(var k in ttl) {
22+
if(ttl.hasOwnProperty(k)) {
23+
_ttl[k] = ttl[k];
24+
}
25+
}
26+
} else {
27+
for(var severity in _ttl) {
28+
if(_ttl.hasOwnProperty(severity)) {
29+
_ttl[severity] = ttl;
30+
}
31+
}
32+
}
2133
};
2234

2335
/**
@@ -128,7 +140,7 @@ angular.module("angular-growl").provider("growl", function() {
128140
message = {
129141
text: text,
130142
severity: severity,
131-
ttl: _config.ttl || _ttl,
143+
ttl: _config.ttl || _ttl[severity],
132144
enableHtml: _config.enableHtml || _enableHtml,
133145
disableCloseButton: _config.disableCloseButton || _disableCloseButton,
134146
referenceId: _config.referenceId || _referenceId

0 commit comments

Comments
 (0)