diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 0f3439aa81..e0628551e8 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -6,17 +6,12 @@ define(function() { Topic.init = function() { var expose_tools = templates.get('expose_tools'), tid = templates.get('topic_id'), - postListEl = document.getElementById('post-container'), - editBtns = document.querySelectorAll('#post-container .post-buttons .edit, #post-container .post-buttons .edit i'), thread_state = { locked: templates.get('locked'), deleted: templates.get('deleted'), pinned: templates.get('pinned') }, - topic_name = templates.get('topic_name'), - twitter_url = templates.get('twitter-intent-url'), - facebook_url = templates.get('facebook-share-url'), - google_url = templates.get('google-share-url'); + topic_name = templates.get('topic_name'); function fixDeleteStateForPosts() { @@ -40,21 +35,6 @@ define(function() { $('.topic-main-buttons').removeClass('hide').parent().removeClass('hide'); } - $('.twitter-share').on('click', function () { - window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); - return false; - }); - - $('.facebook-share').on('click', function () { - window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no'); - return false; - }); - - $('.google-share').on('click', function () { - window.open(google_url, '_blank', 'width=500,height=570,scrollbars=no,status=no'); - return false; - }); - // Resetting thread state if (thread_state.locked === '1') set_locked_state(true); if (thread_state.deleted === '1') set_delete_state(true); @@ -333,6 +313,24 @@ define(function() { }); }); + $('#post-container').on('click', '.twitter-share', function () { + var pid = $(this).parents('li').attr('data-pid'); + window.open('https://twitter.com/intent/tweet?url=' + encodeURIComponent(window.location.href + '#' + pid) + '&text=' + topic_name, '_blank', 'width=550,height=420,scrollbars=no,status=no'); + return false; + }); + + $('#post-container').on('click', '.facebook-share', function () { + var pid = $(this).parents('li').attr('data-pid'); + window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href + '#' + pid), '_blank', 'width=626,height=436,scrollbars=no,status=no'); + return false; + }); + + $('#post-container').on('click', '.google-share', function () { + var pid = $(this).parents('li').attr('data-pid'); + window.open('https://plus.google.com/share?url=' + encodeURIComponent(window.location.href + '#' + pid), '_blank', 'width=500,height=570,scrollbars=no,status=no'); + return false; + }); + $('#post-container').delegate('.edit', 'click', function(e) { var pid = $(this).parents('li').attr('data-pid'), main = $(this).parents('.posts'); diff --git a/src/topics.js b/src/topics.js index 642567db73..b556e7cc88 100644 --- a/src/topics.js +++ b/src/topics.js @@ -534,10 +534,7 @@ var RDB = require('./redis'), 'unreplied': topicData.postcount > 1, 'topic_id': tid, 'expose_tools': privileges.editable ? 1 : 0, - 'posts': topicPosts, - 'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug) + '&text=' + encodeURIComponent(topicData.title), - 'facebook-share-url': 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug), - 'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(nconf.get('url') + 'topic/' + topicData.slug) + 'posts': topicPosts }); }); });