From 8a66010ec59a058e67c002faa3449c52760295d5 Mon Sep 17 00:00:00 2001 From: Stabzs Date: Sun, 13 Mar 2016 17:38:30 -0600 Subject: [PATCH] Updated documentation Updated documentation and removed unnecessary comments from toaster.js for the items now documented in the README, per https://github.com/jirikavi/AngularJS-Toaster/issues/200 --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- toaster.js | 20 +++------------- toaster.min.js | 2 +- 4 files changed, 68 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 513eb03..4169003 100644 --- a/README.md +++ b/README.md @@ -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. @@ -64,6 +64,39 @@ angular.module('main', ['toaster', 'ngAnimate']) ``` +### 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 + +``` + +* 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 + + +``` +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: @@ -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 + +``` + +### 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 + +``` + +### 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 + +``` + ### Other Options ```html diff --git a/package.json b/package.json index e13a770..61e15d1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/toaster.js b/toaster.js index 654185d..d8edf09 100644 --- a/toaster.js +++ b/toaster.js @@ -4,7 +4,7 @@ /* * AngularJS Toaster - * Version: 1.2.0 + * Version: 1.2.1 * * Copyright 2013-2016 Jiri Kavulak. * All Rights Reserved. @@ -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': '', - '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', diff --git a/toaster.min.js b/toaster.min.js index 98b7e72..792387b 100644 --- a/toaster.min.js +++ b/toaster.min.js @@ -1,6 +1,6 @@ /* * AngularJS Toaster - * Version: 1.2.0 + * Version: 1.2.1 * * Copyright 2013-2016 Jiri Kavulak. * All Rights Reserved.