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.

126 lines
4.3 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. /***********************************************************************************
  2. * 관리자 페이지 초기화
  3. ***********************************************************************************/
  4. APP.init = function(){
  5. APP.initAjaxDefaultSetting();
  6. APP.initMenu();
  7. APP.initAx5();
  8. APP.initPlugins();
  9. APP.initCheckboxAll();
  10. };
  11. /***********************************************************************************
  12. * AJAX Error BlockUI 처리
  13. ***********************************************************************************/
  14. APP.initAjaxDefaultSetting = function() {
  15. $(document).ajaxError(function(event, request, settings){
  16. var message = '알수없는 오류가 발생하였습니다.';
  17. if( typeof request.responseJSON != 'undefined' && typeof request.responseJSON.message != 'undefined' ) {
  18. message = request.responseJSON.message;
  19. }
  20. else {
  21. if( request.status == 500 ) message = '서버 코드 오류가 발생하였습니다.\n관리자에게 문의하세요';
  22. else if ( request.status == 401 ) message = '해당 명령을 실행할 권한이 없습니다.';
  23. }
  24. toastr.error(message, '오류 발생');
  25. }).ajaxStart(function(){
  26. $.blockUI({
  27. css: {width:'25px',top:'49%',left:'49%',border:'0px none',backgroundColor:'transparent',cursor:'wait'},
  28. message : '<img src="/assets/images/common/ajax-loader.gif" alt="로딩중">',
  29. baseZ : 10000,
  30. overlayCSS : {opacity : 0}
  31. });
  32. }).ajaxComplete(function(){
  33. $.unblockUI();
  34. });
  35. };
  36. /***********************************************************************************
  37. * 메뉴관련 초기화
  38. ***********************************************************************************/
  39. APP.initMenu = function(){
  40. $('#nav .main-navigation li').each(function(){
  41. var $this = $(this);
  42. var menuCode = $this.data('active');
  43. if(menuCode == menuActive)
  44. {
  45. $(this).addClass('active');
  46. $(this).parents('li').addClass('active');
  47. }
  48. });
  49. };
  50. APP.initPlugins = function() {
  51. /*
  52. $('[data-toggle="datepicker"]').datepicker();
  53. $("body").on("click", '[data-toggle="datepicker"]', function(){
  54. if (!$(this).hasClass("hasDatepicker"))
  55. {
  56. $(this).datepicker();
  57. $(this).datepicker("show");
  58. }
  59. });
  60. $('[data-toggle="formatter"]').each(function(){
  61. if( $(this).data('pattern') )
  62. {
  63. $(this).formatter({
  64. pattern : $(this).data('pattern'),
  65. persistent: true
  66. });
  67. }
  68. });
  69. $.datetimepicker.setLocale('kr');
  70. $('[data-toggle="datetimepicker"]').datetimepicker({
  71. format:'Y-m-d H:i'
  72. });
  73. */
  74. };
  75. APP.initCheckboxAll = function(){
  76. $('[data-checkbox]').click(function(){
  77. var $check = $(this);
  78. var is_all = ($check.data('checkbox-all') && $check.data('checkbox-all').toString() == 'true');
  79. var name = $check.data('checkbox');
  80. var checked = $check.prop('checked');
  81. var $allCheck = is_all ? $check : $('[data-checkbox="'+name+'"][data-checkbox-all="true"]');
  82. if( is_all ) {
  83. $('[data-checkbox="'+name+'"]').prop('checked', checked );
  84. }
  85. else {
  86. $allCheck.prop('checked', $('[data-checkbox="'+name+'"]').not('[data-checkbox-all="true"]').length == $('[data-checkbox="'+name+'"]:checked').not('[data-checkbox-all="true"]').length);
  87. }
  88. });
  89. };
  90. /**********************************************************************************************************************
  91. * MODAL 관련
  92. *********************************************************************************************************************/
  93. APP.initAx5 = function(){
  94. APP.MASK = new ax5.ui.mask({
  95. zIndex: 1000}
  96. );
  97. APP.MASK2 = new ax5.ui.mask({
  98. zIndex: 2000
  99. });
  100. APP.modal = new ax5.ui.modal({
  101. absolute: true,
  102. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  103. });
  104. APP.modal2 = new ax5.ui.modal({
  105. absolute: true,
  106. iframeLoadingMsg: '<i class="far fa-spinner"></i>'
  107. });
  108. APP.toast = new ax5.ui.toast({
  109. containerPosition: "top-right",
  110. closeIcon: '<i class="far fa-times"></i>'
  111. });
  112. };
  113. $(function(){
  114. APP.init();
  115. });