Skip to content

Commit d72f91d

Browse files
committed
Adds a flag to see whether a toast is opened or not
Fixes #75
1 parent f75f952 commit d72f91d

File tree

7 files changed

+33
-5
lines changed

7 files changed

+33
-5
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ app.controller('foo', function($scope, toastr) {
103103

104104
If no toast is passed in, all toasts will be closed.
105105

106+
#### Other options
107+
108+
A toast has a `isOpened` flag to see whether it is opened or not.
109+
106110
### Toastr customization
107111

108112
You can customize the entire library like:
@@ -111,6 +115,7 @@ You can customize the entire library like:
111115
app.config(function(toastrConfig) {
112116
angular.extend(toastrConfig, {
113117
allowHtml: false,
118+
autoDismiss: false,
114119
closeButton: false,
115120
closeHtml: '<button>&times;</button>',
116121
containerId: 'toast-container',
@@ -121,8 +126,7 @@ app.config(function(toastrConfig) {
121126
success: 'toast-success',
122127
warning: 'toast-warning'
123128
},
124-
maxOpened: 0,
125-
autoDismiss: false,
129+
maxOpened: 0,
126130
messageClass: 'toast-message',
127131
newestOnTop: true,
128132
onHidden: null,
@@ -146,13 +150,13 @@ app.config(function(toastrConfig) {
146150
Those are the default values, you can pick what you need from it and override with your values.
147151

148152
* **allowHtml**: Your toast can use custom HTML here (See [Issue 3](https://github.com/Foxandxss/angular-toastr/issues/3))
153+
* **autoDismiss** If set, show only the most recent `maxOpened` toast(s)
149154
* **closeButton**: Whether to display an "X" close button on the toast.
150155
* **closeHtml**: Html element to be used as a close button.
151156
* **containerId**: The name of the container where you want to append your toasts (the container will be created for you).
152157
* **extendedTimeOut**: The timeout after you hover a toast.
153158
* **iconClasses**: The default type classes for the different toasts.
154159
* **maxOpened**: Maximum number of toasts displayed at once.
155-
* **autoDismiss** If set, show only the most recent `maxOpened` toast(s)
156160
* **messageClass**: The class for the toast's message.
157161
* **newestOnTop**: Add new toasts on top of the old one. Put on false to put them on the bottom.
158162
* **onHidden**: A callback function called when a toast gets hidden.

dist/angular-toastr.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
if (toast && ! toast.deleting) { // Avoid clicking when fading out
6464
toast.deleting = true;
65+
toast.isOpened = false;
6566
$animate.leave(toast.el).then(function() {
6667
if (toast.scope.options.onHidden) {
6768
toast.scope.options.onHidden(wasClicked);
@@ -157,6 +158,7 @@
157158

158159
newToast.open.promise.then(function() {
159160
_createOrGetContainer(options).then(function() {
161+
newToast.isOpened = true;
160162
if (options.newestOnTop) {
161163
$animate.enter(newToast.el, container).then(function() {
162164
newToast.scope.init();
@@ -204,6 +206,7 @@
204206
function createToast() {
205207
var newToast = {
206208
toastId: index++,
209+
isOpened: false,
207210
scope: $rootScope.$new(),
208211
open: $q.defer()
209212
};

dist/angular-toastr.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-toastr.tpls.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
if (toast && ! toast.deleting) { // Avoid clicking when fading out
6464
toast.deleting = true;
65+
toast.isOpened = false;
6566
$animate.leave(toast.el).then(function() {
6667
if (toast.scope.options.onHidden) {
6768
toast.scope.options.onHidden(wasClicked);
@@ -157,6 +158,7 @@
157158

158159
newToast.open.promise.then(function() {
159160
_createOrGetContainer(options).then(function() {
161+
newToast.isOpened = true;
160162
if (options.newestOnTop) {
161163
$animate.enter(newToast.el, container).then(function() {
162164
newToast.scope.init();
@@ -204,6 +206,7 @@
204206
function createToast() {
205207
var newToast = {
206208
toastId: index++,
209+
isOpened: false,
207210
scope: $rootScope.$new(),
208211
open: $q.defer()
209212
};

0 commit comments

Comments
 (0)