ngx-toastr 8.2.1 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -8
- package/bundles/ngx-toastr.umd.js +43 -548
- package/bundles/ngx-toastr.umd.js.map +17 -6
- package/bundles/ngx-toastr.umd.min.js +1 -1
- package/bundles/ngx-toastr.umd.min.js.map +100 -52
- package/esm2015/ngx-toastr.js +18 -2
- package/esm2015/ngx-toastr.js.map +4 -4
- package/esm5/ngx-toastr.js +47 -561
- package/esm5/ngx-toastr.js.map +8 -5
- package/ngx-toastr.metadata.json +1 -1
- package/package.json +3 -1
- package/toastr/toast-noanimation.component.d.ts +1 -0
- package/toastr/toastr-config.d.ts +2 -3
- package/toastr/toastr.service.d.ts +9 -9
@@ -1,6 +1,6 @@
|
|
1
1
|
(function (global, factory) {
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Subject'), require('@angular/platform-browser'), require('@angular/animations'), require('@angular/common')) :
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/Subject', '@angular/platform-browser', '@angular/animations', '@angular/common'], factory) :
|
3
|
+
typeof define === 'function' && define.amd ? define('ngx-toastr', ['exports', '@angular/core', 'rxjs/Subject', '@angular/platform-browser', '@angular/animations', '@angular/common'], factory) :
|
4
4
|
(factory((global['ngx-toastr'] = {}),global.ng.core,global.Rx,global.ng.platformBrowser,global.ng.animations,global.ng.common));
|
5
5
|
}(this, (function (exports,core,Subject,platformBrowser,animations,common) { 'use strict';
|
6
6
|
|
@@ -44,88 +44,41 @@ function __values(o) {
|
|
44
44
|
};
|
45
45
|
}
|
46
46
|
|
47
|
-
/**
|
48
|
-
* @fileoverview added by tsickle
|
49
|
-
* @suppress {checkTypes} checked by tsc
|
50
|
-
*/
|
51
|
-
/**
|
52
|
-
* @record
|
53
|
-
*/
|
54
|
-
/**
|
55
|
-
* A `ComponentPortal` is a portal that instantiates some Component upon attachment.
|
56
|
-
*/
|
57
47
|
var ComponentPortal = /** @class */ (function () {
|
58
|
-
/**
|
59
|
-
* @param {?} component
|
60
|
-
* @param {?} injector
|
61
|
-
*/
|
62
48
|
function ComponentPortal(component, injector) {
|
63
49
|
this.component = component;
|
64
50
|
this.injector = injector;
|
65
51
|
}
|
66
|
-
/**
|
67
|
-
* Attach this portal to a host.
|
68
|
-
* @param {?} host
|
69
|
-
* @param {?} newestOnTop
|
70
|
-
* @return {?}
|
71
|
-
*/
|
72
52
|
ComponentPortal.prototype.attach = function (host, newestOnTop) {
|
73
53
|
this._attachedHost = host;
|
74
54
|
return host.attach(this, newestOnTop);
|
75
55
|
};
|
76
|
-
/**
|
77
|
-
* Detach this portal from its host
|
78
|
-
* @return {?}
|
79
|
-
*/
|
80
56
|
ComponentPortal.prototype.detach = function () {
|
81
|
-
var
|
57
|
+
var host = this._attachedHost;
|
82
58
|
if (host) {
|
83
59
|
this._attachedHost = undefined;
|
84
60
|
return host.detach();
|
85
61
|
}
|
86
62
|
};
|
87
63
|
Object.defineProperty(ComponentPortal.prototype, "isAttached", {
|
88
|
-
/**
|
89
|
-
* Whether this portal is attached to a host.
|
90
|
-
* @return {?}
|
91
|
-
*/
|
92
64
|
get: function () {
|
93
65
|
return this._attachedHost != null;
|
94
66
|
},
|
95
67
|
enumerable: true,
|
96
68
|
configurable: true
|
97
69
|
});
|
98
|
-
/**
|
99
|
-
* Sets the PortalHost reference without performing `attach()`. This is used directly by
|
100
|
-
* the PortalHost when it is performing an `attach()` or `detach()`.
|
101
|
-
* @param {?=} host
|
102
|
-
* @return {?}
|
103
|
-
*/
|
104
70
|
ComponentPortal.prototype.setAttachedHost = function (host) {
|
105
71
|
this._attachedHost = host;
|
106
72
|
};
|
107
73
|
return ComponentPortal;
|
108
74
|
}());
|
109
|
-
/**
|
110
|
-
* Partial implementation of PortalHost that only deals with attaching a
|
111
|
-
* ComponentPortal
|
112
|
-
* @abstract
|
113
|
-
*/
|
114
75
|
var BasePortalHost = /** @class */ (function () {
|
115
76
|
function BasePortalHost() {
|
116
77
|
}
|
117
|
-
/**
|
118
|
-
* @param {?} portal
|
119
|
-
* @param {?} newestOnTop
|
120
|
-
* @return {?}
|
121
|
-
*/
|
122
78
|
BasePortalHost.prototype.attach = function (portal, newestOnTop) {
|
123
79
|
this._attachedPortal = portal;
|
124
80
|
return this.attachComponentPortal(portal, newestOnTop);
|
125
81
|
};
|
126
|
-
/**
|
127
|
-
* @return {?}
|
128
|
-
*/
|
129
82
|
BasePortalHost.prototype.detach = function () {
|
130
83
|
if (this._attachedPortal) {
|
131
84
|
this._attachedPortal.setAttachedHost();
|
@@ -136,32 +89,13 @@ var BasePortalHost = /** @class */ (function () {
|
|
136
89
|
this._disposeFn = undefined;
|
137
90
|
}
|
138
91
|
};
|
139
|
-
/**
|
140
|
-
* @param {?} fn
|
141
|
-
* @return {?}
|
142
|
-
*/
|
143
92
|
BasePortalHost.prototype.setDisposeFn = function (fn) {
|
144
93
|
this._disposeFn = fn;
|
145
94
|
};
|
146
95
|
return BasePortalHost;
|
147
96
|
}());
|
148
|
-
/**
|
149
|
-
* @fileoverview added by tsickle
|
150
|
-
* @suppress {checkTypes} checked by tsc
|
151
|
-
*/
|
152
|
-
/**
|
153
|
-
* A PortalHost for attaching portals to an arbitrary DOM element outside of the Angular
|
154
|
-
* application context.
|
155
|
-
*
|
156
|
-
* This is the only part of the portal core that directly touches the DOM.
|
157
|
-
*/
|
158
97
|
var DomPortalHost = /** @class */ (function (_super) {
|
159
98
|
__extends(DomPortalHost, _super);
|
160
|
-
/**
|
161
|
-
* @param {?} _hostDomElement
|
162
|
-
* @param {?} _componentFactoryResolver
|
163
|
-
* @param {?} _appRef
|
164
|
-
*/
|
165
99
|
function DomPortalHost(_hostDomElement, _componentFactoryResolver, _appRef) {
|
166
100
|
var _this = _super.call(this) || this;
|
167
101
|
_this._hostDomElement = _hostDomElement;
|
@@ -169,34 +103,16 @@ var DomPortalHost = /** @class */ (function (_super) {
|
|
169
103
|
_this._appRef = _appRef;
|
170
104
|
return _this;
|
171
105
|
}
|
172
|
-
/**
|
173
|
-
* Attach the given ComponentPortal to DOM element using the ComponentFactoryResolver.
|
174
|
-
* @template T
|
175
|
-
* @param {?} portal Portal to be attached
|
176
|
-
* @param {?} newestOnTop
|
177
|
-
* @return {?}
|
178
|
-
*/
|
179
106
|
DomPortalHost.prototype.attachComponentPortal = function (portal, newestOnTop) {
|
180
107
|
var _this = this;
|
181
|
-
var
|
182
|
-
var
|
183
|
-
// If the portal specifies a ViewContainerRef, we will use that as the attachment point
|
184
|
-
// for the component (in terms of Angular's component tree, not rendering).
|
185
|
-
// When the ViewContainerRef is missing, we use the factory to create the component directly
|
186
|
-
// and then manually attach the ChangeDetector for that component to the application (which
|
187
|
-
// happens automatically when using a ViewContainer).
|
108
|
+
var componentFactory = this._componentFactoryResolver.resolveComponentFactory(portal.component);
|
109
|
+
var componentRef;
|
188
110
|
componentRef = componentFactory.create(portal.injector);
|
189
|
-
// When creating a component outside of a ViewContainer, we need to manually register
|
190
|
-
// its ChangeDetector with the application. This API is unfortunately not yet published
|
191
|
-
// in Angular core. The change detector must also be deregistered when the component
|
192
|
-
// is destroyed to prevent memory leaks.
|
193
111
|
this._appRef.attachView(componentRef.hostView);
|
194
112
|
this.setDisposeFn(function () {
|
195
113
|
_this._appRef.detachView(componentRef.hostView);
|
196
114
|
componentRef.destroy();
|
197
115
|
});
|
198
|
-
// At this point the component has been instantiated, so we move it to the location in the DOM
|
199
|
-
// where we want it to be rendered.
|
200
116
|
if (newestOnTop) {
|
201
117
|
this._hostDomElement.insertBefore(this._getComponentRootNode(componentRef), this._hostDomElement.firstChild);
|
202
118
|
}
|
@@ -205,124 +121,51 @@ var DomPortalHost = /** @class */ (function (_super) {
|
|
205
121
|
}
|
206
122
|
return componentRef;
|
207
123
|
};
|
208
|
-
/**
|
209
|
-
* Gets the root HTMLElement for an instantiated component.
|
210
|
-
* @param {?} componentRef
|
211
|
-
* @return {?}
|
212
|
-
*/
|
213
124
|
DomPortalHost.prototype._getComponentRootNode = function (componentRef) {
|
214
|
-
return
|
125
|
+
return (((componentRef.hostView)).rootNodes[0]);
|
215
126
|
};
|
216
127
|
return DomPortalHost;
|
217
128
|
}(BasePortalHost));
|
218
|
-
/**
|
219
|
-
* @fileoverview added by tsickle
|
220
|
-
* @suppress {checkTypes} checked by tsc
|
221
|
-
*/
|
222
|
-
/**
|
223
|
-
* Reference to an overlay that has been created with the Overlay service.
|
224
|
-
* Used to manipulate or dispose of said overlay.
|
225
|
-
*/
|
226
129
|
var OverlayRef = /** @class */ (function () {
|
227
|
-
/**
|
228
|
-
* @param {?} _portalHost
|
229
|
-
*/
|
230
130
|
function OverlayRef(_portalHost) {
|
231
131
|
this._portalHost = _portalHost;
|
232
132
|
}
|
233
|
-
/**
|
234
|
-
* @param {?} portal
|
235
|
-
* @param {?=} newestOnTop
|
236
|
-
* @return {?}
|
237
|
-
*/
|
238
133
|
OverlayRef.prototype.attach = function (portal, newestOnTop) {
|
239
134
|
if (newestOnTop === void 0) { newestOnTop = true; }
|
240
135
|
return this._portalHost.attach(portal, newestOnTop);
|
241
136
|
};
|
242
|
-
/**
|
243
|
-
* Detaches an overlay from a portal.
|
244
|
-
* @return {?} Resolves when the overlay has been detached.
|
245
|
-
*/
|
246
137
|
OverlayRef.prototype.detach = function () {
|
247
138
|
return this._portalHost.detach();
|
248
139
|
};
|
249
140
|
return OverlayRef;
|
250
141
|
}());
|
251
|
-
/**
|
252
|
-
* @fileoverview added by tsickle
|
253
|
-
* @suppress {checkTypes} checked by tsc
|
254
|
-
*/
|
255
|
-
/**
|
256
|
-
* The OverlayContainer is the container in which all overlays will load.
|
257
|
-
* It should be provided in the root component to ensure it is properly shared.
|
258
|
-
*/
|
259
142
|
var OverlayContainer = /** @class */ (function () {
|
260
143
|
function OverlayContainer() {
|
261
144
|
}
|
262
|
-
/**
|
263
|
-
* This method returns the overlay container element. It will lazily
|
264
|
-
* create the element the first time it is called to facilitate using
|
265
|
-
* the container in non-browser environments.
|
266
|
-
* @return {?} the container element
|
267
|
-
*/
|
268
145
|
OverlayContainer.prototype.getContainerElement = function () {
|
269
146
|
if (!this._containerElement) {
|
270
147
|
this._createContainer();
|
271
148
|
}
|
272
149
|
return this._containerElement;
|
273
150
|
};
|
274
|
-
/**
|
275
|
-
* Create the overlay container element, which is simply a div
|
276
|
-
* with the 'cdk-overlay-container' class on the document body.
|
277
|
-
* @return {?}
|
278
|
-
*/
|
279
151
|
OverlayContainer.prototype._createContainer = function () {
|
280
|
-
var
|
152
|
+
var container = document.createElement('div');
|
281
153
|
container.classList.add('overlay-container');
|
282
154
|
document.body.appendChild(container);
|
283
155
|
this._containerElement = container;
|
284
156
|
};
|
285
157
|
return OverlayContainer;
|
286
158
|
}());
|
287
|
-
/**
|
288
|
-
* @fileoverview added by tsickle
|
289
|
-
* @suppress {checkTypes} checked by tsc
|
290
|
-
*/
|
291
|
-
/**
|
292
|
-
* Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
|
293
|
-
* used as a low-level building building block for other components. Dialogs, tooltips, menus,
|
294
|
-
* selects, etc. can all be built using overlays. The service should primarily be used by authors
|
295
|
-
* of re-usable components rather than developers building end-user applications.
|
296
|
-
*
|
297
|
-
* An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.
|
298
|
-
*/
|
299
159
|
var Overlay = /** @class */ (function () {
|
300
|
-
/**
|
301
|
-
* @param {?} _overlayContainer
|
302
|
-
* @param {?} _componentFactoryResolver
|
303
|
-
* @param {?} _appRef
|
304
|
-
*/
|
305
160
|
function Overlay(_overlayContainer, _componentFactoryResolver, _appRef) {
|
306
161
|
this._overlayContainer = _overlayContainer;
|
307
162
|
this._componentFactoryResolver = _componentFactoryResolver;
|
308
163
|
this._appRef = _appRef;
|
309
164
|
this._paneElements = {};
|
310
165
|
}
|
311
|
-
/**
|
312
|
-
* Creates an overlay.
|
313
|
-
* @param {?=} positionClass
|
314
|
-
* @param {?=} overlayContainer
|
315
|
-
* @return {?} A reference to the created overlay.
|
316
|
-
*/
|
317
166
|
Overlay.prototype.create = function (positionClass, overlayContainer) {
|
318
|
-
// get existing pane if possible
|
319
167
|
return this._createOverlayRef(this.getPaneElement(positionClass, overlayContainer));
|
320
168
|
};
|
321
|
-
/**
|
322
|
-
* @param {?=} positionClass
|
323
|
-
* @param {?=} overlayContainer
|
324
|
-
* @return {?}
|
325
|
-
*/
|
326
169
|
Overlay.prototype.getPaneElement = function (positionClass, overlayContainer) {
|
327
170
|
if (positionClass === void 0) { positionClass = ''; }
|
328
171
|
if (!this._paneElements[positionClass]) {
|
@@ -330,14 +173,8 @@ var Overlay = /** @class */ (function () {
|
|
330
173
|
}
|
331
174
|
return this._paneElements[positionClass];
|
332
175
|
};
|
333
|
-
/**
|
334
|
-
* Creates the DOM element for an overlay and appends it to the overlay container.
|
335
|
-
* @param {?} positionClass
|
336
|
-
* @param {?=} overlayContainer
|
337
|
-
* @return {?} Newly-created pane element
|
338
|
-
*/
|
339
176
|
Overlay.prototype._createPaneElement = function (positionClass, overlayContainer) {
|
340
|
-
var
|
177
|
+
var pane = document.createElement('div');
|
341
178
|
pane.id = 'toast-container';
|
342
179
|
pane.classList.add(positionClass);
|
343
180
|
pane.classList.add('toast-container');
|
@@ -349,19 +186,9 @@ var Overlay = /** @class */ (function () {
|
|
349
186
|
}
|
350
187
|
return pane;
|
351
188
|
};
|
352
|
-
/**
|
353
|
-
* Create a DomPortalHost into which the overlay content can be loaded.
|
354
|
-
* @param {?} pane The DOM element to turn into a portal host.
|
355
|
-
* @return {?} A portal host for the given DOM element.
|
356
|
-
*/
|
357
189
|
Overlay.prototype._createPortalHost = function (pane) {
|
358
190
|
return new DomPortalHost(pane, this._componentFactoryResolver, this._appRef);
|
359
191
|
};
|
360
|
-
/**
|
361
|
-
* Creates an OverlayRef for an overlay in the given DOM element.
|
362
|
-
* @param {?} pane DOM element for the overlay
|
363
|
-
* @return {?}
|
364
|
-
*/
|
365
192
|
Overlay.prototype._createOverlayRef = function (pane) {
|
366
193
|
return new OverlayRef(this._createPortalHost(pane));
|
367
194
|
};
|
@@ -370,33 +197,19 @@ var Overlay = /** @class */ (function () {
|
|
370
197
|
Overlay.decorators = [
|
371
198
|
{ type: core.Injectable },
|
372
199
|
];
|
373
|
-
/** @nocollapse */
|
374
200
|
Overlay.ctorParameters = function () { return [
|
375
201
|
{ type: OverlayContainer, },
|
376
202
|
{ type: core.ComponentFactoryResolver, },
|
377
203
|
{ type: core.ApplicationRef, },
|
378
204
|
]; };
|
379
|
-
/**
|
380
|
-
* Providers for Overlay and its related injectables.
|
381
|
-
*/
|
382
205
|
var OVERLAY_PROVIDERS = [
|
383
206
|
Overlay,
|
384
207
|
OverlayContainer,
|
385
208
|
];
|
386
|
-
/**
|
387
|
-
* @fileoverview added by tsickle
|
388
|
-
* @suppress {checkTypes} checked by tsc
|
389
|
-
*/
|
390
209
|
var ToastContainerDirective = /** @class */ (function () {
|
391
|
-
/**
|
392
|
-
* @param {?} el
|
393
|
-
*/
|
394
210
|
function ToastContainerDirective(el) {
|
395
211
|
this.el = el;
|
396
212
|
}
|
397
|
-
/**
|
398
|
-
* @return {?}
|
399
|
-
*/
|
400
213
|
ToastContainerDirective.prototype.getContainerElement = function () {
|
401
214
|
return this.el.nativeElement;
|
402
215
|
};
|
@@ -408,7 +221,6 @@ ToastContainerDirective.decorators = [
|
|
408
221
|
exportAs: 'toastContainer',
|
409
222
|
},] },
|
410
223
|
];
|
411
|
-
/** @nocollapse */
|
412
224
|
ToastContainerDirective.ctorParameters = function () { return [
|
413
225
|
{ type: core.ElementRef, },
|
414
226
|
]; };
|
@@ -423,36 +235,8 @@ ToastContainerModule.decorators = [
|
|
423
235
|
exports: [ToastContainerDirective],
|
424
236
|
},] },
|
425
237
|
];
|
426
|
-
/** @nocollapse */
|
427
238
|
ToastContainerModule.ctorParameters = function () { return []; };
|
428
|
-
/**
|
429
|
-
* @fileoverview added by tsickle
|
430
|
-
* @suppress {checkTypes} checked by tsc
|
431
|
-
*/
|
432
|
-
/**
|
433
|
-
* Configuration for an individual toast.
|
434
|
-
* @record
|
435
|
-
*/
|
436
|
-
/**
|
437
|
-
* @record
|
438
|
-
*/
|
439
|
-
/**
|
440
|
-
* Global Toast configuration
|
441
|
-
* Includes all IndividualConfig
|
442
|
-
* @record
|
443
|
-
*/
|
444
|
-
/**
|
445
|
-
* Everything a toast needs to launch
|
446
|
-
*/
|
447
239
|
var ToastPackage = /** @class */ (function () {
|
448
|
-
/**
|
449
|
-
* @param {?} toastId
|
450
|
-
* @param {?} config
|
451
|
-
* @param {?} message
|
452
|
-
* @param {?} title
|
453
|
-
* @param {?} toastType
|
454
|
-
* @param {?} toastRef
|
455
|
-
*/
|
456
240
|
function ToastPackage(toastId, config, message, title, toastType, toastRef) {
|
457
241
|
var _this = this;
|
458
242
|
this.toastId = toastId;
|
@@ -468,88 +252,35 @@ var ToastPackage = /** @class */ (function () {
|
|
468
252
|
_this._onTap.complete();
|
469
253
|
});
|
470
254
|
}
|
471
|
-
/**
|
472
|
-
* Fired on click
|
473
|
-
* @return {?}
|
474
|
-
*/
|
475
255
|
ToastPackage.prototype.triggerTap = function () {
|
476
256
|
this._onTap.next();
|
477
257
|
this._onTap.complete();
|
478
258
|
};
|
479
|
-
/**
|
480
|
-
* @return {?}
|
481
|
-
*/
|
482
259
|
ToastPackage.prototype.onTap = function () {
|
483
260
|
return this._onTap.asObservable();
|
484
261
|
};
|
485
|
-
/**
|
486
|
-
* available for use in custom toast
|
487
|
-
* @param {?=} action
|
488
|
-
* @return {?}
|
489
|
-
*/
|
490
262
|
ToastPackage.prototype.triggerAction = function (action) {
|
491
263
|
this._onAction.next(action);
|
492
264
|
};
|
493
|
-
/**
|
494
|
-
* @return {?}
|
495
|
-
*/
|
496
265
|
ToastPackage.prototype.onAction = function () {
|
497
266
|
return this._onAction.asObservable();
|
498
267
|
};
|
499
268
|
return ToastPackage;
|
500
269
|
}());
|
501
|
-
/**
|
502
|
-
* @record
|
503
|
-
*/
|
504
|
-
/**
|
505
|
-
* @record
|
506
|
-
*/
|
507
|
-
/**
|
508
|
-
* @record
|
509
|
-
*/
|
510
|
-
/**
|
511
|
-
* @fileoverview added by tsickle
|
512
|
-
* @suppress {checkTypes} checked by tsc
|
513
|
-
*/
|
514
|
-
/**
|
515
|
-
* Reference to a toast opened via the Toastr service.
|
516
|
-
*/
|
517
270
|
var ToastRef = /** @class */ (function () {
|
518
|
-
/**
|
519
|
-
* @param {?} _overlayRef
|
520
|
-
*/
|
521
271
|
function ToastRef(_overlayRef) {
|
522
272
|
this._overlayRef = _overlayRef;
|
523
|
-
/**
|
524
|
-
* Subject for notifying the user that the toast has finished closing.
|
525
|
-
*/
|
526
273
|
this._afterClosed = new Subject.Subject();
|
527
|
-
/**
|
528
|
-
* triggered when toast is activated
|
529
|
-
*/
|
530
274
|
this._activate = new Subject.Subject();
|
531
|
-
/**
|
532
|
-
* notifies the toast that it should close before the timeout
|
533
|
-
*/
|
534
275
|
this._manualClose = new Subject.Subject();
|
535
276
|
}
|
536
|
-
/**
|
537
|
-
* @return {?}
|
538
|
-
*/
|
539
277
|
ToastRef.prototype.manualClose = function () {
|
540
278
|
this._manualClose.next();
|
541
279
|
this._manualClose.complete();
|
542
280
|
};
|
543
|
-
/**
|
544
|
-
* @return {?}
|
545
|
-
*/
|
546
281
|
ToastRef.prototype.manualClosed = function () {
|
547
282
|
return this._manualClose.asObservable();
|
548
283
|
};
|
549
|
-
/**
|
550
|
-
* Close the toast.
|
551
|
-
* @return {?}
|
552
|
-
*/
|
553
284
|
ToastRef.prototype.close = function () {
|
554
285
|
this._overlayRef.detach();
|
555
286
|
this._afterClosed.next();
|
@@ -557,52 +288,26 @@ var ToastRef = /** @class */ (function () {
|
|
557
288
|
this._manualClose.complete();
|
558
289
|
this._activate.complete();
|
559
290
|
};
|
560
|
-
/**
|
561
|
-
* Gets an observable that is notified when the toast is finished closing.
|
562
|
-
* @return {?}
|
563
|
-
*/
|
564
291
|
ToastRef.prototype.afterClosed = function () {
|
565
292
|
return this._afterClosed.asObservable();
|
566
293
|
};
|
567
|
-
/**
|
568
|
-
* @return {?}
|
569
|
-
*/
|
570
294
|
ToastRef.prototype.isInactive = function () {
|
571
295
|
return this._activate.isStopped;
|
572
296
|
};
|
573
|
-
/**
|
574
|
-
* @return {?}
|
575
|
-
*/
|
576
297
|
ToastRef.prototype.activate = function () {
|
577
298
|
this._activate.next();
|
578
299
|
this._activate.complete();
|
579
300
|
};
|
580
|
-
/**
|
581
|
-
* Gets an observable that is notified when the toast has started opening.
|
582
|
-
* @return {?}
|
583
|
-
*/
|
584
301
|
ToastRef.prototype.afterActivate = function () {
|
585
302
|
return this._activate.asObservable();
|
586
303
|
};
|
587
304
|
return ToastRef;
|
588
305
|
}());
|
589
|
-
/**
|
590
|
-
* Custom injector type specifically for instantiating components with a toast.
|
591
|
-
*/
|
592
306
|
var ToastInjector = /** @class */ (function () {
|
593
|
-
/**
|
594
|
-
* @param {?} _toastPackage
|
595
|
-
* @param {?} _parentInjector
|
596
|
-
*/
|
597
307
|
function ToastInjector(_toastPackage, _parentInjector) {
|
598
308
|
this._toastPackage = _toastPackage;
|
599
309
|
this._parentInjector = _parentInjector;
|
600
310
|
}
|
601
|
-
/**
|
602
|
-
* @param {?} token
|
603
|
-
* @param {?=} notFoundValue
|
604
|
-
* @return {?}
|
605
|
-
*/
|
606
311
|
ToastInjector.prototype.get = function (token, notFoundValue) {
|
607
312
|
if (token === ToastPackage && this._toastPackage) {
|
608
313
|
return this._toastPackage;
|
@@ -611,29 +316,8 @@ var ToastInjector = /** @class */ (function () {
|
|
611
316
|
};
|
612
317
|
return ToastInjector;
|
613
318
|
}());
|
614
|
-
/**
|
615
|
-
* @fileoverview added by tsickle
|
616
|
-
* @suppress {checkTypes} checked by tsc
|
617
|
-
*/
|
618
|
-
/**
|
619
|
-
* @record
|
620
|
-
*/
|
621
319
|
var TOAST_CONFIG = new core.InjectionToken('ToastConfig');
|
622
|
-
/**
|
623
|
-
* @fileoverview added by tsickle
|
624
|
-
* @suppress {checkTypes} checked by tsc
|
625
|
-
*/
|
626
|
-
/**
|
627
|
-
* @record
|
628
|
-
*/
|
629
320
|
var ToastrService = /** @class */ (function () {
|
630
|
-
/**
|
631
|
-
* @param {?} token
|
632
|
-
* @param {?} overlay
|
633
|
-
* @param {?} _injector
|
634
|
-
* @param {?} sanitizer
|
635
|
-
* @param {?} ngZone
|
636
|
-
*/
|
637
321
|
function ToastrService(token, overlay, _injector, sanitizer, ngZone) {
|
638
322
|
this.overlay = overlay;
|
639
323
|
this._injector = _injector;
|
@@ -642,79 +326,37 @@ var ToastrService = /** @class */ (function () {
|
|
642
326
|
this.currentlyActive = 0;
|
643
327
|
this.toasts = [];
|
644
328
|
this.index = 0;
|
645
|
-
var
|
329
|
+
var defaultConfig = new token.defaults;
|
646
330
|
this.toastrConfig = Object.assign({}, defaultConfig, token.config);
|
647
331
|
this.toastrConfig.iconClasses = Object.assign({}, defaultConfig.iconClasses, token.config.iconClasses);
|
648
332
|
}
|
649
|
-
/**
|
650
|
-
* show toast
|
651
|
-
* @param {?=} message
|
652
|
-
* @param {?=} title
|
653
|
-
* @param {?=} override
|
654
|
-
* @param {?=} type
|
655
|
-
* @return {?}
|
656
|
-
*/
|
657
333
|
ToastrService.prototype.show = function (message, title, override, type) {
|
658
334
|
if (override === void 0) { override = {}; }
|
659
335
|
if (type === void 0) { type = ''; }
|
660
336
|
return this._preBuildNotification(type, message, title, this.applyConfig(override));
|
661
337
|
};
|
662
|
-
/**
|
663
|
-
* show successful toast
|
664
|
-
* @param {?=} message
|
665
|
-
* @param {?=} title
|
666
|
-
* @param {?=} override
|
667
|
-
* @return {?}
|
668
|
-
*/
|
669
338
|
ToastrService.prototype.success = function (message, title, override) {
|
670
339
|
if (override === void 0) { override = {}; }
|
671
|
-
var
|
340
|
+
var type = this.toastrConfig.iconClasses.success || '';
|
672
341
|
return this._preBuildNotification(type, message, title, this.applyConfig(override));
|
673
342
|
};
|
674
|
-
/**
|
675
|
-
* show error toast
|
676
|
-
* @param {?=} message
|
677
|
-
* @param {?=} title
|
678
|
-
* @param {?=} override
|
679
|
-
* @return {?}
|
680
|
-
*/
|
681
343
|
ToastrService.prototype.error = function (message, title, override) {
|
682
344
|
if (override === void 0) { override = {}; }
|
683
|
-
var
|
345
|
+
var type = this.toastrConfig.iconClasses.error || '';
|
684
346
|
return this._preBuildNotification(type, message, title, this.applyConfig(override));
|
685
347
|
};
|
686
|
-
/**
|
687
|
-
* show info toast
|
688
|
-
* @param {?=} message
|
689
|
-
* @param {?=} title
|
690
|
-
* @param {?=} override
|
691
|
-
* @return {?}
|
692
|
-
*/
|
693
348
|
ToastrService.prototype.info = function (message, title, override) {
|
694
349
|
if (override === void 0) { override = {}; }
|
695
|
-
var
|
350
|
+
var type = this.toastrConfig.iconClasses.info || '';
|
696
351
|
return this._preBuildNotification(type, message, title, this.applyConfig(override));
|
697
352
|
};
|
698
|
-
/**
|
699
|
-
* show warning toast
|
700
|
-
* @param {?=} message
|
701
|
-
* @param {?=} title
|
702
|
-
* @param {?=} override
|
703
|
-
* @return {?}
|
704
|
-
*/
|
705
353
|
ToastrService.prototype.warning = function (message, title, override) {
|
706
354
|
if (override === void 0) { override = {}; }
|
707
|
-
var
|
355
|
+
var type = this.toastrConfig.iconClasses.warning || '';
|
708
356
|
return this._preBuildNotification(type, message, title, this.applyConfig(override));
|
709
357
|
};
|
710
|
-
/**
|
711
|
-
* Remove all or a single toast by id
|
712
|
-
* @param {?=} toastId
|
713
|
-
* @return {?}
|
714
|
-
*/
|
715
358
|
ToastrService.prototype.clear = function (toastId) {
|
716
359
|
try {
|
717
|
-
// Call every toastRef manualClose function
|
718
360
|
for (var _a = __values(this.toasts), _b = _a.next(); !_b.done; _b = _a.next()) {
|
719
361
|
var toast = _b.value;
|
720
362
|
if (toastId !== undefined) {
|
@@ -737,13 +379,8 @@ var ToastrService = /** @class */ (function () {
|
|
737
379
|
}
|
738
380
|
var e_1, _c;
|
739
381
|
};
|
740
|
-
/**
|
741
|
-
* Remove and destroy a single toast by id
|
742
|
-
* @param {?} toastId
|
743
|
-
* @return {?}
|
744
|
-
*/
|
745
382
|
ToastrService.prototype.remove = function (toastId) {
|
746
|
-
var
|
383
|
+
var found = this._findToast(toastId);
|
747
384
|
if (!found) {
|
748
385
|
return false;
|
749
386
|
}
|
@@ -753,8 +390,8 @@ var ToastrService = /** @class */ (function () {
|
|
753
390
|
if (!this.toastrConfig.maxOpened || !this.toasts.length) {
|
754
391
|
return false;
|
755
392
|
}
|
756
|
-
if (this.currentlyActive
|
757
|
-
var
|
393
|
+
if (this.currentlyActive < this.toastrConfig.maxOpened && this.toasts[this.currentlyActive]) {
|
394
|
+
var p = this.toasts[this.currentlyActive].toastRef;
|
758
395
|
if (!p.isInactive()) {
|
759
396
|
this.currentlyActive = this.currentlyActive + 1;
|
760
397
|
p.activate();
|
@@ -762,49 +399,26 @@ var ToastrService = /** @class */ (function () {
|
|
762
399
|
}
|
763
400
|
return true;
|
764
401
|
};
|
765
|
-
/**
|
766
|
-
* Determines if toast message is already shown
|
767
|
-
* @param {?} message
|
768
|
-
* @return {?}
|
769
|
-
*/
|
770
402
|
ToastrService.prototype.isDuplicate = function (message) {
|
771
|
-
for (var
|
403
|
+
for (var i = 0; i < this.toasts.length; i++) {
|
772
404
|
if (this.toasts[i].message === message) {
|
773
405
|
return true;
|
774
406
|
}
|
775
407
|
}
|
776
408
|
return false;
|
777
409
|
};
|
778
|
-
/**
|
779
|
-
* create a clone of global config and apply individual settings
|
780
|
-
* @param {?=} override
|
781
|
-
* @return {?}
|
782
|
-
*/
|
783
410
|
ToastrService.prototype.applyConfig = function (override) {
|
784
411
|
if (override === void 0) { override = {}; }
|
785
412
|
return Object.assign({}, this.toastrConfig, override);
|
786
413
|
};
|
787
|
-
/**
|
788
|
-
* Find toast object by id
|
789
|
-
* @param {?} toastId
|
790
|
-
* @return {?}
|
791
|
-
*/
|
792
414
|
ToastrService.prototype._findToast = function (toastId) {
|
793
|
-
for (var
|
415
|
+
for (var i = 0; i < this.toasts.length; i++) {
|
794
416
|
if (this.toasts[i].toastId === toastId) {
|
795
417
|
return { index: i, activeToast: this.toasts[i] };
|
796
418
|
}
|
797
419
|
}
|
798
420
|
return null;
|
799
421
|
};
|
800
|
-
/**
|
801
|
-
* Determines the need to run inside angular's zone then builds the toast
|
802
|
-
* @param {?} toastType
|
803
|
-
* @param {?} message
|
804
|
-
* @param {?} title
|
805
|
-
* @param {?} config
|
806
|
-
* @return {?}
|
807
|
-
*/
|
808
422
|
ToastrService.prototype._preBuildNotification = function (toastType, message, title, config) {
|
809
423
|
var _this = this;
|
810
424
|
if (config.onActivateTick) {
|
@@ -812,43 +426,35 @@ var ToastrService = /** @class */ (function () {
|
|
812
426
|
}
|
813
427
|
return this._buildNotification(toastType, message, title, config);
|
814
428
|
};
|
815
|
-
/**
|
816
|
-
* Creates and attaches toast data to component
|
817
|
-
* returns null if toast is duplicate and preventDuplicates == True
|
818
|
-
* @param {?} toastType
|
819
|
-
* @param {?} message
|
820
|
-
* @param {?} title
|
821
|
-
* @param {?} config
|
822
|
-
* @return {?}
|
823
|
-
*/
|
824
429
|
ToastrService.prototype._buildNotification = function (toastType, message, title, config) {
|
825
430
|
var _this = this;
|
826
431
|
if (!config.toastComponent) {
|
827
432
|
throw new Error('toastComponent required');
|
828
433
|
}
|
829
|
-
// max opened and auto dismiss = true
|
830
434
|
if (message && this.toastrConfig.preventDuplicates && this.isDuplicate(message)) {
|
831
435
|
return null;
|
832
436
|
}
|
833
437
|
this.previousToastMessage = message;
|
834
|
-
var
|
438
|
+
var keepInactive = false;
|
835
439
|
if (this.toastrConfig.maxOpened && this.currentlyActive >= this.toastrConfig.maxOpened) {
|
836
440
|
keepInactive = true;
|
837
441
|
if (this.toastrConfig.autoDismiss) {
|
838
442
|
this.clear(this.toasts[this.toasts.length - 1].toastId);
|
839
443
|
}
|
840
444
|
}
|
841
|
-
var
|
445
|
+
var overlayRef = this.overlay.create(config.positionClass, this.overlayContainer);
|
842
446
|
this.index = this.index + 1;
|
843
|
-
var
|
447
|
+
var sanitizedMessage = message;
|
844
448
|
if (message && config.enableHtml) {
|
845
449
|
sanitizedMessage = this.sanitizer.sanitize(core.SecurityContext.HTML, message);
|
846
450
|
}
|
847
|
-
var
|
848
|
-
var
|
849
|
-
var
|
850
|
-
var
|
851
|
-
var
|
451
|
+
var toastRef = new ToastRef(overlayRef);
|
452
|
+
var toastPackage = new ToastPackage(this.index, config, sanitizedMessage, title, toastType, toastRef);
|
453
|
+
var toastInjector = new ToastInjector(toastPackage, this._injector);
|
454
|
+
var component = new ComponentPortal(config.toastComponent, toastInjector);
|
455
|
+
var portal = overlayRef.attach(component, this.toastrConfig.newestOnTop);
|
456
|
+
toastRef.componentInstance = ((portal))._component;
|
457
|
+
var ins = {
|
852
458
|
toastId: this.index,
|
853
459
|
message: message || '',
|
854
460
|
toastRef: toastRef,
|
@@ -856,7 +462,7 @@ var ToastrService = /** @class */ (function () {
|
|
856
462
|
onHidden: toastRef.afterClosed(),
|
857
463
|
onTap: toastPackage.onTap(),
|
858
464
|
onAction: toastPackage.onAction(),
|
859
|
-
portal:
|
465
|
+
portal: portal,
|
860
466
|
};
|
861
467
|
if (!keepInactive) {
|
862
468
|
setTimeout(function () {
|
@@ -872,7 +478,6 @@ var ToastrService = /** @class */ (function () {
|
|
872
478
|
ToastrService.decorators = [
|
873
479
|
{ type: core.Injectable },
|
874
480
|
];
|
875
|
-
/** @nocollapse */
|
876
481
|
ToastrService.ctorParameters = function () { return [
|
877
482
|
{ type: undefined, decorators: [{ type: core.Inject, args: [TOAST_CONFIG,] },] },
|
878
483
|
{ type: Overlay, },
|
@@ -880,32 +485,14 @@ ToastrService.ctorParameters = function () { return [
|
|
880
485
|
{ type: platformBrowser.DomSanitizer, },
|
881
486
|
{ type: core.NgZone, },
|
882
487
|
]; };
|
883
|
-
/**
|
884
|
-
* @fileoverview added by tsickle
|
885
|
-
* @suppress {checkTypes} checked by tsc
|
886
|
-
*/
|
887
488
|
var Toast = /** @class */ (function () {
|
888
|
-
/**
|
889
|
-
* @param {?} toastrService
|
890
|
-
* @param {?} toastPackage
|
891
|
-
* @param {?=} ngZone
|
892
|
-
*/
|
893
489
|
function Toast(toastrService, toastPackage, ngZone) {
|
894
490
|
var _this = this;
|
895
491
|
this.toastrService = toastrService;
|
896
492
|
this.toastPackage = toastPackage;
|
897
493
|
this.ngZone = ngZone;
|
898
|
-
/**
|
899
|
-
* width of progress bar
|
900
|
-
*/
|
901
494
|
this.width = -1;
|
902
|
-
/**
|
903
|
-
* a combination of toast type and options.toastClass
|
904
|
-
*/
|
905
495
|
this.toastClasses = '';
|
906
|
-
/**
|
907
|
-
* controls animation
|
908
|
-
*/
|
909
496
|
this.state = {
|
910
497
|
value: 'inactive',
|
911
498
|
params: {
|
@@ -924,19 +511,12 @@ var Toast = /** @class */ (function () {
|
|
924
511
|
_this.remove();
|
925
512
|
});
|
926
513
|
}
|
927
|
-
/**
|
928
|
-
* @return {?}
|
929
|
-
*/
|
930
514
|
Toast.prototype.ngOnDestroy = function () {
|
931
515
|
this.sub.unsubscribe();
|
932
516
|
this.sub1.unsubscribe();
|
933
517
|
clearInterval(this.intervalId);
|
934
518
|
clearTimeout(this.timeout);
|
935
519
|
};
|
936
|
-
/**
|
937
|
-
* activates toast and sets timeout
|
938
|
-
* @return {?}
|
939
|
-
*/
|
940
520
|
Toast.prototype.activateToast = function () {
|
941
521
|
var _this = this;
|
942
522
|
this.state = Object.assign({}, this.state, { value: 'active' });
|
@@ -948,16 +528,12 @@ var Toast = /** @class */ (function () {
|
|
948
528
|
}
|
949
529
|
}
|
950
530
|
};
|
951
|
-
/**
|
952
|
-
* updates progress bar width
|
953
|
-
* @return {?}
|
954
|
-
*/
|
955
531
|
Toast.prototype.updateProgress = function () {
|
956
532
|
if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
|
957
533
|
return;
|
958
534
|
}
|
959
|
-
var
|
960
|
-
var
|
535
|
+
var now = new Date().getTime();
|
536
|
+
var remaining = this.hideTime - now;
|
961
537
|
this.width = (remaining / this.options.timeOut) * 100;
|
962
538
|
if (this.options.progressAnimation === 'increasing') {
|
963
539
|
this.width = 100 - this.width;
|
@@ -969,10 +545,6 @@ var Toast = /** @class */ (function () {
|
|
969
545
|
this.width = 100;
|
970
546
|
}
|
971
547
|
};
|
972
|
-
/**
|
973
|
-
* tells toastrService to remove this toast after animation time
|
974
|
-
* @return {?}
|
975
|
-
*/
|
976
548
|
Toast.prototype.remove = function () {
|
977
549
|
var _this = this;
|
978
550
|
if (this.state.value === 'removed') {
|
@@ -982,9 +554,6 @@ var Toast = /** @class */ (function () {
|
|
982
554
|
this.state = Object.assign({}, this.state, { value: 'removed' });
|
983
555
|
this.outsideTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); }, +this.toastPackage.config.easeTime);
|
984
556
|
};
|
985
|
-
/**
|
986
|
-
* @return {?}
|
987
|
-
*/
|
988
557
|
Toast.prototype.tapToast = function () {
|
989
558
|
if (this.state.value === 'removed') {
|
990
559
|
return;
|
@@ -994,9 +563,6 @@ var Toast = /** @class */ (function () {
|
|
994
563
|
this.remove();
|
995
564
|
}
|
996
565
|
};
|
997
|
-
/**
|
998
|
-
* @return {?}
|
999
|
-
*/
|
1000
566
|
Toast.prototype.stickAround = function () {
|
1001
567
|
if (this.state.value === 'removed') {
|
1002
568
|
return;
|
@@ -1004,13 +570,9 @@ var Toast = /** @class */ (function () {
|
|
1004
570
|
clearTimeout(this.timeout);
|
1005
571
|
this.options.timeOut = 0;
|
1006
572
|
this.hideTime = 0;
|
1007
|
-
// disable progressBar
|
1008
573
|
clearInterval(this.intervalId);
|
1009
574
|
this.width = 0;
|
1010
575
|
};
|
1011
|
-
/**
|
1012
|
-
* @return {?}
|
1013
|
-
*/
|
1014
576
|
Toast.prototype.delayedHideToast = function () {
|
1015
577
|
var _this = this;
|
1016
578
|
if (this.options.disableTimeOut
|
@@ -1026,11 +588,6 @@ var Toast = /** @class */ (function () {
|
|
1026
588
|
this.outsideInterval(function () { return _this.updateProgress(); }, 10);
|
1027
589
|
}
|
1028
590
|
};
|
1029
|
-
/**
|
1030
|
-
* @param {?} func
|
1031
|
-
* @param {?} timeout
|
1032
|
-
* @return {?}
|
1033
|
-
*/
|
1034
591
|
Toast.prototype.outsideTimeout = function (func, timeout) {
|
1035
592
|
var _this = this;
|
1036
593
|
if (this.ngZone) {
|
@@ -1040,11 +597,6 @@ var Toast = /** @class */ (function () {
|
|
1040
597
|
this.timeout = setTimeout(function () { return func(); }, timeout);
|
1041
598
|
}
|
1042
599
|
};
|
1043
|
-
/**
|
1044
|
-
* @param {?} func
|
1045
|
-
* @param {?} timeout
|
1046
|
-
* @return {?}
|
1047
|
-
*/
|
1048
600
|
Toast.prototype.outsideInterval = function (func, timeout) {
|
1049
601
|
var _this = this;
|
1050
602
|
if (this.ngZone) {
|
@@ -1054,10 +606,6 @@ var Toast = /** @class */ (function () {
|
|
1054
606
|
this.intervalId = setInterval(function () { return func(); }, timeout);
|
1055
607
|
}
|
1056
608
|
};
|
1057
|
-
/**
|
1058
|
-
* @param {?} func
|
1059
|
-
* @return {?}
|
1060
|
-
*/
|
1061
609
|
Toast.prototype.runInsideAngular = function (func) {
|
1062
610
|
if (this.ngZone) {
|
1063
611
|
this.ngZone.run(function () { return func(); });
|
@@ -1087,7 +635,6 @@ Toast.decorators = [
|
|
1087
635
|
preserveWhitespaces: false,
|
1088
636
|
},] },
|
1089
637
|
];
|
1090
|
-
/** @nocollapse */
|
1091
638
|
Toast.ctorParameters = function () { return [
|
1092
639
|
{ type: ToastrService, },
|
1093
640
|
{ type: ToastPackage, },
|
@@ -1100,13 +647,8 @@ Toast.propDecorators = {
|
|
1100
647
|
"stickAround": [{ type: core.HostListener, args: ['mouseenter',] },],
|
1101
648
|
"delayedHideToast": [{ type: core.HostListener, args: ['mouseleave',] },],
|
1102
649
|
};
|
1103
|
-
/**
|
1104
|
-
* @fileoverview added by tsickle
|
1105
|
-
* @suppress {checkTypes} checked by tsc
|
1106
|
-
*/
|
1107
650
|
var DefaultGlobalConfig = /** @class */ (function () {
|
1108
651
|
function DefaultGlobalConfig() {
|
1109
|
-
// Global
|
1110
652
|
this.maxOpened = 0;
|
1111
653
|
this.autoDismiss = false;
|
1112
654
|
this.newestOnTop = true;
|
@@ -1117,7 +659,6 @@ var DefaultGlobalConfig = /** @class */ (function () {
|
|
1117
659
|
success: 'toast-success',
|
1118
660
|
warning: 'toast-warning',
|
1119
661
|
};
|
1120
|
-
// Individual
|
1121
662
|
this.toastComponent = Toast;
|
1122
663
|
this.closeButton = false;
|
1123
664
|
this.timeOut = 5000;
|
@@ -1136,23 +677,12 @@ var DefaultGlobalConfig = /** @class */ (function () {
|
|
1136
677
|
}
|
1137
678
|
return DefaultGlobalConfig;
|
1138
679
|
}());
|
1139
|
-
/**
|
1140
|
-
* @fileoverview added by tsickle
|
1141
|
-
* @suppress {checkTypes} checked by tsc
|
1142
|
-
*/
|
1143
680
|
var ToastrModule = /** @class */ (function () {
|
1144
|
-
/**
|
1145
|
-
* @param {?} parentModule
|
1146
|
-
*/
|
1147
681
|
function ToastrModule(parentModule) {
|
1148
682
|
if (parentModule) {
|
1149
683
|
throw new Error('ToastrModule is already loaded. It should only be imported in your application\'s main module.');
|
1150
684
|
}
|
1151
685
|
}
|
1152
|
-
/**
|
1153
|
-
* @param {?=} config
|
1154
|
-
* @return {?}
|
1155
|
-
*/
|
1156
686
|
ToastrModule.forRoot = function (config) {
|
1157
687
|
if (config === void 0) { config = {}; }
|
1158
688
|
return {
|
@@ -1175,36 +705,17 @@ ToastrModule.decorators = [
|
|
1175
705
|
entryComponents: [Toast],
|
1176
706
|
},] },
|
1177
707
|
];
|
1178
|
-
/** @nocollapse */
|
1179
708
|
ToastrModule.ctorParameters = function () { return [
|
1180
709
|
{ type: ToastrModule, decorators: [{ type: core.Optional }, { type: core.SkipSelf },] },
|
1181
710
|
]; };
|
1182
|
-
/**
|
1183
|
-
* @fileoverview added by tsickle
|
1184
|
-
* @suppress {checkTypes} checked by tsc
|
1185
|
-
*/
|
1186
711
|
var ToastNoAnimation = /** @class */ (function () {
|
1187
|
-
/**
|
1188
|
-
* @param {?} toastrService
|
1189
|
-
* @param {?} toastPackage
|
1190
|
-
* @param {?} appRef
|
1191
|
-
*/
|
1192
712
|
function ToastNoAnimation(toastrService, toastPackage, appRef) {
|
1193
713
|
var _this = this;
|
1194
714
|
this.toastrService = toastrService;
|
1195
715
|
this.toastPackage = toastPackage;
|
1196
716
|
this.appRef = appRef;
|
1197
|
-
/**
|
1198
|
-
* width of progress bar
|
1199
|
-
*/
|
1200
717
|
this.width = -1;
|
1201
|
-
/**
|
1202
|
-
* a combination of toast type and options.toastClass
|
1203
|
-
*/
|
1204
718
|
this.toastClasses = '';
|
1205
|
-
/**
|
1206
|
-
* controls animation
|
1207
|
-
*/
|
1208
719
|
this.state = 'inactive';
|
1209
720
|
this.message = toastPackage.message;
|
1210
721
|
this.title = toastPackage.title;
|
@@ -1217,19 +728,22 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1217
728
|
_this.remove();
|
1218
729
|
});
|
1219
730
|
}
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
731
|
+
Object.defineProperty(ToastNoAnimation.prototype, "displayStyle", {
|
732
|
+
get: function () {
|
733
|
+
if (this.state === 'inactive') {
|
734
|
+
return 'none';
|
735
|
+
}
|
736
|
+
return 'inherit';
|
737
|
+
},
|
738
|
+
enumerable: true,
|
739
|
+
configurable: true
|
740
|
+
});
|
1223
741
|
ToastNoAnimation.prototype.ngOnDestroy = function () {
|
1224
742
|
this.sub.unsubscribe();
|
1225
743
|
this.sub1.unsubscribe();
|
1226
744
|
clearInterval(this.intervalId);
|
1227
745
|
clearTimeout(this.timeout);
|
1228
746
|
};
|
1229
|
-
/**
|
1230
|
-
* activates toast and sets timeout
|
1231
|
-
* @return {?}
|
1232
|
-
*/
|
1233
747
|
ToastNoAnimation.prototype.activateToast = function () {
|
1234
748
|
var _this = this;
|
1235
749
|
this.state = 'active';
|
@@ -1246,16 +760,12 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1246
760
|
this.appRef.tick();
|
1247
761
|
}
|
1248
762
|
};
|
1249
|
-
/**
|
1250
|
-
* updates progress bar width
|
1251
|
-
* @return {?}
|
1252
|
-
*/
|
1253
763
|
ToastNoAnimation.prototype.updateProgress = function () {
|
1254
764
|
if (this.width === 0 || this.width === 100 || !this.options.timeOut) {
|
1255
765
|
return;
|
1256
766
|
}
|
1257
|
-
var
|
1258
|
-
var
|
767
|
+
var now = new Date().getTime();
|
768
|
+
var remaining = this.hideTime - now;
|
1259
769
|
this.width = remaining / this.options.timeOut * 100;
|
1260
770
|
if (this.options.progressAnimation === 'increasing') {
|
1261
771
|
this.width = 100 - this.width;
|
@@ -1267,10 +777,6 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1267
777
|
this.width = 100;
|
1268
778
|
}
|
1269
779
|
};
|
1270
|
-
/**
|
1271
|
-
* tells toastrService to remove this toast after animation time
|
1272
|
-
* @return {?}
|
1273
|
-
*/
|
1274
780
|
ToastNoAnimation.prototype.remove = function () {
|
1275
781
|
var _this = this;
|
1276
782
|
if (this.state === 'removed') {
|
@@ -1280,9 +786,6 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1280
786
|
this.state = 'removed';
|
1281
787
|
this.timeout = setTimeout(function () { return _this.toastrService.remove(_this.toastPackage.toastId); });
|
1282
788
|
};
|
1283
|
-
/**
|
1284
|
-
* @return {?}
|
1285
|
-
*/
|
1286
789
|
ToastNoAnimation.prototype.tapToast = function () {
|
1287
790
|
if (this.state === 'removed') {
|
1288
791
|
return;
|
@@ -1292,9 +795,6 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1292
795
|
this.remove();
|
1293
796
|
}
|
1294
797
|
};
|
1295
|
-
/**
|
1296
|
-
* @return {?}
|
1297
|
-
*/
|
1298
798
|
ToastNoAnimation.prototype.stickAround = function () {
|
1299
799
|
if (this.state === 'removed') {
|
1300
800
|
return;
|
@@ -1302,13 +802,9 @@ var ToastNoAnimation = /** @class */ (function () {
|
|
1302
802
|
clearTimeout(this.timeout);
|
1303
803
|
this.options.timeOut = 0;
|
1304
804
|
this.hideTime = 0;
|
1305
|
-
// disable progressBar
|
1306
805
|
clearInterval(this.intervalId);
|
1307
806
|
this.width = 0;
|
1308
807
|
};
|
1309
|
-
/**
|
1310
|
-
* @return {?}
|
1311
|
-
*/
|
1312
808
|
ToastNoAnimation.prototype.delayedHideToast = function () {
|
1313
809
|
var _this = this;
|
1314
810
|
if (this.options.disableTimeOut
|
@@ -1332,7 +828,6 @@ ToastNoAnimation.decorators = [
|
|
1332
828
|
template: "\n <button *ngIf=\"options.closeButton\" (click)=\"remove()\" class=\"toast-close-button\" aria-label=\"Close\">\n <span aria-hidden=\"true\">×</span>\n </button>\n <div *ngIf=\"title\" [class]=\"options.titleClass\" [attr.aria-label]=\"title\">\n {{ title }}\n </div>\n <div *ngIf=\"message && options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [innerHTML]=\"message\">\n </div>\n <div *ngIf=\"message && !options.enableHtml\" role=\"alert\" aria-live=\"polite\"\n [class]=\"options.messageClass\" [attr.aria-label]=\"message\">\n {{ message }}\n </div>\n <div *ngIf=\"options.progressBar\">\n <div class=\"toast-progress\" [style.width]=\"width + '%'\"></div>\n </div>\n ",
|
1333
829
|
},] },
|
1334
830
|
];
|
1335
|
-
/** @nocollapse */
|
1336
831
|
ToastNoAnimation.ctorParameters = function () { return [
|
1337
832
|
{ type: ToastrService, },
|
1338
833
|
{ type: ToastPackage, },
|
@@ -1340,6 +835,7 @@ ToastNoAnimation.ctorParameters = function () { return [
|
|
1340
835
|
]; };
|
1341
836
|
ToastNoAnimation.propDecorators = {
|
1342
837
|
"toastClasses": [{ type: core.HostBinding, args: ['class',] },],
|
838
|
+
"displayStyle": [{ type: core.HostBinding, args: ['style.display',] },],
|
1343
839
|
"tapToast": [{ type: core.HostListener, args: ['click',] },],
|
1344
840
|
"stickAround": [{ type: core.HostListener, args: ['mouseenter',] },],
|
1345
841
|
"delayedHideToast": [{ type: core.HostListener, args: ['mouseleave',] },],
|
@@ -1357,7 +853,6 @@ ToastNoAnimationModule.decorators = [
|
|
1357
853
|
entryComponents: [ToastNoAnimation],
|
1358
854
|
},] },
|
1359
855
|
];
|
1360
|
-
/** @nocollapse */
|
1361
856
|
ToastNoAnimationModule.ctorParameters = function () { return []; };
|
1362
857
|
|
1363
858
|
exports.ComponentPortal = ComponentPortal;
|