Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
Updated documentation and removed unnecessary comments from toaster.js
for the items now documented in the README, per
#200
  • Loading branch information
Stabzs committed Mar 13, 2016
1 parent ba9822e commit 8a66010
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 20 deletions.
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AngularJS-Toaster
[![Build Status](https://travis-ci.org/jirikavi/AngularJS-Toaster.svg)](https://travis-ci.org/jirikavi/AngularJS-Toaster)
[![Coverage Status](https://coveralls.io/repos/jirikavi/AngularJS-Toaster/badge.svg?branch=master&service=github&busting=3)](https://coveralls.io/github/jirikavi/AngularJS-Toaster?branch=master)

### Current Version 1.2.0
### Current Version 1.2.1

## Angular Compatibility
AngularJS-Toaster requires AngularJS v1.2.6 or higher and specifically targets AngularJS, not Angular 2, although it could be used via ngUpgrade.
Expand Down Expand Up @@ -64,6 +64,39 @@ angular.module('main', ['toaster', 'ngAnimate'])
</div>
```

### Timeout
By default, toasts have a timeout setting of 5000, meaning that they are removed after 5000
milliseconds.

If the timeout is set to anything other than a number greater than 0, the toast will be considered
"sticky" and will not automatically dismiss.

The timeout can be configured at three different levels:

* Globally in the config for all toast types:
```html
<toaster-container toaster-options="{'time-out': 1000}"></toaster-container>
```

* Per info-class type:
By passing the time-out configuration as an object instead of a number, you can specify the global behavior an info-class type should have.
```html
<toaster-container toaster-options="
{'time-out':{ 'toast-warning': 10, 'toast-error': 0 } }">
</toaster-container>
```
If a type is not defined and specified, a timeout will not be applied, making the toast "sticky".

* Per toast constructed via toaster.pop('success', "title", "text"):
```html
toaster.pop({
type: 'error',
title: 'Title text',
body: 'Body text',
timeout: 3000
});
```

### Close Button

The Close Button's visibility can be configured at three different levels:
Expand Down Expand Up @@ -260,6 +293,35 @@ vm.popContainerTwo = function () {
and it is documented in these [tests](test/toasterContainerSpec.js#L430).


### Limit
Limit is defaulted to 0, meaning that there is no maximum number of toasts that are defined
before the toast container begins removing toasts when a new toast is added.

To change this behavior, pass a "limit" option to the toast-container configuration:

```html
<toaster-container toaster-options="{'limit':5}"></toaster-container>
```

### Dismiss on tap
By default, the `tap-to-dismiss` option is set to true, meaning that if a toast is clicked anywhere
on the toast body, the toast will be dismissed. This behavior can be overriden in the toast-container
configuration so that if set to false, the toast will only be dismissed if the close button is defined
and clicked:

```html
<toaster-container toaster-options="{'tap-to-dismiss':false}"></toaster-container>
```

### Newest Toasts on Top
The `newest-on-top` option is defaulted to true, adding new toasts on top of other existing toasts.
If changed to false via the toaster-container configuration, toasts will be added to the bottom of
other existing toasts.

```html
<toaster-container toaster-options="{'newest-on-top':false}"></toaster-container>
```

### Other Options

```html
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularjs-toaster",
"version": "1.2.0",
"version": "1.2.1",
"description": "AngularJS Toaster is a customized version of toastr non-blocking notification javascript library",
"author": "Jiri Kavulak",
"license": "MIT",
Expand Down
20 changes: 3 additions & 17 deletions toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/*
* AngularJS Toaster
* Version: 1.2.0
* Version: 1.2.1
*
* Copyright 2013-2016 Jiri Kavulak.
* All Rights Reserved.
Expand All @@ -19,24 +19,10 @@
'toasterConfig', {
'limit': 0, // limits max number of toasts
'tap-to-dismiss': true,

/* Options:
- Boolean false/true
'close-button': true
- object if not a boolean that allows you to
override showing the close button for each
icon-class value
'close-button': { 'toast-error': true, 'toast-info': false }
*/
'close-button': false,
'close-html': '<button class="toast-close-button" type="button">&times;</button>',
'newest-on-top': true,
//'fade-in': 1000, // done in css
//'on-fade-in': undefined, // not implemented
//'fade-out': 1000, // done in css
//'on-fade-out': undefined, // not implemented
//'extended-time-out': 1000, // not implemented
'time-out': 5000, // Set timeOut and extendedTimeout to 0 to make it sticky
'newest-on-top': true,
'time-out': 5000,
'icon-classes': {
error: 'toast-error',
info: 'toast-info',
Expand Down
2 changes: 1 addition & 1 deletion toaster.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a66010

Please sign in to comment.