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.

338 lines
9.1 KiB

7 years ago
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. $.datetimepicker.setLocale('kr');
  81. $('[data-toggle="datetimepicker"]').datetimepicker({
  82. format:'Y-m-d H:i'
  83. });
  84. };
  85. APP.initCheckboxAll = function(){
  86. $('[data-checkbox]').click(function(){
  87. var $check = $(this);
  88. var is_all = ($check.data('checkbox-all') && $check.data('checkbox-all').toString() == 'true');
  89. var name = $check.data('checkbox');
  90. var checked = $check.prop('checked');
  91. var $allCheck = is_all ? $check : $('[data-checkbox="'+name+'"][data-checkbox-all="true"]');
  92. if( is_all ) {
  93. $('[data-checkbox="'+name+'"]').prop('checked', checked );
  94. }
  95. else {
  96. $allCheck.prop('checked', $('[data-checkbox="'+name+'"]').not('[data-checkbox-all="true"]').length == $('[data-checkbox="'+name+'"]:checked').not('[data-checkbox-all="true"]').length);
  97. }
  98. });
  99. };
  100. /**********************************************************************************************************************
  101. * MODAL 관련
  102. *********************************************************************************************************************/
  103. APP.MASK = null;
  104. APP.MASK2 = null;
  105. APP.modal = null;
  106. APP.modal2 = null;
  107. APP.initMask = function(){
  108. APP.MASK = new ax5.ui.mask({
  109. zIndex: 1000
  110. });
  111. APP.MASK2 = new ax5.ui.mask({
  112. zIndex: 2000
  113. });
  114. };
  115. APP.initModal = function() {
  116. APP.modal = new ax5.ui.modal({
  117. absolute: true,
  118. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  119. });
  120. APP.modal2 = new ax5.ui.modal({
  121. absolute: true,
  122. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  123. });
  124. };
  125. APP.MODAL = function() {
  126. var modalCallback = {};
  127. var defaultCss = {
  128. width: 400,
  129. height: 400,
  130. position: {
  131. left: "center",
  132. top: "middle"
  133. }
  134. };
  135. var defaultOption = $.extend(true, {}, defaultCss, {
  136. iframeLoadingMsg: "",
  137. iframe: {
  138. method: "get",
  139. url: "#"
  140. },
  141. closeToEsc: true,
  142. onStateChanged: function onStateChanged() {
  143. // mask
  144. if (this.state === "open") {
  145. APP.MASK.open();
  146. } else if (this.state === "close") {
  147. APP.MASK.close();
  148. }
  149. },
  150. animateTime: 100,
  151. zIndex: 1001,
  152. absolute: true,
  153. fullScreen: false,
  154. header: {
  155. title: "새로운 윈도우",
  156. btns: {
  157. close: {
  158. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  159. APP.MODAL.callback();
  160. }
  161. }
  162. }
  163. }
  164. });
  165. var open = function(modalConfig) {
  166. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  167. $(document.body).addClass("modalOpened");
  168. this.modalCallback = modalConfig.callback;
  169. this.modalSendData = modalConfig.sendData;
  170. APP.modal.open(modalConfig);
  171. };
  172. var css = function css(modalCss) {
  173. modalCss = $.extend(true, {}, defaultCss, modalCss);
  174. APP.modal.css(modalCss);
  175. };
  176. var align = function align(modalAlign) {
  177. APP.modal.align(modalAlign);
  178. };
  179. var close = function close(data) {
  180. APP.modal.close();
  181. setTimeout(function () {
  182. $(document.body).removeClass("modalOpened");
  183. }, 500);
  184. };
  185. var minimize = function minimize() {
  186. APP.modal.minimize();
  187. };
  188. var maximize = function maximize() {
  189. APP.modal.maximize();
  190. };
  191. var callback = function callback(data) {
  192. if (this.modalCallback) {
  193. this.modalCallback(data);
  194. }
  195. this.close(data);
  196. };
  197. var getData = function getData() {
  198. if (this.modalSendData) {
  199. return this.modalSendData();
  200. }
  201. };
  202. return {
  203. "open": open,
  204. "css": css,
  205. "align": align,
  206. "close": close,
  207. "minimize": minimize,
  208. "maximize": maximize,
  209. "callback": callback,
  210. "modalCallback": modalCallback,
  211. "getData": getData
  212. };
  213. }();
  214. APP.MODAL2 = function() {
  215. var modalCallback = {};
  216. var defaultCss = {
  217. width: 400,
  218. height: 400,
  219. position: {
  220. left: "center",
  221. top: "middle"
  222. }
  223. };
  224. var defaultOption = $.extend(true, {}, defaultCss, {
  225. iframeLoadingMsg: "",
  226. iframe: {
  227. method: "get",
  228. url: "#"
  229. },
  230. closeToEsc: true,
  231. onStateChanged: function onStateChanged() {
  232. // mask
  233. if (this.state === "open") {
  234. APP.MASK2.open();
  235. } else if (this.state === "close") {
  236. APP.MASK2.close();
  237. }
  238. },
  239. animateTime: 100,
  240. zIndex: 2001,
  241. absolute: true,
  242. fullScreen: false,
  243. header: {
  244. title: "새로운 윈도우",
  245. btns: {
  246. close: {
  247. label: '<i class="far fa-times"></i>', onClick: function onClick() {
  248. APP.MODAL2.callback();
  249. }
  250. }
  251. }
  252. }
  253. });
  254. var open = function(modalConfig) {
  255. modalConfig = $.extend(true, {}, defaultOption, modalConfig);
  256. $(document.body).addClass("modalOpened");
  257. this.modalCallback = modalConfig.callback;
  258. this.modalSendData = modalConfig.sendData;
  259. APP.modal2.open(modalConfig);
  260. };
  261. var css = function css(modalCss) {
  262. modalCss = $.extend(true, {}, defaultCss, modalCss);
  263. APP.modal2.css(modalCss);
  264. };
  265. var align = function align(modalAlign) {
  266. APP.modal2.align(modalAlign);
  267. };
  268. var close = function close(data) {
  269. APP.modal2.close();
  270. setTimeout(function () {
  271. $(document.body).removeClass("modalOpened");
  272. }, 500);
  273. };
  274. var minimize = function minimize() {
  275. APP.modal2.minimize();
  276. };
  277. var maximize = function maximize() {
  278. APP.modal2.maximize();
  279. };
  280. var callback = function callback(data) {
  281. if (this.modalCallback) {
  282. this.modalCallback(data);
  283. }
  284. this.close(data);
  285. };
  286. var getData = function getData() {
  287. if (this.modalSendData) {
  288. return this.modalSendData();
  289. }
  290. };
  291. return {
  292. "open": open,
  293. "css": css,
  294. "align": align,
  295. "close": close,
  296. "minimize": minimize,
  297. "maximize": maximize,
  298. "callback": callback,
  299. "modalCallback": modalCallback,
  300. "getData": getData
  301. };
  302. }();
  303. $(function(){
  304. APP.init();
  305. });