1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports", "../util/util"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var util_1 = require("../util/util");
  13. var OverlayProxy = (function () {
  14. function OverlayProxy(_app, _component, _config, _deepLinker) {
  15. this._app = _app;
  16. this._component = _component;
  17. this._config = _config;
  18. this._deepLinker = _deepLinker;
  19. }
  20. OverlayProxy.prototype.getImplementation = function () {
  21. throw new Error('Child class must implement "getImplementation" method');
  22. };
  23. /**
  24. * Present the modal instance.
  25. *
  26. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  27. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  28. */
  29. OverlayProxy.prototype.present = function (navOptions) {
  30. var _this = this;
  31. if (navOptions === void 0) { navOptions = {}; }
  32. // check if it's a lazy loaded component, or not
  33. var isLazyLoaded = util_1.isString(this._component);
  34. if (isLazyLoaded) {
  35. return this._deepLinker.getComponentFromName(this._component).then(function (loadedComponent) {
  36. _this._component = loadedComponent;
  37. return _this.createAndPresentOverlay(navOptions);
  38. });
  39. }
  40. else {
  41. return this.createAndPresentOverlay(navOptions);
  42. }
  43. };
  44. OverlayProxy.prototype.dismiss = function (data, role, navOptions) {
  45. if (this.overlay) {
  46. return this.overlay.dismiss(data, role, navOptions);
  47. }
  48. };
  49. /**
  50. * Called when the current viewController has be successfully dismissed
  51. */
  52. OverlayProxy.prototype.onDidDismiss = function (callback) {
  53. this._onDidDismiss = callback;
  54. if (this.overlay) {
  55. this.overlay.onDidDismiss(this._onDidDismiss);
  56. }
  57. };
  58. OverlayProxy.prototype.createAndPresentOverlay = function (navOptions) {
  59. this.overlay = this.getImplementation();
  60. this.overlay.onWillDismiss(this._onWillDismiss);
  61. this.overlay.onDidDismiss(this._onDidDismiss);
  62. return this.overlay.present(navOptions);
  63. };
  64. /**
  65. * Called when the current viewController will be dismissed
  66. */
  67. OverlayProxy.prototype.onWillDismiss = function (callback) {
  68. this._onWillDismiss = callback;
  69. if (this.overlay) {
  70. this.overlay.onWillDismiss(this._onWillDismiss);
  71. }
  72. };
  73. return OverlayProxy;
  74. }());
  75. exports.OverlayProxy = OverlayProxy;
  76. });
  77. //# sourceMappingURL=overlay-proxy.js.map