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.

127 lines
3.8 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. var APP = {};
  6. APP.POPUP = null;
  7. APP.REGEX = {};
  8. APP.REGEX.uniqueID = /^[a-z][a-z0-9_]{2,19}$/g;
  9. (function($) {
  10. APP.POPUP = function(option) {
  11. var defaults={
  12. title : '_blank',
  13. width : 800,
  14. height : 600,
  15. url : ''
  16. };
  17. var options = $.extend({}, defaults, option);
  18. cw = screen.availWidth;
  19. ch = screen.availHeight;
  20. sw = options.width;
  21. sh = options.height;
  22. ml = (cw - sw) / 2;
  23. mt = (ch - sh) / 2;
  24. var option = 'width='+sw+',height='+sh+',top='+mt+',left='+ml+',scrollbars=yes,resizable=no';
  25. var win = window.open(options.url, options.title, option);
  26. if (win == null || typeof(win) == "undefined" || (win == null && win.outerWidth == 0) || (win != null && win.outerHeight == 0))
  27. {
  28. alert("팝업 차단 기능이 설정되어있습니다\n\n차단 기능을 해제(팝업허용) 한 후 다시 이용해 주십시오.");
  29. return;
  30. }
  31. };
  32. })(jQuery);
  33. /**
  34. * 언어셋 변경
  35. * @param lang
  36. * @constructor
  37. */
  38. APP.SET_LANG = function(lang)
  39. {
  40. $.cookie('site_lang', lang, {expires:30, path:'/'});
  41. location.reload();
  42. };
  43. /**
  44. * 팝업창 닫기버튼 init
  45. */
  46. $('[data-toggle="btn-popup-close"]').click(function(e){
  47. var type = $(this).data('type');
  48. var idx = $(this).data('idx');
  49. var cookie = $(this).data('cookie');
  50. if( type == 'Y')
  51. {
  52. window.close();
  53. }
  54. else if( type == 'N' )
  55. {
  56. $("#popup-" + idx ).remove();
  57. }
  58. if( cookie == 1 )
  59. {
  60. $.cookie('popup_'+idx, 1, {expires:1, path:'/'});
  61. }
  62. });
  63. /**
  64. * SNS 공유
  65. */
  66. $("a[data-toggle='sns-share']").not('[data-service="link"]').click(function(e){
  67. e.preventDefault();
  68. var _this = $(this);
  69. var sns_type = _this.data('service');
  70. var href = _this.data('url');
  71. var title = _this.data('title');
  72. var loc = "";
  73. var img = $("meta[name='og:image']").attr('content');
  74. if( ! sns_type || !href || !title) return;
  75. if( sns_type == 'facebook' ) {
  76. loc = '//www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(href);
  77. }
  78. else if ( sns_type == 'twitter' ) {
  79. loc = '//twitter.com/home?status='+encodeURIComponent(title)+' '+href;
  80. }
  81. else if ( sns_type == 'google' ) {
  82. loc = '//plus.google.com/share?url='+href;
  83. }
  84. else if ( sns_type == 'pinterest' ) {
  85. loc = '//www.pinterest.com/pin/create/button/?url='+href+'&media='+img+'&description='+encodeURIComponent(title);
  86. }
  87. else if ( sns_type == 'kakaostory') {
  88. loc = 'https://story.kakao.com/share?url='+encodeURIComponent(href);
  89. }
  90. else if ( sns_type == 'band' ) {
  91. loc = 'http://www.band.us/plugin/share?body='+encodeURIComponent(title)+'%0A'+encodeURIComponent(href);
  92. }
  93. else if ( sns_type == 'naver' ) {
  94. loc = "http://share.naver.com/web/shareView.nhn?url="+encodeURIComponent(href)+"&title="+encodeURIComponent(title);
  95. }
  96. else if ( sns_type == 'line') {
  97. loc = "http://line.me/R/msg/text/?" + encodeURIComponent(title + "\n" + href);
  98. }
  99. else {
  100. return false;
  101. }
  102. APP.POPUP({ url : loc});
  103. return false;
  104. });
  105. $(function(){
  106. var clipboard = new ClipboardJS('a[data-toggle="sns-share"][data-service="link"]', {
  107. text: function(trigger) {
  108. return trigger.getAttribute('data-url');
  109. }
  110. });
  111. clipboard.on('success', function(){
  112. alert('현재 URL이 복사되었습니다.');
  113. });
  114. });