1 | import { isString } from '../util/util';
|
2 | var OverlayProxy = (function () {
|
3 | function OverlayProxy(_app, _component, _config, _deepLinker) {
|
4 | this._app = _app;
|
5 | this._component = _component;
|
6 | this._config = _config;
|
7 | this._deepLinker = _deepLinker;
|
8 | }
|
9 | OverlayProxy.prototype.getImplementation = function () {
|
10 | throw new Error('Child class must implement "getImplementation" method');
|
11 | };
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | OverlayProxy.prototype.present = function (navOptions) {
|
19 | var _this = this;
|
20 | if (navOptions === void 0) { navOptions = {}; }
|
21 |
|
22 | var isLazyLoaded = isString(this._component);
|
23 | if (isLazyLoaded) {
|
24 | return this._deepLinker.getComponentFromName(this._component).then(function (loadedComponent) {
|
25 | _this._component = loadedComponent;
|
26 | return _this.createAndPresentOverlay(navOptions);
|
27 | });
|
28 | }
|
29 | else {
|
30 | return this.createAndPresentOverlay(navOptions);
|
31 | }
|
32 | };
|
33 | OverlayProxy.prototype.dismiss = function (data, role, navOptions) {
|
34 | if (this.overlay) {
|
35 | return this.overlay.dismiss(data, role, navOptions);
|
36 | }
|
37 | };
|
38 | |
39 |
|
40 |
|
41 | OverlayProxy.prototype.onDidDismiss = function (callback) {
|
42 | this._onDidDismiss = callback;
|
43 | if (this.overlay) {
|
44 | this.overlay.onDidDismiss(this._onDidDismiss);
|
45 | }
|
46 | };
|
47 | OverlayProxy.prototype.createAndPresentOverlay = function (navOptions) {
|
48 | this.overlay = this.getImplementation();
|
49 | this.overlay.onWillDismiss(this._onWillDismiss);
|
50 | this.overlay.onDidDismiss(this._onDidDismiss);
|
51 | return this.overlay.present(navOptions);
|
52 | };
|
53 | |
54 |
|
55 |
|
56 | OverlayProxy.prototype.onWillDismiss = function (callback) {
|
57 | this._onWillDismiss = callback;
|
58 | if (this.overlay) {
|
59 | this.overlay.onWillDismiss(this._onWillDismiss);
|
60 | }
|
61 | };
|
62 | return OverlayProxy;
|
63 | }());
|
64 | export { OverlayProxy };
|
65 |
|
\ | No newline at end of file |