Skip to content

Commit

Permalink
merge PR#5 (html in messsages), updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Rinck committed Nov 19, 2013
1 parent 585684f commit db355c7
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 11 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ present, you only have to provide keys as messages, angular-translate will trans

##Changelog

**0.4.0** - 19th Nov 2013

* updated dependency to angularJS 1.2.x, angular-growl does not work with 1.0.x anymore (BREAKING CHANGE)
* new option: only display unique messages, which is the new default, disable to allow same message more than once (BREAKING CHANGE)
* new option: allow html tags in messages, default is off you need to

**0.3.1** - 1st Oct 2013

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

##Configuration

###Only unique messages

* Default: true

Accept only unique messages as a new message. If a message is already displayed (text and severity are the same) then this
message will not be added to the displayed message list. Set to false, to always display all messages regardless if they
are already displayed or not:

````javascript
var app = angular.module('myApp', ['angular-growl']);

app.config(['growlProvider', function(growlProvider) {
growlProvider.onlyUniqueMessages(false);
}]);
````

###Automatic closing of notifications (timeout, ttl)
Standard behaviour is, that all notifications need to be closed manually by the user.

* Default: none (all messages need to be closed manually by the user.)

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

###Allow HTML in messages

* Default: false

Turn this on to be able to display html tags in messages, default behaviour is to NOT display HTML.

For this to work, you have to declare a dependency to "ngSanitize" (and load the extra javascript) in your own application
module!

````javascript
var app = angular.module('myApp', ['angular-growl', 'ngSanitize']);

app.config(['growlProvider', function(growlProvider) {
growlProvider.globalEnableHtml(true);
}]);
````

You can override the global option and allow HTML tags in single messages too:

````javascript
app.controller("demoCtrl", ['$scope', 'growl', function($scope, growl) {
$scope.addSpecialWarnMessage = function() {
growl.addWarnMessage("<strong>This is a HTML message</strong>", {enableHtml: true});
}
}]);
````

###Animations

Beginning with angularJS 1.2 growl messages can be automatically animated with CSS animations when adding and/or closing
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
".gitignore"
],
"dependencies": {
"angular": "1.0.8"
"angular": "1.2.1"
},
"devDependencies": {
"angular-mocks": "1.0.8"
"angular-mocks": "1.2.1"
}
}
8 changes: 4 additions & 4 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html>
<head>
<title>angular-growl demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-mocks.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-sanitize.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-mocks.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-sanitize.js"></script>
<link href="http://netdna.bootstrapcdn.com//twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<!--<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">-->

Expand Down
2 changes: 1 addition & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ app.run(function($httpBackend) {
});
});

app.controller("demoCtrl", function demoCtrl($scope, growl, $http) {
app.controller("demoCtrl", function demoCtrl($scope, growl, $http) {

$scope.createMessage = function () {
var config = {};
Expand Down
2 changes: 1 addition & 1 deletion src/growl.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
angular.module('angular-growl', ['ngSanitize']);
angular.module('angular-growl', []);
5 changes: 3 additions & 2 deletions src/growlFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ angular.module("angular-growl").provider("growl", function() {
_enableHtml = false,
_messagesKey = 'messages',
_messageTextKey = 'text',
_messageSeverityKey = 'severity';
_messageSeverityKey = 'severity',
_onlyUniqueMessages = true;

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

0 comments on commit db355c7

Please sign in to comment.