提交 | 用户 | 时间
|
58d006
|
1 |
# toastr |
A |
2 |
**toastr** is a Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended. |
|
3 |
|
|
4 |
## Current Version |
|
5 |
2.0.1 |
|
6 |
|
|
7 |
## Demo |
|
8 |
- Demo can be found at http://codeseven.github.io/toastr/demo.html |
|
9 |
- [Demo using FontAwesome icons with toastr](http://plnkr.co/edit/6W9URNyyp2ItO4aUWzBB?p=preview) |
|
10 |
|
|
11 |
## CDNjs |
|
12 |
Toastr is hosted at CDN JS |
|
13 |
|
|
14 |
#### Debug |
|
15 |
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.js](//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/js/toastr.js) |
|
16 |
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/css/toastr.css) |
|
17 |
|
|
18 |
#### Minified |
|
19 |
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/js/toastr.min.js](//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/js/toastr.min.js) |
|
20 |
- [//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.1/css/toastr.min.css](//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/css/toastr.min.css) |
|
21 |
|
|
22 |
## NuGet Gallery |
|
23 |
http://nuget.org/packages/toastr |
|
24 |
|
|
25 |
## [Bower](http://bower.io/) |
|
26 |
bower install toastr |
|
27 |
|
|
28 |
|
|
29 |
## Wiki and Change Log |
|
30 |
[Wiki including Change Log](https://github.com/CodeSeven/toastr/wiki) |
|
31 |
|
|
32 |
## Breaking Changes |
|
33 |
|
|
34 |
####Animation Changes |
|
35 |
The following animations options have been deprecated and should be replaced: |
|
36 |
|
|
37 |
- Replace `options.fadeIn` with `options.showDuration` |
|
38 |
- Replace `options.onFadeIn` with `options.onShown` |
|
39 |
- Replace `options.fadeOut` with `options.hideDuration` |
|
40 |
- Replace `options.onFadeOut` with `options.onHidden` |
|
41 |
|
|
42 |
## Quick start |
|
43 |
|
|
44 |
###3 Easy Steps |
|
45 |
For other API calls, see the [demo](http://codeseven.github.io/toastr/demo.html). |
|
46 |
|
|
47 |
1. Link to toastr.css `<link href="toastr.css" rel="stylesheet"/>` |
|
48 |
|
|
49 |
2. Link to toastr.js `<script src="toastr.js"></script>` |
|
50 |
|
|
51 |
3. use toastr to display a toast for info, success, warning or error |
|
52 |
|
|
53 |
// Display an info toast with no title |
|
54 |
toastr.info('Are you the 6 fingered man?') |
|
55 |
|
|
56 |
### Other Options |
|
57 |
// Display a warning toast, with no title |
|
58 |
toastr.warning('My name is Inigo Montoya. You killed my father, prepare to die!') |
|
59 |
|
|
60 |
// Display a success toast, with a title |
|
61 |
toastr.success('Have fun storming the castle!', 'Miracle Max Says') |
|
62 |
|
|
63 |
// Display an error toast, with a title |
|
64 |
toastr.error('I do not think that word means what you think it means.', 'Inconceivable!') |
|
65 |
|
|
66 |
// Clears the current list of toasts |
|
67 |
toastr.clear() |
|
68 |
|
|
69 |
### Close Button |
|
70 |
Optionally enable a close button |
|
71 |
|
|
72 |
toastr.options.closeButton = true; |
|
73 |
|
|
74 |
Optionally override the close button's HTML. |
|
75 |
|
|
76 |
toastr.options.closeHtml = '<button><i class="icon-off"></i></button>'; |
|
77 |
|
|
78 |
You can also override the CSS/LESS for `#toast-container .toast-close-button` |
|
79 |
|
|
80 |
### Display Sequence |
|
81 |
Show newest toast at bottom (top is default) |
|
82 |
|
|
83 |
toastr.options.newestOnTop = false; |
|
84 |
|
|
85 |
### Callbacks |
|
86 |
// Define a callback for when the toast is shown/hidden |
|
87 |
toastr.options.onShown = function() { console.log('hello'); } |
|
88 |
toastr.options.onHidden = function() { console.log('goodbye'); } |
|
89 |
|
|
90 |
### Animation Options |
|
91 |
Toastr will supply default animations, so you do not have to provide any of these settings. However you have the option to override the animations if you like. |
|
92 |
|
|
93 |
####Easings |
|
94 |
Optionally override the animation easing to show or hide the toasts. Default is swing. swing and linear are built into jQuery. |
|
95 |
|
|
96 |
toastr.options.showEasing = 'swing'; |
|
97 |
toastr.options.hideEasing = 'linear'; |
|
98 |
|
|
99 |
Using the jQuery Easing plugin (http://www.gsgd.co.uk/sandbox/jquery/easing/) |
|
100 |
|
|
101 |
toastr.options.showEasing = 'easeOutBounce'; |
|
102 |
toastr.options.hideEasing = 'easeInBack'; |
|
103 |
|
|
104 |
####Animation Method |
|
105 |
Use the jQuery show/hide method of your choice. These default to fadeIn/fadeOut. The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. |
|
106 |
|
|
107 |
toastr.options.showMethod = 'slideDown'; |
|
108 |
toastr.options.hideMethod = 'slideUp'; |
|
109 |
|
|
110 |
## Building Toastr |
|
111 |
|
|
112 |
To build the minified and css versions of Toastr you will need [node](http://nodejs.org) installed. |
|
113 |
|
|
114 |
Install the [Grunt](http://gruntjs.com/) command line. This might require `sudo`. |
|
115 |
|
|
116 |
```shell |
|
117 |
npm install -g grunt-cli |
|
118 |
``` |
|
119 |
|
|
120 |
Then, from the main project folder run this command. This should not require `sudo`. |
|
121 |
|
|
122 |
```shell |
|
123 |
npm install |
|
124 |
``` |
|
125 |
|
|
126 |
At this point the dependencies have been installed and you can build Toastr |
|
127 |
|
|
128 |
```shell |
|
129 |
grunt |
|
130 |
``` |
|
131 |
|
|
132 |
## Authors |
|
133 |
**Hans Fjällemark** |
|
134 |
|
|
135 |
+ http://twitter.com/hfjallemark |
|
136 |
|
|
137 |
**John Papa** |
|
138 |
|
|
139 |
+ http://twitter.com/John_Papa |
|
140 |
|
|
141 |
## Credits |
|
142 |
Inspired by https://github.com/Srirangan/notifer.js/. |
|
143 |
|
|
144 |
|
|
145 |
## Copyright |
|
146 |
Copyright © 2012 [Hans Fjällemark](http://twitter.com/hfjallemark) & [John Papa](http://twitter.com/John_Papa). |
|
147 |
|
|
148 |
## License |
|
149 |
toastr is under MIT license - http://www.opensource.org/licenses/mit-license.php |