modal-impl.js 3.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. (function (factory) {
  12. if (typeof module === "object" && typeof module.exports === "object") {
  13. var v = factory(require, exports);
  14. if (v !== undefined) module.exports = v;
  15. }
  16. else if (typeof define === "function" && define.amd) {
  17. define(["require", "exports", "../../util/util", "../app/app-constants", "./modal-component", "./modal-transitions", "../../navigation/view-controller"], factory);
  18. }
  19. })(function (require, exports) {
  20. "use strict";
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. var util_1 = require("../../util/util");
  23. var app_constants_1 = require("../app/app-constants");
  24. var modal_component_1 = require("./modal-component");
  25. var modal_transitions_1 = require("./modal-transitions");
  26. var view_controller_1 = require("../../navigation/view-controller");
  27. /**
  28. * @hidden
  29. */
  30. var ModalImpl = (function (_super) {
  31. __extends(ModalImpl, _super);
  32. function ModalImpl(app, component, data, opts, config) {
  33. if (opts === void 0) { opts = {}; }
  34. var _this = this;
  35. data = data || {};
  36. data.component = component;
  37. opts.showBackdrop = util_1.isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
  38. opts.enableBackdropDismiss = util_1.isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
  39. data.opts = opts;
  40. _this = _super.call(this, modal_component_1.ModalCmp, data, null) || this;
  41. _this._app = app;
  42. _this._enterAnimation = opts.enterAnimation;
  43. _this._leaveAnimation = opts.leaveAnimation;
  44. _this.isOverlay = true;
  45. config.setTransition('modal-slide-in', modal_transitions_1.ModalSlideIn);
  46. config.setTransition('modal-slide-out', modal_transitions_1.ModalSlideOut);
  47. config.setTransition('modal-md-slide-in', modal_transitions_1.ModalMDSlideIn);
  48. config.setTransition('modal-md-slide-out', modal_transitions_1.ModalMDSlideOut);
  49. return _this;
  50. }
  51. /**
  52. * @hidden
  53. */
  54. ModalImpl.prototype.getTransitionName = function (direction) {
  55. var key;
  56. if (direction === 'back') {
  57. if (this._leaveAnimation) {
  58. return this._leaveAnimation;
  59. }
  60. key = 'modalLeave';
  61. }
  62. else {
  63. if (this._enterAnimation) {
  64. return this._enterAnimation;
  65. }
  66. key = 'modalEnter';
  67. }
  68. return this._nav && this._nav.config.get(key);
  69. };
  70. /**
  71. * Present the action sheet instance.
  72. *
  73. * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
  74. * @returns {Promise} Returns a promise which is resolved when the transition has completed.
  75. */
  76. ModalImpl.prototype.present = function (navOptions) {
  77. if (navOptions === void 0) { navOptions = {}; }
  78. navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
  79. return this._app.present(this, navOptions, app_constants_1.PORTAL_MODAL);
  80. };
  81. return ModalImpl;
  82. }(view_controller_1.ViewController));
  83. exports.ModalImpl = ModalImpl;
  84. });
  85. //# sourceMappingURL=modal-impl.js.map