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.

153 lines
5.0 KiB

7 years ago
7 years ago
7 years ago
7 years ago
  1. /***********************************************************************************
  2. * IE 8 이하 브라우져 console.log 에러처리
  3. ***********************************************************************************/
  4. if(!window.console || !window.console.log) {window.console = {log : function(){}};}
  5. /***********************************************************************************
  6. * AJAX Error BlockUI 처리
  7. ***********************************************************************************/
  8. $(function(){
  9. $(document).ajaxError(function(event, request, settings){
  10. var message = '알수없는 오류가 발생하였습니다.';
  11. if( typeof request.responseJSON != 'undefined' && typeof request.responseJSON.message != 'undefined' ) {
  12. message = request.responseJSON.message;
  13. }
  14. else {
  15. if( request.status == 500 ) message = '서버 코드 오류가 발생하였습니다.\n관리자에게 문의하세요';
  16. else if ( request.status == 401 ) message = '해당 명령을 실행할 권한이 없습니다.';
  17. }
  18. toastr.error(message, '오류 발생');
  19. }).ajaxStart(function(){
  20. $.blockUI({
  21. css: {width:'25px',top:'49%',left:'49%',border:'0px none',backgroundColor:'transparent',cursor:'wait'},
  22. message : '<img src="/assets/images/common/ajax-loader.gif" alt="로딩중">',
  23. baseZ : 10000,
  24. overlayCSS : {opacity : 0}
  25. });
  26. }).ajaxComplete(function(){
  27. $.unblockUI();
  28. });
  29. });
  30. var APP = {};
  31. APP.POPUP = null;
  32. APP.REGEX = {};
  33. APP.REGEX.uniqueID = /^[a-z][a-z0-9_]{2,19}$/g;
  34. (function($) {
  35. APP.POPUP = function(option) {
  36. var defaults={
  37. title : '_blank',
  38. width : 800,
  39. height : 600,
  40. url : ''
  41. };
  42. var options = $.extend({}, defaults, option);
  43. cw = screen.availWidth;
  44. ch = screen.availHeight;
  45. sw = options.width;
  46. sh = options.height;
  47. ml = (cw - sw) / 2;
  48. mt = (ch - sh) / 2;
  49. var option = 'width='+sw+',height='+sh+',top='+mt+',left='+ml+',scrollbars=yes,resizable=no';
  50. var win = window.open(options.url, options.title, option);
  51. if (win == null || typeof(win) == "undefined" || (win == null && win.outerWidth == 0) || (win != null && win.outerHeight == 0))
  52. {
  53. alert("팝업 차단 기능이 설정되어있습니다\n\n차단 기능을 해제(팝업허용) 한 후 다시 이용해 주십시오.");
  54. return;
  55. }
  56. };
  57. })(jQuery);
  58. /**
  59. * 언어셋 변경
  60. * @param lang
  61. * @constructor
  62. */
  63. APP.SET_LANG = function(lang)
  64. {
  65. $.cookie('site_lang', lang, {expires:30, path:'/'});
  66. location.reload();
  67. };
  68. /**
  69. * 팝업창 닫기버튼 init
  70. */
  71. $('[data-toggle="btn-popup-close"]').click(function(e){
  72. var type = $(this).data('type');
  73. var idx = $(this).data('idx');
  74. var cookie = $(this).data('cookie');
  75. if( type == 'Y')
  76. {
  77. window.close();
  78. }
  79. else if( type == 'N' )
  80. {
  81. $("#popup-" + idx ).remove();
  82. }
  83. if( cookie == 1 )
  84. {
  85. $.cookie('popup_'+idx, 1, {expires:1, path:'/'});
  86. }
  87. });
  88. /**
  89. * SNS 공유
  90. */
  91. $("a[data-toggle='sns-share']").not('[data-service="link"]').click(function(e){
  92. e.preventDefault();
  93. var _this = $(this);
  94. var sns_type = _this.data('service');
  95. var href = _this.data('url');
  96. var title = _this.data('title');
  97. var loc = "";
  98. var img = $("meta[name='og:image']").attr('content');
  99. if( ! sns_type || !href || !title) return;
  100. if( sns_type == 'facebook' ) {
  101. loc = '//www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(href);
  102. }
  103. else if ( sns_type == 'twitter' ) {
  104. loc = '//twitter.com/home?status='+encodeURIComponent(title)+' '+href;
  105. }
  106. else if ( sns_type == 'google' ) {
  107. loc = '//plus.google.com/share?url='+href;
  108. }
  109. else if ( sns_type == 'pinterest' ) {
  110. loc = '//www.pinterest.com/pin/create/button/?url='+href+'&media='+img+'&description='+encodeURIComponent(title);
  111. }
  112. else if ( sns_type == 'kakaostory') {
  113. loc = 'https://story.kakao.com/share?url='+encodeURIComponent(href);
  114. }
  115. else if ( sns_type == 'band' ) {
  116. loc = 'http://www.band.us/plugin/share?body='+encodeURIComponent(title)+'%0A'+encodeURIComponent(href);
  117. }
  118. else if ( sns_type == 'naver' ) {
  119. loc = "http://share.naver.com/web/shareView.nhn?url="+encodeURIComponent(href)+"&title="+encodeURIComponent(title);
  120. }
  121. else if ( sns_type == 'line') {
  122. loc = "http://line.me/R/msg/text/?" + encodeURIComponent(title + "\n" + href);
  123. }
  124. else {
  125. return false;
  126. }
  127. APP.POPUP({ url : loc});
  128. return false;
  129. });
  130. $(function(){
  131. var clipboard = new ClipboardJS('a[data-toggle="sns-share"][data-service="link"]', {
  132. text: function(trigger) {
  133. return trigger.getAttribute('data-url');
  134. }
  135. });
  136. clipboard.on('success', function(){
  137. alert('현재 URL이 복사되었습니다.');
  138. });
  139. });