1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = Object.setPrototypeOf ||
|
3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5 | return function (d, b) {
|
6 | extendStatics(d, b);
|
7 | function __() { this.constructor = d; }
|
8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9 | };
|
10 | })();
|
11 | import { isPresent } from '../../util/util';
|
12 | import { PORTAL_TOAST } from '../app/app-constants';
|
13 | import { ToastCmp } from './toast-component';
|
14 | import { ToastMdSlideIn, ToastMdSlideOut, ToastSlideIn, ToastSlideOut, ToastWpPopIn, ToastWpPopOut } from './toast-transitions';
|
15 | import { ViewController } from '../../navigation/view-controller';
|
16 |
|
17 |
|
18 |
|
19 | var Toast = (function (_super) {
|
20 | __extends(Toast, _super);
|
21 | function Toast(app, opts, config) {
|
22 | if (opts === void 0) { opts = {}; }
|
23 | var _this = this;
|
24 | opts.dismissOnPageChange = isPresent(opts.dismissOnPageChange) ? !!opts.dismissOnPageChange : false;
|
25 | _this = _super.call(this, ToastCmp, opts, null) || this;
|
26 | _this._app = app;
|
27 |
|
28 | if (!opts.position || !_this.isValidPosition(opts.position)) {
|
29 | opts.position = TOAST_POSITION_BOTTOM;
|
30 | }
|
31 | _this.isOverlay = true;
|
32 | config.setTransition('toast-slide-in', ToastSlideIn);
|
33 | config.setTransition('toast-slide-out', ToastSlideOut);
|
34 | config.setTransition('toast-md-slide-in', ToastMdSlideIn);
|
35 | config.setTransition('toast-md-slide-out', ToastMdSlideOut);
|
36 | config.setTransition('toast-wp-slide-out', ToastWpPopOut);
|
37 | config.setTransition('toast-wp-slide-in', ToastWpPopIn);
|
38 | return _this;
|
39 | }
|
40 | |
41 |
|
42 |
|
43 | Toast.prototype.getTransitionName = function (direction) {
|
44 | var key = 'toast' + (direction === 'back' ? 'Leave' : 'Enter');
|
45 | return this._nav && this._nav.config.get(key);
|
46 | };
|
47 | |
48 |
|
49 |
|
50 | Toast.prototype.isValidPosition = function (position) {
|
51 | return position === TOAST_POSITION_TOP || position === TOAST_POSITION_MIDDLE || position === TOAST_POSITION_BOTTOM;
|
52 | };
|
53 | |
54 |
|
55 |
|
56 | Toast.prototype.setMessage = function (message) {
|
57 | this.data.message = message;
|
58 | return this;
|
59 | };
|
60 | |
61 |
|
62 |
|
63 | Toast.prototype.setDuration = function (dur) {
|
64 | this.data.duration = dur;
|
65 | return this;
|
66 | };
|
67 | |
68 |
|
69 |
|
70 | Toast.prototype.setPosition = function (pos) {
|
71 | this.data.position = pos;
|
72 | return this;
|
73 | };
|
74 | |
75 |
|
76 |
|
77 | Toast.prototype.setCssClass = function (cssClass) {
|
78 | this.data.cssClass = cssClass;
|
79 | return this;
|
80 | };
|
81 | |
82 |
|
83 |
|
84 | Toast.prototype.setShowCloseButton = function (closeButton) {
|
85 | this.data.showCloseButton = closeButton;
|
86 | return this;
|
87 | };
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | Toast.prototype.present = function (navOptions) {
|
95 | if (navOptions === void 0) { navOptions = {}; }
|
96 | navOptions.disableApp = false;
|
97 | navOptions.keyboardClose = false;
|
98 | return this._app.present(this, navOptions, PORTAL_TOAST);
|
99 | };
|
100 | |
101 |
|
102 |
|
103 | Toast.prototype.dismissAll = function () {
|
104 | this._nav && this._nav.popAll();
|
105 | };
|
106 | return Toast;
|
107 | }(ViewController));
|
108 | export { Toast };
|
109 | var TOAST_POSITION_TOP = 'top';
|
110 | var TOAST_POSITION_MIDDLE = 'middle';
|
111 | var TOAST_POSITION_BOTTOM = 'bottom';
|
112 |
|
\ | No newline at end of file |