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.

207 lines
5.2 KiB

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