Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit db355c7

Browse files
author
Marco Rinck
committed
merge PR#5 (html in messsages), updated doc
1 parent 585684f commit db355c7

File tree

6 files changed

+62
-11
lines changed

6 files changed

+62
-11
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ present, you only have to provide keys as messages, angular-translate will trans
1717

1818
##Changelog
1919

20+
**0.4.0** - 19th Nov 2013
21+
22+
* updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE)
23+
* new option: only display unique messages, which is the new default, disable to allow same message more than once (BREAKING CHANGE)
24+
* new option: allow html tags in messages, default is off you need to
25+
2026
**0.3.1** - 1st Oct 2013
2127

2228
* bugfix: translating of messages works again
@@ -102,8 +108,25 @@ app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) {
102108

103109
##Configuration
104110

111+
###Only unique messages
112+
113+
* Default: true
114+
115+
Accept only unique messages as a new message. If a message is already displayed (text and severity are the same) then this
116+
message will not be added to the displayed message list. Set to false, to always display all messages regardless if they
117+
are already displayed or not:
118+
119+
````javascript
120+
var app = angular.module('myApp', ['angular-growl']);
121+
122+
app.config(['growlProvider', function(growlProvider) {
123+
growlProvider.onlyUniqueMessages(false);
124+
}]);
125+
````
126+
105127
###Automatic closing of notifications (timeout, ttl)
106-
Standard behaviour is, that all notifications need to be closed manually by the user.
128+
129+
* Default: none (all messages need to be closed manually by the user.)
107130

108131
However, you can configure a global timeout (TTL) after which notifications should be automatically closed. To do
109132
this, you have to configure this during config phase of angular bootstrap like this:
@@ -140,6 +163,33 @@ app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) {
140163
}]);
141164
````
142165

166+
###Allow HTML in messages
167+
168+
* Default: false
169+
170+
Turn this on to be able to display html tags in messages, default behaviour is to NOT display HTML.
171+
172+
For this to work, you have to declare a dependency to "ngSanitize" (and load the extra javascript) in your own application
173+
module!
174+
175+
````javascript
176+
var app = angular.module('myApp', ['angular-growl', 'ngSanitize']);
177+
178+
app.config(['growlProvider', function(growlProvider) {
179+
growlProvider.globalEnableHtml(true);
180+
}]);
181+
````
182+
183+
You can override the global option and allow HTML tags in single messages too:
184+
185+
````javascript
186+
app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) {
187+
$scope.addSpecialWarnMessage = function() {
188+
growl.addWarnMessage("<strong>This is a HTML message</strong>", {enableHtml: true});
189+
}
190+
}]);
191+
````
192+
143193
###Animations
144194

145195
Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
".gitignore"
2323
],
2424
"dependencies": {
25-
"angular": "1.0.8"
25+
"angular": "1.2.1"
2626
},
2727
"devDependencies": {
28-
"angular-mocks": "1.0.8"
28+
"angular-mocks": "1.2.1"
2929
}
3030
}

demo/demo.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html>
33
<head>
44
<title>angular-growl demo</title>
5-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
6-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.min.js"></script>
7-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-mocks.js"></script>
8-
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-sanitize.js"></script>
5+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
6+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-animate.min.js"></script>
7+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-mocks.js"></script>
8+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.js"></script>
99
<link href="http://netdna.bootstrapcdn.com//twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
1010
<!--<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">-->
1111

demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ app.run(function($httpBackend) {
2323
});
2424
});
2525

26-
app.controller("demoCtrl", function demoCtrl($scope, growl, $http) {
26+
app.controller("demoCtrl", function demoCtrl($scope, growl, $http) {
2727

2828
$scope.createMessage = function () {
2929
var config = {};

src/growl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
angular.module('angular-growl', ['ngSanitize']);
1+
angular.module('angular-growl', []);

src/growlFactory.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ angular.module("angular-growl").provider("growl", function() {
55
_enableHtml = false,
66
_messagesKey = 'messages',
77
_messageTextKey = 'text',
8-
_messageSeverityKey = 'severity';
8+
_messageSeverityKey = 'severity',
9+
_onlyUniqueMessages = true;
910

1011
/**
1112
* set a global timeout (time to live) after which messages will be automatically closed
@@ -19,7 +20,7 @@ angular.module("angular-growl").provider("growl", function() {
1920
/**
2021
* set whether HTML in message content should be escaped (default) or binded as-is
2122
*
22-
* @param {bool} true to make all messages not escapes
23+
* @param {bool} enableHtml true to make all messages not escapes
2324
*/
2425
this.globalEnableHtml = function(enableHtml) {
2526
_enableHtml = enableHtml;

0 commit comments

Comments
 (0)