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.

333 lines
9.0 KiB

7 years ago
  1. APP.init = function(){
  2. APP.initPage();
  3. APP.initMenu();
  4. APP.initMask();
  5. APP.initModal();
  6. APP.initPlugins();
  7. APP.initCheckboxAll();
  8. };
  9. APP.initPage = function(){
  10. if( $('body').height() < $(window).height() )
  11. {
  12. $('html,body').css('height', '100%');
  13. }
  14. };
  15. APP.initMenu = function(){
  16. $('.btn-menu-toggle').click(function(e){
  17. $('#left-panel').toggleClass('opened');
  18. $('#left-panel').niceScroll().resize();
  19. });
  20. $('#main .main').niceScroll({
  21. cursorborder : "1px solid rgba(0,0,0, 0.15)",
  22. cursorwidth : '12px',
  23. cursorcolor : 'rgba(0,0,0, 0.5)'
  24. });
  25. $('#left-panel').niceScroll({
  26. cursorborder : "1px solid rgba(0,0,0, 0.15)",
  27. cursorwidth : '12px',
  28. cursorcolor : 'rgba(0,0,0, 0.5)'
  29. });
  30. $("#left-panel li").each(function(){
  31. if( $(this).data('active') && $(this).data('active') == menuActive)
  32. {
  33. $(this).addClass('active');
  34. $(this).parents('li').addClass('open');
  35. $(this).parents('ul').show();
  36. }
  37. });
  38. $('#left-panel #main-navigation a.parent').click(function(e){
  39. e.preventDefault();
  40. $(this).parent().toggleClass('open');
  41. $('#left-panel').niceScroll().resize();
  42. });
  43. };
  44. APP.initPlugins = function() {
  45. $.datepicker.regional['ko'] = {
  46. closeText: '닫기',
  47. prevText: '이전달',
  48. nextText: '다음달',
  49. currentText: '오늘',
  50. monthNames: ['1월','2월','3월','4월','5월','6월', '7월','8월','9월','10월','11월','12월'],
  51. monthNamesShort: ['1월','2월','3월','4월','5월','6월', '7월','8월','9월','10월','11월','12월'],
  52. dayNames: ['일','월','화','수','목','금','토'],
  53. dayNamesShort: ['일','월','화','수','목','금','토'],
  54. dayNamesMin: ['일','월','화','수','목','금','토'],
  55. weekHeader: 'Wk',
  56. dateFormat: 'yy-mm-dd',
  57. firstDay: 0,
  58. isRTL: false,
  59. showMonthAfterYear: true,
  60. yearSuffix: ''
  61. };
  62. $.datepicker.setDefaults($.datepicker.regional['ko']);
  63. $('[data-toggle="datepicker"]').datepicker();
  64. $("body").on("click", '[data-toggle="datepicker"]', function(){
  65. if (!$(this).hasClass("hasDatepicker"))
  66. {
  67. $(this).datepicker();
  68. $(this).datepicker("show");
  69. }
  70. });
  71. $('[data-toggle="formatter"]').each(function(){
  72. if( $(this).data('pattern') )
  73. {
  74. $(this).formatter({
  75. pattern : $(this).data('pattern'),
  76. persistent: true
  77. });
  78. }
  79. });
  80. };
  81. APP.initCheckboxAll = function(){
  82. $('[data-checkbox]').click(function(){
  83. var $check = $(this);
  84. var is_all = ($check.data('checkbox-all') && $check.data('checkbox-all').toString() == 'true');
  85. var name = $check.data('checkbox');
  86. var checked = $check.prop('checked');
  87. var $allCheck = is_all ? $check : $('[data-checkbox="'+name+'"][data-checkbox-all="true"]');
  88. if( is_all ) {
  89. $('[data-checkbox="'+name+'"]').prop('checked', checked );
  90. }
  91. else {
  92. $allCheck.prop('checked', $('[data-checkbox="'+name+'"]').not('[data-checkbox-all="true"]').length == $('[data-checkbox="'+name+'"]:checked').not('[data-checkbox-all="true"]').length);
  93. }
  94. });
  95. };
  96. /**********************************************************************************************************************
  97. * MODAL 관련
  98. *********************************************************************************************************************/
  99. APP.MASK = null;
  100. APP.MASK2 = null;
  101. APP.modal = null;
  102. APP.modal2 = null;
  103. APP.initMask = function(){
  104. APP.MASK = new ax5.ui.mask({
  105. zIndex: 1000
  106. });
  107. APP.MASK2 = new ax5.ui.mask({
  108. zIndex: 2000
  109. });
  110. };
  111. APP.initModal = function() {
  112. APP.modal = new ax5.ui.modal({
  113. absolute: true,
  114. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  115. });
  116. APP.modal2 = new ax5.ui.modal({
  117. absolute: true,
  118. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  119. });
  120. };
  121. APP.MODAL = function() {
  122. var modalCallback = {};
  123. var defaultCss = {
  124. width: 400,
  125. height: 400,
  126. position: {
  127. left: "center",
  128. top: "middle"
  129. }
  130. };
  131. var defaultOption = $.extend(true, {}, defaultCss, {
  132. iframeLoadingMsg: "",
  133. iframe: {
  134. method: "get",
  135. url: "#"
  136. },
  137. closeToEsc: true,
  138. onStateChanged: function onStateChanged() {
  139. // mask
  140. if (this.state === "open") {
  141. APP.MASK.open();
  142. } else if (this.state === "close") {
  143. APP.MASK.close();
  144. }
  145. },
  146. animateTime: 100,
  147. zIndex: 1001,
  148. absolute: true,
  149. fullScreen: false,
  150. header: {
  151. title: "새로운 윈도우",
  152. btns: {
  153. close: {
  154. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  155. APP.MODAL.callback();
  156. }
  157. }
  158. }
  159. }
  160. });
  161. var open = function(modalConfig) {
  162. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  163. $(document.body).addClass("modalOpened");
  164. this.modalCallback = modalConfig.callback;
  165. this.modalSendData = modalConfig.sendData;
  166. APP.modal.open(modalConfig);
  167. };
  168. var css = function css(modalCss) {
  169. modalCss = $.extend(true, {}, defaultCss, modalCss);
  170. APP.modal.css(modalCss);
  171. };
  172. var align = function align(modalAlign) {
  173. APP.modal.align(modalAlign);
  174. };
  175. var close = function close(data) {
  176. APP.modal.close();
  177. setTimeout(function () {
  178. $(document.body).removeClass("modalOpened");
  179. }, 500);
  180. };
  181. var minimize = function minimize() {
  182. APP.modal.minimize();
  183. };
  184. var maximize = function maximize() {
  185. APP.modal.maximize();
  186. };
  187. var callback = function callback(data) {
  188. if (this.modalCallback) {
  189. this.modalCallback(data);
  190. }
  191. this.close(data);
  192. };
  193. var getData = function getData() {
  194. if (this.modalSendData) {
  195. return this.modalSendData();
  196. }
  197. };
  198. return {
  199. "open": open,
  200. "css": css,
  201. "align": align,
  202. "close": close,
  203. "minimize": minimize,
  204. "maximize": maximize,
  205. "callback": callback,
  206. "modalCallback": modalCallback,
  207. "getData": getData
  208. };
  209. }();
  210. APP.MODAL2 = function() {
  211. var modalCallback = {};
  212. var defaultCss = {
  213. width: 400,
  214. height: 400,
  215. position: {
  216. left: "center",
  217. top: "middle"
  218. }
  219. };
  220. var defaultOption = $.extend(true, {}, defaultCss, {
  221. iframeLoadingMsg: "",
  222. iframe: {
  223. method: "get",
  224. url: "#"
  225. },
  226. closeToEsc: true,
  227. onStateChanged: function onStateChanged() {
  228. // mask
  229. if (this.state === "open") {
  230. APP.MASK2.open();
  231. } else if (this.state === "close") {
  232. APP.MASK2.close();
  233. }
  234. },
  235. animateTime: 100,
  236. zIndex: 2001,
  237. absolute: true,
  238. fullScreen: false,
  239. header: {
  240. title: "새로운 윈도우",
  241. btns: {
  242. close: {
  243. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  244. APP.MODAL2.callback();
  245. }
  246. }
  247. }
  248. }
  249. });
  250. var open = function(modalConfig) {
  251. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  252. $(document.body).addClass("modalOpened");
  253. this.modalCallback = modalConfig.callback;
  254. this.modalSendData = modalConfig.sendData;
  255. APP.modal2.open(modalConfig);
  256. };
  257. var css = function css(modalCss) {
  258. modalCss = $.extend(true, {}, defaultCss, modalCss);
  259. APP.modal2.css(modalCss);
  260. };
  261. var align = function align(modalAlign) {
  262. APP.modal2.align(modalAlign);
  263. };
  264. var close = function close(data) {
  265. APP.modal2.close();
  266. setTimeout(function () {
  267. $(document.body).removeClass("modalOpened");
  268. }, 500);
  269. };
  270. var minimize = function minimize() {
  271. APP.modal2.minimize();
  272. };
  273. var maximize = function maximize() {
  274. APP.modal2.maximize();
  275. };
  276. var callback = function callback(data) {
  277. if (this.modalCallback) {
  278. this.modalCallback(data);
  279. }
  280. this.close(data);
  281. };
  282. var getData = function getData() {
  283. if (this.modalSendData) {
  284. return this.modalSendData();
  285. }
  286. };
  287. return {
  288. "open": open,
  289. "css": css,
  290. "align": align,
  291. "close": close,
  292. "minimize": minimize,
  293. "maximize": maximize,
  294. "callback": callback,
  295. "modalCallback": modalCallback,
  296. "getData": getData
  297. };
  298. }();
  299. $(function(){
  300. APP.init();
  301. });