dialog.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. "use strict";
  2. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  6. return c > 3 && r && Object.defineProperty(target, key, r), r;
  7. };
  8. var __metadata = (this && this.__metadata) || function (k, v) {
  9. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var animations_1 = require("@angular/animations");
  14. var common_1 = require("@angular/common");
  15. var domhandler_1 = require("../dom/domhandler");
  16. var shared_1 = require("../common/shared");
  17. var idx = 0;
  18. var Dialog = /** @class */ (function () {
  19. function Dialog(el, renderer, zone) {
  20. this.el = el;
  21. this.renderer = renderer;
  22. this.zone = zone;
  23. this.draggable = true;
  24. this.resizable = true;
  25. this.closeOnEscape = true;
  26. this.closable = true;
  27. this.responsive = true;
  28. this.showHeader = true;
  29. this.breakpoint = 640;
  30. this.blockScroll = false;
  31. this.autoZIndex = true;
  32. this.baseZIndex = 0;
  33. this.minX = 0;
  34. this.minY = 0;
  35. this.focusOnShow = true;
  36. this.focusTrap = true;
  37. this.transitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)';
  38. this.closeIcon = 'pi pi-times';
  39. this.minimizeIcon = 'pi pi-window-minimize';
  40. this.maximizeIcon = 'pi pi-window-maximize';
  41. this.onShow = new core_1.EventEmitter();
  42. this.onHide = new core_1.EventEmitter();
  43. this.visibleChange = new core_1.EventEmitter();
  44. this.id = "ui-dialog-" + idx++;
  45. }
  46. Object.defineProperty(Dialog.prototype, "width", {
  47. get: function () {
  48. return this._width;
  49. },
  50. set: function (val) {
  51. this._width = val;
  52. console.warn("width property is deprecated, use style to define the width of the Dialog.");
  53. },
  54. enumerable: true,
  55. configurable: true
  56. });
  57. Object.defineProperty(Dialog.prototype, "height", {
  58. get: function () {
  59. return this._height;
  60. },
  61. set: function (val) {
  62. this._height = val;
  63. console.warn("height property is deprecated, use style to define the height of the Dialog.");
  64. },
  65. enumerable: true,
  66. configurable: true
  67. });
  68. Object.defineProperty(Dialog.prototype, "minWidth", {
  69. get: function () {
  70. return this._minWidth;
  71. },
  72. set: function (val) {
  73. this._minWidth = val;
  74. console.warn("minWidth property is deprecated, use style to define the minWidth of the Dialog.");
  75. },
  76. enumerable: true,
  77. configurable: true
  78. });
  79. Object.defineProperty(Dialog.prototype, "minHeight", {
  80. get: function () {
  81. return this._minHeight;
  82. },
  83. set: function (val) {
  84. this._minHeight = val;
  85. console.warn("minHeight property is deprecated, use style to define the minHeight of the Dialog.");
  86. },
  87. enumerable: true,
  88. configurable: true
  89. });
  90. Dialog.prototype.focus = function () {
  91. var focusable = domhandler_1.DomHandler.findSingle(this.container, 'button');
  92. if (focusable) {
  93. this.zone.runOutsideAngular(function () {
  94. setTimeout(function () { return focusable.focus(); }, 5);
  95. });
  96. }
  97. };
  98. Dialog.prototype.positionOverlay = function () {
  99. var viewport = domhandler_1.DomHandler.getViewport();
  100. if (domhandler_1.DomHandler.getOuterHeight(this.container) + this.contentViewChild.nativeElement.scrollHeight - this.contentViewChild.nativeElement.clientHeight > viewport.height) {
  101. this.contentViewChild.nativeElement.style.height = (viewport.height * .75) + 'px';
  102. this.container.style.height = 'auto';
  103. }
  104. else {
  105. this.contentViewChild.nativeElement.style.height = null;
  106. if (this.height) {
  107. this.container.style.height = this.height + 'px';
  108. }
  109. }
  110. if (this.positionLeft >= 0 && this.positionTop >= 0) {
  111. this.container.style.left = this.positionLeft + 'px';
  112. this.container.style.top = this.positionTop + 'px';
  113. }
  114. else if (this.positionTop >= 0) {
  115. this.center();
  116. this.container.style.top = this.positionTop + 'px';
  117. }
  118. else {
  119. this.center();
  120. }
  121. };
  122. Dialog.prototype.close = function (event) {
  123. this.visibleChange.emit(false);
  124. event.preventDefault();
  125. };
  126. Dialog.prototype.center = function () {
  127. var elementWidth = domhandler_1.DomHandler.getOuterWidth(this.container);
  128. var elementHeight = domhandler_1.DomHandler.getOuterHeight(this.container);
  129. if (elementWidth == 0 && elementHeight == 0) {
  130. this.container.style.visibility = 'hidden';
  131. this.container.style.display = 'block';
  132. elementWidth = domhandler_1.DomHandler.getOuterWidth(this.container);
  133. elementHeight = domhandler_1.DomHandler.getOuterHeight(this.container);
  134. this.container.style.display = 'none';
  135. this.container.style.visibility = 'visible';
  136. }
  137. var viewport = domhandler_1.DomHandler.getViewport();
  138. var x = Math.max(Math.floor((viewport.width - elementWidth) / 2), 0);
  139. var y = Math.max(Math.floor((viewport.height - elementHeight) / 2), 0);
  140. this.container.style.left = x + 'px';
  141. this.container.style.top = y + 'px';
  142. };
  143. Dialog.prototype.enableModality = function () {
  144. var _this = this;
  145. if (!this.mask) {
  146. this.mask = document.createElement('div');
  147. this.mask.style.zIndex = String(parseInt(this.container.style.zIndex) - 1);
  148. var maskStyleClass = 'ui-widget-overlay ui-dialog-mask';
  149. if (this.blockScroll) {
  150. maskStyleClass += ' ui-dialog-mask-scrollblocker';
  151. }
  152. domhandler_1.DomHandler.addMultipleClasses(this.mask, maskStyleClass);
  153. if (this.closable && this.dismissableMask) {
  154. this.maskClickListener = this.renderer.listen(this.mask, 'click', function (event) {
  155. _this.close(event);
  156. });
  157. }
  158. document.body.appendChild(this.mask);
  159. if (this.blockScroll) {
  160. domhandler_1.DomHandler.addClass(document.body, 'ui-overflow-hidden');
  161. }
  162. }
  163. };
  164. Dialog.prototype.disableModality = function () {
  165. if (this.mask) {
  166. this.unbindMaskClickListener();
  167. document.body.removeChild(this.mask);
  168. if (this.blockScroll) {
  169. var bodyChildren = document.body.children;
  170. var hasBlockerMasks = void 0;
  171. for (var i = 0; i < bodyChildren.length; i++) {
  172. var bodyChild = bodyChildren[i];
  173. if (domhandler_1.DomHandler.hasClass(bodyChild, 'ui-dialog-mask-scrollblocker')) {
  174. hasBlockerMasks = true;
  175. break;
  176. }
  177. }
  178. if (!hasBlockerMasks) {
  179. domhandler_1.DomHandler.removeClass(document.body, 'ui-overflow-hidden');
  180. }
  181. }
  182. this.mask = null;
  183. }
  184. };
  185. Dialog.prototype.toggleMaximize = function (event) {
  186. if (this.maximized)
  187. this.revertMaximize();
  188. else
  189. this.maximize();
  190. event.preventDefault();
  191. };
  192. Dialog.prototype.maximize = function () {
  193. this.preMaximizePageX = parseFloat(this.container.style.top);
  194. this.preMaximizePageY = parseFloat(this.container.style.left);
  195. this.preMaximizeContainerWidth = domhandler_1.DomHandler.getOuterWidth(this.container);
  196. this.preMaximizeContainerHeight = domhandler_1.DomHandler.getOuterHeight(this.container);
  197. this.preMaximizeContentHeight = domhandler_1.DomHandler.getOuterHeight(this.contentViewChild.nativeElement);
  198. this.container.style.top = '0px';
  199. this.container.style.left = '0px';
  200. this.container.style.width = '100vw';
  201. this.container.style.height = '100vh';
  202. var diffHeight = parseFloat(this.container.style.top);
  203. if (this.headerViewChild && this.headerViewChild.nativeElement) {
  204. diffHeight += domhandler_1.DomHandler.getOuterHeight(this.headerViewChild.nativeElement);
  205. }
  206. if (this.footerViewChild && this.footerViewChild.nativeElement) {
  207. diffHeight += domhandler_1.DomHandler.getOuterHeight(this.footerViewChild.nativeElement);
  208. }
  209. this.contentViewChild.nativeElement.style.height = 'calc(100vh - ' + diffHeight + 'px)';
  210. domhandler_1.DomHandler.addClass(this.container, 'ui-dialog-maximized');
  211. if (!this.blockScroll) {
  212. domhandler_1.DomHandler.addClass(document.body, 'ui-overflow-hidden');
  213. }
  214. this.moveOnTop();
  215. this.maximized = true;
  216. };
  217. Dialog.prototype.revertMaximize = function () {
  218. var _this = this;
  219. this.container.style.top = this.preMaximizePageX + 'px';
  220. this.container.style.left = this.preMaximizePageY + 'px';
  221. this.container.style.width = this.preMaximizeContainerWidth + 'px';
  222. this.container.style.height = this.preMaximizeContainerHeight + 'px';
  223. this.contentViewChild.nativeElement.style.height = this.preMaximizeContentHeight + 'px';
  224. if (!this.blockScroll) {
  225. domhandler_1.DomHandler.removeClass(document.body, 'ui-overflow-hidden');
  226. }
  227. this.maximized = false;
  228. this.zone.runOutsideAngular(function () {
  229. setTimeout(function () { return domhandler_1.DomHandler.removeClass(_this.container, 'ui-dialog-maximized'); }, 300);
  230. });
  231. };
  232. Dialog.prototype.unbindMaskClickListener = function () {
  233. if (this.maskClickListener) {
  234. this.maskClickListener();
  235. this.maskClickListener = null;
  236. }
  237. };
  238. Dialog.prototype.moveOnTop = function () {
  239. if (this.autoZIndex) {
  240. this.container.style.zIndex = String(this.baseZIndex + (++domhandler_1.DomHandler.zindex));
  241. }
  242. };
  243. Dialog.prototype.onCloseMouseDown = function (event) {
  244. this.closeIconMouseDown = true;
  245. };
  246. Dialog.prototype.initDrag = function (event) {
  247. if (this.closeIconMouseDown) {
  248. this.closeIconMouseDown = false;
  249. return;
  250. }
  251. if (this.draggable) {
  252. this.dragging = true;
  253. this.lastPageX = event.pageX;
  254. this.lastPageY = event.pageY;
  255. domhandler_1.DomHandler.addClass(document.body, 'ui-unselectable-text');
  256. }
  257. };
  258. Dialog.prototype.onKeydown = function (event) {
  259. if (this.focusTrap) {
  260. if (event.which === 9) {
  261. event.preventDefault();
  262. var focusableElements = domhandler_1.DomHandler.getFocusableElements(this.container);
  263. if (focusableElements && focusableElements.length > 0) {
  264. if (!document.activeElement) {
  265. focusableElements[0].focus();
  266. }
  267. else {
  268. var focusedIndex = focusableElements.indexOf(document.activeElement);
  269. if (event.shiftKey) {
  270. if (focusedIndex == -1 || focusedIndex === 0)
  271. focusableElements[focusableElements.length - 1].focus();
  272. else
  273. focusableElements[focusedIndex - 1].focus();
  274. }
  275. else {
  276. if (focusedIndex == -1 || focusedIndex === (focusableElements.length - 1))
  277. focusableElements[0].focus();
  278. else
  279. focusableElements[focusedIndex + 1].focus();
  280. }
  281. }
  282. }
  283. }
  284. }
  285. };
  286. Dialog.prototype.onDrag = function (event) {
  287. if (this.dragging) {
  288. var containerWidth = domhandler_1.DomHandler.getOuterWidth(this.container);
  289. var containerHeight = domhandler_1.DomHandler.getOuterHeight(this.container);
  290. var deltaX = event.pageX - this.lastPageX;
  291. var deltaY = event.pageY - this.lastPageY;
  292. var offset = domhandler_1.DomHandler.getOffset(this.container);
  293. var leftPos = offset.left + deltaX;
  294. var topPos = offset.top + deltaY;
  295. var viewport = domhandler_1.DomHandler.getViewport();
  296. if (leftPos >= this.minX && (leftPos + containerWidth) < viewport.width) {
  297. this.container.style.left = leftPos + 'px';
  298. }
  299. if (topPos >= this.minY && (topPos + containerHeight) < viewport.height) {
  300. this.container.style.top = topPos + 'px';
  301. }
  302. this.lastPageX = event.pageX;
  303. this.lastPageY = event.pageY;
  304. }
  305. };
  306. Dialog.prototype.endDrag = function (event) {
  307. if (this.draggable) {
  308. this.dragging = false;
  309. domhandler_1.DomHandler.removeClass(document.body, 'ui-unselectable-text');
  310. }
  311. };
  312. Dialog.prototype.initResize = function (event) {
  313. if (this.resizable) {
  314. this.preWidth = null;
  315. this.resizing = true;
  316. this.lastPageX = event.pageX;
  317. this.lastPageY = event.pageY;
  318. domhandler_1.DomHandler.addClass(document.body, 'ui-unselectable-text');
  319. }
  320. };
  321. Dialog.prototype.onResize = function (event) {
  322. if (this.resizing) {
  323. var deltaX = event.pageX - this.lastPageX;
  324. var deltaY = event.pageY - this.lastPageY;
  325. var containerWidth = domhandler_1.DomHandler.getOuterWidth(this.container);
  326. var containerHeight = domhandler_1.DomHandler.getOuterHeight(this.container);
  327. var contentHeight = domhandler_1.DomHandler.getOuterHeight(this.contentViewChild.nativeElement);
  328. var newWidth = containerWidth + deltaX;
  329. var newHeight = containerHeight + deltaY;
  330. var minWidth = this.container.style.minWidth;
  331. var minHeight = this.container.style.minHeight;
  332. var offset = domhandler_1.DomHandler.getOffset(this.container);
  333. var viewport = domhandler_1.DomHandler.getViewport();
  334. if ((!minWidth || newWidth > parseInt(minWidth)) && (offset.left + newWidth) < viewport.width) {
  335. this.container.style.width = newWidth + 'px';
  336. }
  337. if ((!minHeight || newHeight > parseInt(minHeight)) && (offset.top + newHeight) < viewport.height) {
  338. this.container.style.height = newHeight + 'px';
  339. this.contentViewChild.nativeElement.style.height = contentHeight + deltaY + 'px';
  340. }
  341. this.lastPageX = event.pageX;
  342. this.lastPageY = event.pageY;
  343. }
  344. };
  345. Dialog.prototype.onResizeEnd = function () {
  346. if (this.resizing) {
  347. this.resizing = false;
  348. domhandler_1.DomHandler.removeClass(document.body, 'ui-unselectable-text');
  349. }
  350. };
  351. Dialog.prototype.bindGlobalListeners = function () {
  352. if (this.focusTrap) {
  353. this.bindDocumentKeydownListener();
  354. }
  355. if (this.draggable) {
  356. this.bindDocumentDragListener();
  357. this.bindDocumentDragEndListener();
  358. }
  359. if (this.resizable) {
  360. this.bindDocumentResizeListeners();
  361. }
  362. if (this.responsive) {
  363. this.bindDocumentResponsiveListener();
  364. }
  365. if (this.closeOnEscape && this.closable) {
  366. this.bindDocumentEscapeListener();
  367. }
  368. };
  369. Dialog.prototype.unbindGlobalListeners = function () {
  370. this.unbindDocumentDragListener();
  371. this.unbindDocumentKeydownListener();
  372. this.unbindDocumentDragEndListener();
  373. this.unbindDocumentResizeListeners();
  374. this.unbindDocumentResponsiveListener();
  375. this.unbindDocumentEscapeListener();
  376. };
  377. Dialog.prototype.bindDocumentKeydownListener = function () {
  378. var _this = this;
  379. this.zone.runOutsideAngular(function () {
  380. _this.documentKeydownListener = _this.onKeydown.bind(_this);
  381. window.document.addEventListener('keydown', _this.documentKeydownListener);
  382. });
  383. };
  384. Dialog.prototype.unbindDocumentKeydownListener = function () {
  385. if (this.documentKeydownListener) {
  386. window.document.removeEventListener('keydown', this.documentKeydownListener);
  387. this.documentKeydownListener = null;
  388. }
  389. };
  390. Dialog.prototype.bindDocumentDragListener = function () {
  391. var _this = this;
  392. this.zone.runOutsideAngular(function () {
  393. _this.documentDragListener = _this.onDrag.bind(_this);
  394. window.document.addEventListener('mousemove', _this.documentDragListener);
  395. });
  396. };
  397. Dialog.prototype.unbindDocumentDragListener = function () {
  398. if (this.documentDragListener) {
  399. window.document.removeEventListener('mousemove', this.documentDragListener);
  400. this.documentDragListener = null;
  401. }
  402. };
  403. Dialog.prototype.bindDocumentDragEndListener = function () {
  404. var _this = this;
  405. this.zone.runOutsideAngular(function () {
  406. _this.documentDragEndListener = _this.endDrag.bind(_this);
  407. window.document.addEventListener('mouseup', _this.documentDragEndListener);
  408. });
  409. };
  410. Dialog.prototype.unbindDocumentDragEndListener = function () {
  411. if (this.documentDragEndListener) {
  412. window.document.removeEventListener('mouseup', this.documentDragEndListener);
  413. this.documentDragEndListener = null;
  414. }
  415. };
  416. Dialog.prototype.bindDocumentResizeListeners = function () {
  417. var _this = this;
  418. this.zone.runOutsideAngular(function () {
  419. _this.documentResizeListener = _this.onResize.bind(_this);
  420. _this.documentResizeEndListener = _this.onResizeEnd.bind(_this);
  421. window.document.addEventListener('mousemove', _this.documentResizeListener);
  422. window.document.addEventListener('mouseup', _this.documentResizeEndListener);
  423. });
  424. };
  425. Dialog.prototype.unbindDocumentResizeListeners = function () {
  426. if (this.documentResizeListener && this.documentResizeEndListener) {
  427. window.document.removeEventListener('mouseup', this.documentResizeListener);
  428. window.document.removeEventListener('mouseup', this.documentResizeEndListener);
  429. this.documentResizeListener = null;
  430. this.documentResizeEndListener = null;
  431. }
  432. };
  433. Dialog.prototype.bindDocumentResponsiveListener = function () {
  434. var _this = this;
  435. this.zone.runOutsideAngular(function () {
  436. _this.documentResponsiveListener = _this.onWindowResize.bind(_this);
  437. window.addEventListener('resize', _this.documentResponsiveListener);
  438. });
  439. };
  440. Dialog.prototype.unbindDocumentResponsiveListener = function () {
  441. if (this.documentResponsiveListener) {
  442. window.removeEventListener('resize', this.documentResponsiveListener);
  443. this.documentResponsiveListener = null;
  444. }
  445. };
  446. Dialog.prototype.onWindowResize = function () {
  447. if (this.maximized) {
  448. return;
  449. }
  450. var viewport = domhandler_1.DomHandler.getViewport();
  451. var width = domhandler_1.DomHandler.getOuterWidth(this.container);
  452. if (viewport.width <= this.breakpoint) {
  453. if (!this.preWidth) {
  454. this.preWidth = width;
  455. }
  456. this.container.style.left = '0px';
  457. this.container.style.width = '100%';
  458. }
  459. else {
  460. this.container.style.width = this.preWidth + 'px';
  461. this.positionOverlay();
  462. }
  463. };
  464. Dialog.prototype.bindDocumentEscapeListener = function () {
  465. var _this = this;
  466. this.documentEscapeListener = this.renderer.listen('document', 'keydown', function (event) {
  467. if (event.which == 27) {
  468. if (parseInt(_this.container.style.zIndex) === (domhandler_1.DomHandler.zindex + _this.baseZIndex)) {
  469. _this.close(event);
  470. }
  471. }
  472. });
  473. };
  474. Dialog.prototype.unbindDocumentEscapeListener = function () {
  475. if (this.documentEscapeListener) {
  476. this.documentEscapeListener();
  477. this.documentEscapeListener = null;
  478. }
  479. };
  480. Dialog.prototype.setDimensions = function () {
  481. if (this.width) {
  482. this.container.style.width = this.width + 'px';
  483. }
  484. if (this.height) {
  485. this.container.style.height = this.height + 'px';
  486. }
  487. if (this.minWidth) {
  488. this.container.style.minWidth = this.minWidth + 'px';
  489. }
  490. if (this.minHeight) {
  491. this.container.style.minHeight = this.minHeight + 'px';
  492. }
  493. };
  494. Dialog.prototype.appendContainer = function () {
  495. if (this.appendTo) {
  496. if (this.appendTo === 'body')
  497. document.body.appendChild(this.container);
  498. else
  499. domhandler_1.DomHandler.appendChild(this.container, this.appendTo);
  500. }
  501. };
  502. Dialog.prototype.restoreAppend = function () {
  503. if (this.container && this.appendTo) {
  504. this.el.nativeElement.appendChild(this.container);
  505. }
  506. };
  507. Dialog.prototype.onAnimationStart = function (event) {
  508. switch (event.toState) {
  509. case 'visible':
  510. this.container = event.element;
  511. this.setDimensions();
  512. this.onShow.emit({});
  513. this.appendContainer();
  514. this.moveOnTop();
  515. this.positionOverlay();
  516. this.bindGlobalListeners();
  517. if (this.maximized) {
  518. domhandler_1.DomHandler.addClass(document.body, 'ui-overflow-hidden');
  519. }
  520. if (this.modal) {
  521. this.enableModality();
  522. }
  523. if (this.focusOnShow) {
  524. this.focus();
  525. }
  526. if (this.responsive) {
  527. this.onWindowResize();
  528. }
  529. break;
  530. case 'void':
  531. this.onContainerDestroy();
  532. this.onHide.emit({});
  533. break;
  534. }
  535. };
  536. Dialog.prototype.onContainerDestroy = function () {
  537. this.unbindGlobalListeners();
  538. this.dragging = false;
  539. if (this.maximized) {
  540. domhandler_1.DomHandler.removeClass(document.body, 'ui-overflow-hidden');
  541. this.maximized = false;
  542. }
  543. if (this.modal) {
  544. this.disableModality();
  545. }
  546. this.container = null;
  547. };
  548. Dialog.prototype.ngOnDestroy = function () {
  549. if (this.container) {
  550. this.restoreAppend();
  551. this.onContainerDestroy();
  552. }
  553. };
  554. __decorate([
  555. core_1.Input(),
  556. __metadata("design:type", Boolean)
  557. ], Dialog.prototype, "visible", void 0);
  558. __decorate([
  559. core_1.Input(),
  560. __metadata("design:type", String)
  561. ], Dialog.prototype, "header", void 0);
  562. __decorate([
  563. core_1.Input(),
  564. __metadata("design:type", Boolean)
  565. ], Dialog.prototype, "draggable", void 0);
  566. __decorate([
  567. core_1.Input(),
  568. __metadata("design:type", Boolean)
  569. ], Dialog.prototype, "resizable", void 0);
  570. __decorate([
  571. core_1.Input(),
  572. __metadata("design:type", Number)
  573. ], Dialog.prototype, "positionLeft", void 0);
  574. __decorate([
  575. core_1.Input(),
  576. __metadata("design:type", Number)
  577. ], Dialog.prototype, "positionTop", void 0);
  578. __decorate([
  579. core_1.Input(),
  580. __metadata("design:type", Object)
  581. ], Dialog.prototype, "contentStyle", void 0);
  582. __decorate([
  583. core_1.Input(),
  584. __metadata("design:type", Boolean)
  585. ], Dialog.prototype, "modal", void 0);
  586. __decorate([
  587. core_1.Input(),
  588. __metadata("design:type", Boolean)
  589. ], Dialog.prototype, "closeOnEscape", void 0);
  590. __decorate([
  591. core_1.Input(),
  592. __metadata("design:type", Boolean)
  593. ], Dialog.prototype, "dismissableMask", void 0);
  594. __decorate([
  595. core_1.Input(),
  596. __metadata("design:type", Boolean)
  597. ], Dialog.prototype, "rtl", void 0);
  598. __decorate([
  599. core_1.Input(),
  600. __metadata("design:type", Boolean)
  601. ], Dialog.prototype, "closable", void 0);
  602. __decorate([
  603. core_1.Input(),
  604. __metadata("design:type", Boolean)
  605. ], Dialog.prototype, "responsive", void 0);
  606. __decorate([
  607. core_1.Input(),
  608. __metadata("design:type", Object)
  609. ], Dialog.prototype, "appendTo", void 0);
  610. __decorate([
  611. core_1.Input(),
  612. __metadata("design:type", Object)
  613. ], Dialog.prototype, "style", void 0);
  614. __decorate([
  615. core_1.Input(),
  616. __metadata("design:type", String)
  617. ], Dialog.prototype, "styleClass", void 0);
  618. __decorate([
  619. core_1.Input(),
  620. __metadata("design:type", Boolean)
  621. ], Dialog.prototype, "showHeader", void 0);
  622. __decorate([
  623. core_1.Input(),
  624. __metadata("design:type", Number)
  625. ], Dialog.prototype, "breakpoint", void 0);
  626. __decorate([
  627. core_1.Input(),
  628. __metadata("design:type", Boolean)
  629. ], Dialog.prototype, "blockScroll", void 0);
  630. __decorate([
  631. core_1.Input(),
  632. __metadata("design:type", Boolean)
  633. ], Dialog.prototype, "autoZIndex", void 0);
  634. __decorate([
  635. core_1.Input(),
  636. __metadata("design:type", Number)
  637. ], Dialog.prototype, "baseZIndex", void 0);
  638. __decorate([
  639. core_1.Input(),
  640. __metadata("design:type", Number)
  641. ], Dialog.prototype, "minX", void 0);
  642. __decorate([
  643. core_1.Input(),
  644. __metadata("design:type", Number)
  645. ], Dialog.prototype, "minY", void 0);
  646. __decorate([
  647. core_1.Input(),
  648. __metadata("design:type", Boolean)
  649. ], Dialog.prototype, "focusOnShow", void 0);
  650. __decorate([
  651. core_1.Input(),
  652. __metadata("design:type", Boolean)
  653. ], Dialog.prototype, "maximizable", void 0);
  654. __decorate([
  655. core_1.Input(),
  656. __metadata("design:type", Boolean)
  657. ], Dialog.prototype, "focusTrap", void 0);
  658. __decorate([
  659. core_1.Input(),
  660. __metadata("design:type", String)
  661. ], Dialog.prototype, "transitionOptions", void 0);
  662. __decorate([
  663. core_1.Input(),
  664. __metadata("design:type", String)
  665. ], Dialog.prototype, "closeIcon", void 0);
  666. __decorate([
  667. core_1.Input(),
  668. __metadata("design:type", String)
  669. ], Dialog.prototype, "minimizeIcon", void 0);
  670. __decorate([
  671. core_1.Input(),
  672. __metadata("design:type", String)
  673. ], Dialog.prototype, "maximizeIcon", void 0);
  674. __decorate([
  675. core_1.ContentChildren(shared_1.Header, { descendants: false }),
  676. __metadata("design:type", core_1.QueryList)
  677. ], Dialog.prototype, "headerFacet", void 0);
  678. __decorate([
  679. core_1.ContentChildren(shared_1.Footer, { descendants: false }),
  680. __metadata("design:type", core_1.QueryList)
  681. ], Dialog.prototype, "footerFacet", void 0);
  682. __decorate([
  683. core_1.ViewChild('titlebar', { static: false }),
  684. __metadata("design:type", core_1.ElementRef)
  685. ], Dialog.prototype, "headerViewChild", void 0);
  686. __decorate([
  687. core_1.ViewChild('content', { static: false }),
  688. __metadata("design:type", core_1.ElementRef)
  689. ], Dialog.prototype, "contentViewChild", void 0);
  690. __decorate([
  691. core_1.ViewChild('footer', { static: false }),
  692. __metadata("design:type", core_1.ElementRef)
  693. ], Dialog.prototype, "footerViewChild", void 0);
  694. __decorate([
  695. core_1.Output(),
  696. __metadata("design:type", core_1.EventEmitter)
  697. ], Dialog.prototype, "onShow", void 0);
  698. __decorate([
  699. core_1.Output(),
  700. __metadata("design:type", core_1.EventEmitter)
  701. ], Dialog.prototype, "onHide", void 0);
  702. __decorate([
  703. core_1.Output(),
  704. __metadata("design:type", core_1.EventEmitter)
  705. ], Dialog.prototype, "visibleChange", void 0);
  706. __decorate([
  707. core_1.Input(),
  708. __metadata("design:type", Object),
  709. __metadata("design:paramtypes", [Object])
  710. ], Dialog.prototype, "width", null);
  711. __decorate([
  712. core_1.Input(),
  713. __metadata("design:type", Object),
  714. __metadata("design:paramtypes", [Object])
  715. ], Dialog.prototype, "height", null);
  716. __decorate([
  717. core_1.Input(),
  718. __metadata("design:type", Object),
  719. __metadata("design:paramtypes", [Object])
  720. ], Dialog.prototype, "minWidth", null);
  721. __decorate([
  722. core_1.Input(),
  723. __metadata("design:type", Object),
  724. __metadata("design:paramtypes", [Object])
  725. ], Dialog.prototype, "minHeight", null);
  726. Dialog = __decorate([
  727. core_1.Component({
  728. selector: 'p-dialog',
  729. template: "\n <div #container [ngClass]=\"{'ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow':true, 'ui-dialog-rtl':rtl,'ui-dialog-draggable':draggable,'ui-dialog-resizable':resizable}\"\n [ngStyle]=\"style\" [class]=\"styleClass\"\n [@animation]=\"{value: 'visible', params: {transitionParams: transitionOptions}}\" (@animation.start)=\"onAnimationStart($event)\" role=\"dialog\" [attr.aria-labelledby]=\"id + '-label'\" *ngIf=\"visible\">\n <div #titlebar class=\"ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top\" (mousedown)=\"initDrag($event)\" *ngIf=\"showHeader\">\n <span [attr.id]=\"id + '-label'\" class=\"ui-dialog-title\" *ngIf=\"header\">{{header}}</span>\n <span [attr.id]=\"id + '-label'\" class=\"ui-dialog-title\" *ngIf=\"headerFacet && headerFacet.first\">\n <ng-content select=\"p-header\"></ng-content>\n </span>\n <a *ngIf=\"closable\" [ngClass]=\"{'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all':true}\" tabindex=\"0\" role=\"button\" (click)=\"close($event)\" (keydown.enter)=\"close($event)\" (mousedown)=\"onCloseMouseDown($event)\">\n <span [class]=\"closeIcon\"></span>\n </a>\n <a *ngIf=\"maximizable\" [ngClass]=\"{'ui-dialog-titlebar-icon ui-dialog-titlebar-maximize ui-corner-all':true}\" tabindex=\"0\" role=\"button\" (click)=\"toggleMaximize($event)\" (keydown.enter)=\"toggleMaximize($event)\">\n <span [ngClass]=\"maximized ? minimizeIcon : maximizeIcon\"></span>\n </a>\n </div>\n <div #content class=\"ui-dialog-content ui-widget-content\" [ngStyle]=\"contentStyle\">\n <ng-content></ng-content>\n </div>\n <div #footer class=\"ui-dialog-footer ui-widget-content\" *ngIf=\"footerFacet && footerFacet.first\">\n <ng-content select=\"p-footer\"></ng-content>\n </div>\n <div *ngIf=\"resizable\" class=\"ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se\" style=\"z-index: 90;\" (mousedown)=\"initResize($event)\"></div>\n </div>\n ",
  730. animations: [
  731. animations_1.trigger('animation', [
  732. animations_1.state('void', animations_1.style({
  733. transform: 'scale(0.7)',
  734. opacity: 0
  735. })),
  736. animations_1.state('visible', animations_1.style({
  737. transform: 'none',
  738. opacity: 1
  739. })),
  740. animations_1.transition('* => *', animations_1.animate('{{transitionParams}}'))
  741. ])
  742. ]
  743. }),
  744. __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer2, core_1.NgZone])
  745. ], Dialog);
  746. return Dialog;
  747. }());
  748. exports.Dialog = Dialog;
  749. var DialogModule = /** @class */ (function () {
  750. function DialogModule() {
  751. }
  752. DialogModule = __decorate([
  753. core_1.NgModule({
  754. imports: [common_1.CommonModule],
  755. exports: [Dialog, shared_1.SharedModule],
  756. declarations: [Dialog]
  757. })
  758. ], DialogModule);
  759. return DialogModule;
  760. }());
  761. exports.DialogModule = DialogModule;
  762. //# sourceMappingURL=dialog.js.map