Skip to content

Commit c469a03

Browse files
committed
Merge pull request #187 from Stabzs/master
Updated version to 1.0.0 and added additional documentation
2 parents 96763be + 4cb9ca1 commit c469a03

File tree

5 files changed

+57
-10
lines changed

5 files changed

+57
-10
lines changed

README.md

+51-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
AngularJS-Toaster
22
=================
33

4-
**AngularJS Toaster** is an AngularJS port of the **toastr** non-blocking notification jQuery library. It requires AngularJS v1.2.6 or higher and angular-animate for the CSS3 transformations.
5-
(I would suggest to use /1.2.8/angular-animate.js, there is a weird blinking in newer versions.)
4+
**AngularJS Toaster** is an AngularJS port of the **toastr** non-blocking notification jQuery library. It requires AngularJS v1.2.6 or higher and angular-animate for the CSS3 transformations.
65

76
[![Build Status](https://travis-ci.org/jirikavi/AngularJS-Toaster.svg)](https://travis-ci.org/jirikavi/AngularJS-Toaster)
87
[![Coverage Status](https://coveralls.io/repos/jirikavi/AngularJS-Toaster/badge.svg?branch=master&service=github&cachebust=1)](https://coveralls.io/github/jirikavi/AngularJS-Toaster?branch=master)
98

10-
### Current Version 0.4.18
9+
### Current Version 1.0.0
1110

1211
## Demo
1312
- Simple demo is at http://plnkr.co/edit/HKTC1a
@@ -130,6 +129,8 @@ There are four types of body renderings: trustedHtml', 'template', 'templateWith
130129

131130
- directive
132131
- Will use the `toast.body` argument to represent the name of a directive that you want to render as the toast's body, else it will fallback to the template bound to the `'body-template': 'toasterBodyTmpl.html'` configuration option.
132+
The directive name being passed to the `body` argument should be normalized as it exists in the markup,
133+
not camelCased as it would appear in the directive declaration (`cool-directive-name` instead of `coolDirectiveName`).
133134

134135
```js
135136
// The toast pop call, passing in a directive name to be rendered
@@ -148,7 +149,7 @@ There are four types of body renderings: trustedHtml', 'template', 'templateWith
148149
};
149150
}])
150151
```
151-
- Will use the `toast.directiveData` argument to accept data that will be bound to the directive's scope.
152+
- Will use the `toast.directiveData` argument to accept data that will be bound to the directive's scope.
152153

153154
```js
154155
// The toast pop call, passing in a directive name to be rendered
@@ -206,6 +207,37 @@ toaster.pop({
206207
});
207208
```
208209

210+
### Multiple Toaster Containers
211+
If desired, you can include multiple `<toaster-container></toaster-container>`
212+
elements in your DOM. The library will register an event handler for every instance
213+
of the container that it identifies. By default, when there are multiple registered
214+
containers, each container will receive a toast notification and display it when a toast
215+
is popped.
216+
217+
To target a specific container, you need to register that container with a unique `toaster-id`.
218+
219+
```html
220+
<toaster-container toaster-options="{'toaster-id': 1,
221+
'animation-class': 'toast-top-left'}"></toaster-container>
222+
<toaster-container toaster-options="{'toaster-id': 2}"></toaster-container>
223+
```
224+
225+
This gives you the ability to specifically target a unique container rather than broadcasting
226+
new toast events to any containers that are currently registered.
227+
228+
```js
229+
vm.popContainerOne = function () {
230+
toaster.pop({ type: 'info', body: 'One', toasterId: 1 });
231+
}
232+
233+
vm.popContainerTwo = function () {
234+
toaster.pop({ type: 'info', body: 'Two', toasterId: 2 });
235+
}
236+
```
237+
238+
[This plnkr](http://plnkr.co/edit/4ICtcrpTSoAB9Vo5bRvN?p=preview) demonstrates this behavior
239+
and it is documented in these [tests](test/toasterContainerSpec.js#L430).
240+
209241

210242
### Other Options
211243

@@ -223,6 +255,21 @@ angular.module('main', ['toaster', 'ngAnimate']);
223255
```
224256
If you do not want to use animations, you can safely remove the angular-animate.min.js reference as well as the injection of ngAnimate. Toasts will be displayed without animations.
225257

258+
259+
### Common Issues
260+
- Toaster always shows up as "info"
261+
- Your `<toaster-container></toaster-container` might be placed inside of your routing directive.
262+
- You have multiple `<toaster-container></toaster-container` elements without unqiue `toaster-id` configuration arguments.
263+
- [$sce:itype] Attempted to trust a non-string value in a content requiring a string
264+
- You have not specified: `bodyOutputType: 'trustedHtml'` when passing html as a body argument.
265+
- My toasts do not show up when I pop them, but after I perform another action.
266+
- You are calling `toaster.pop()` outside of AngularJS scope and a digest cycle is not being triggered.
267+
Wrap your `toaster.pop()` call in `$timeout` to force a digest cycle.
268+
```js
269+
$timeout(function () {
270+
toaster.pop();
271+
}, 0);
272+
```
226273

227274
## Author
228275
**Jiri Kavulak**

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AngularJS-Toaster",
3-
"version": "0.4.18",
3+
"version": "1.0.0",
44
"main": [
55
"toaster.js",
66
"toaster.css"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-toaster",
3-
"version": "0.4.18",
3+
"version": "1.0.0",
44
"description": "AngularJS Toaster is a customized version of toastr non-blocking notification javascript library",
55
"scripts": {
66
"test": "gulp test"

toaster.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
/*
66
* AngularJS Toaster
7-
* Version: 0.4.18
7+
* Version: 1.0.0
88
*
9-
* Copyright 2013-2015 Jiri Kavulak.
9+
* Copyright 2013-2016 Jiri Kavulak.
1010
* All Rights Reserved.
1111
* Use, reproduction, distribution, and modification of this code is subject to the terms and
1212
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php

toaster.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)