You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.9 KiB

  1. APP.MODAL = function() {
  2. var modalCallback = {};
  3. var defaultCss = {
  4. width: 400,
  5. height: 400,
  6. position: {
  7. left: "center",
  8. top: "middle"
  9. }
  10. };
  11. var defaultOption = $.extend(true, {}, defaultCss, {
  12. iframeLoadingMsg: "",
  13. iframe: {
  14. method: "get",
  15. url: "#"
  16. },
  17. closeToEsc: true,
  18. onStateChanged: function onStateChanged() {
  19. // mask
  20. if (this.state === "open") {
  21. APP.MASK.open();
  22. } else if (this.state === "close") {
  23. APP.MASK.close();
  24. }
  25. },
  26. animateTime: 100,
  27. zIndex: 1001,
  28. absolute: true,
  29. fullScreen: false,
  30. header: {
  31. title: "새로운 윈도우",
  32. btns: {
  33. close: {
  34. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  35. APP.MODAL.callback();
  36. }
  37. }
  38. }
  39. }
  40. });
  41. var open = function(modalConfig) {
  42. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  43. $(document.body).addClass("modalOpened");
  44. this.modalCallback = modalConfig.callback;
  45. this.modalSendData = modalConfig.sendData;
  46. APP.modal.open(modalConfig);
  47. };
  48. var css = function css(modalCss) {
  49. modalCss = $.extend(true, {}, defaultCss, modalCss);
  50. APP.modal.css(modalCss);
  51. };
  52. var align = function align(modalAlign) {
  53. APP.modal.align(modalAlign);
  54. };
  55. var close = function close(data) {
  56. APP.modal.close();
  57. setTimeout(function () {
  58. $(document.body).removeClass("modalOpened");
  59. }, 500);
  60. };
  61. var minimize = function minimize() {
  62. APP.modal.minimize();
  63. };
  64. var maximize = function maximize() {
  65. APP.modal.maximize();
  66. };
  67. var callback = function callback(data) {
  68. if (this.modalCallback) {
  69. this.modalCallback(data);
  70. }
  71. this.close(data);
  72. };
  73. var getData = function getData() {
  74. if (this.modalSendData) {
  75. return this.modalSendData();
  76. }
  77. };
  78. return {
  79. "open": open,
  80. "css": css,
  81. "align": align,
  82. "close": close,
  83. "minimize": minimize,
  84. "maximize": maximize,
  85. "callback": callback,
  86. "modalCallback": modalCallback,
  87. "getData": getData
  88. };
  89. }();
  90. APP.MODAL2 = function() {
  91. var modalCallback = {};
  92. var defaultCss = {
  93. width: 400,
  94. height: 400,
  95. position: {
  96. left: "center",
  97. top: "middle"
  98. }
  99. };
  100. var defaultOption = $.extend(true, {}, defaultCss, {
  101. iframeLoadingMsg: "",
  102. iframe: {
  103. method: "get",
  104. url: "#"
  105. },
  106. closeToEsc: true,
  107. onStateChanged: function onStateChanged() {
  108. // mask
  109. if (this.state === "open") {
  110. APP.MASK2.open();
  111. } else if (this.state === "close") {
  112. APP.MASK2.close();
  113. }
  114. },
  115. animateTime: 100,
  116. zIndex: 2001,
  117. absolute: true,
  118. fullScreen: false,
  119. header: {
  120. title: "새로운 윈도우",
  121. btns: {
  122. close: {
  123. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  124. APP.MODAL2.callback();
  125. }
  126. }
  127. }
  128. }
  129. });
  130. var open = function(modalConfig) {
  131. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  132. $(document.body).addClass("modalOpened");
  133. this.modalCallback = modalConfig.callback;
  134. this.modalSendData = modalConfig.sendData;
  135. APP.modal2.open(modalConfig);
  136. };
  137. var css = function css(modalCss) {
  138. modalCss = $.extend(true, {}, defaultCss, modalCss);
  139. APP.modal2.css(modalCss);
  140. };
  141. var align = function align(modalAlign) {
  142. APP.modal2.align(modalAlign);
  143. };
  144. var close = function close(data) {
  145. APP.modal2.close();
  146. setTimeout(function () {
  147. $(document.body).removeClass("modalOpened");
  148. }, 500);
  149. };
  150. var minimize = function minimize() {
  151. APP.modal2.minimize();
  152. };
  153. var maximize = function maximize() {
  154. APP.modal2.maximize();
  155. };
  156. var callback = function callback(data) {
  157. if (this.modalCallback) {
  158. this.modalCallback(data);
  159. }
  160. this.close(data);
  161. };
  162. var getData = function getData() {
  163. if (this.modalSendData) {
  164. return this.modalSendData();
  165. }
  166. };
  167. return {
  168. "open": open,
  169. "css": css,
  170. "align": align,
  171. "close": close,
  172. "minimize": minimize,
  173. "maximize": maximize,
  174. "callback": callback,
  175. "modalCallback": modalCallback,
  176. "getData": getData
  177. };
  178. }();