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.

97 lines
2.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. /**
  7. * 언어셋 변경
  8. * @param lang
  9. * @constructor
  10. */
  11. APP.SET_LANG = function(lang)
  12. {
  13. $.cookie('site_lang', lang, {expires:30, path:'/'});
  14. location.reload();
  15. };
  16. /**
  17. * 팝업창 닫기버튼 init
  18. */
  19. $('[data-toggle="btn-popup-close"]').click(function(e){
  20. var type = $(this).data('type');
  21. var idx = $(this).data('idx');
  22. var cookie = $(this).data('cookie');
  23. if( type == 'Y')
  24. {
  25. window.close();
  26. }
  27. else if( type == 'N' )
  28. {
  29. $("#popup-" + idx ).remove();
  30. }
  31. if( cookie == 1 )
  32. {
  33. $.cookie('popup_'+idx, 1, {expires:1, path:'/'});
  34. }
  35. });
  36. /**
  37. * SNS 공유
  38. */
  39. $("a[data-toggle='sns-share']").not('[data-service="link"]').click(function(e){
  40. e.preventDefault();
  41. var _this = $(this);
  42. var sns_type = _this.data('service');
  43. var href = _this.data('url');
  44. var title = _this.data('title');
  45. var loc = "";
  46. var img = $("meta[name='og:image']").attr('content');
  47. if( ! sns_type || !href || !title) return;
  48. if( sns_type == 'facebook' ) {
  49. loc = '//www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(href);
  50. }
  51. else if ( sns_type == 'twitter' ) {
  52. loc = '//twitter.com/home?status='+encodeURIComponent(title)+' '+href;
  53. }
  54. else if ( sns_type == 'google' ) {
  55. loc = '//plus.google.com/share?url='+href;
  56. }
  57. else if ( sns_type == 'pinterest' ) {
  58. loc = '//www.pinterest.com/pin/create/button/?url='+href+'&media='+img+'&description='+encodeURIComponent(title);
  59. }
  60. else if ( sns_type == 'kakaostory') {
  61. loc = 'https://story.kakao.com/share?url='+encodeURIComponent(href);
  62. }
  63. else if ( sns_type == 'band' ) {
  64. loc = 'http://www.band.us/plugin/share?body='+encodeURIComponent(title)+'%0A'+encodeURIComponent(href);
  65. }
  66. else if ( sns_type == 'naver' ) {
  67. loc = "http://share.naver.com/web/shareView.nhn?url="+encodeURIComponent(href)+"&title="+encodeURIComponent(title);
  68. }
  69. else if ( sns_type == 'line') {
  70. loc = "http://line.me/R/msg/text/?" + encodeURIComponent(title + "\n" + href);
  71. }
  72. else {
  73. return false;
  74. }
  75. APP.POPUP({ url : loc});
  76. return false;
  77. });
  78. $(function(){
  79. var clipboard = new ClipboardJS('a[data-toggle="sns-share"][data-service="link"]', {
  80. text: function(trigger) {
  81. return trigger.getAttribute('data-url');
  82. }
  83. });
  84. clipboard.on('success', function(){
  85. alert('현재 URL이 복사되었습니다.');
  86. });
  87. });