From 9098d61fe240f24f100f2a6be4596b954ccbf2b7 Mon Sep 17 00:00:00 2001 From: Julian Lam <julian.lam@gmail.com> Date: Tue, 25 Jun 2013 21:15:24 -0400 Subject: [PATCH] completed fb and g+ integration of buttons in category view --- public/src/forum/category.js | 12 +++++++++++- public/templates/category.tpl | 6 ++++-- src/categories.js | 4 +++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 83bea12460..0db384a34e 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -2,13 +2,23 @@ var cid = templates.get('category_id'), room = 'category_' + cid, twitterEl = document.getElementById('twitter-intent'), - twitter_url = templates.get('twitter-intent-url'); + facebookEl = document.getElementById('facebook-share'), + googleEl = document.getElementById('google-share'), + twitter_url = templates.get('twitter-intent-url'), + facebook_url = templates.get('facebook-share-url'), + google_url = templates.get('google-share-url'); app.enter_room(room); twitterEl.addEventListener('click', function() { window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); }, false); + facebookEl.addEventListener('click', function() { + window.open(facebook_url, '_blank', 'width=626,height=436,scrollbars=no,status=no'); + }, false); + googleEl.addEventListener('click', function() { + window.open(google_url, '_blank', 'width=500,height=570,scrollbars=no,status=no'); + }, false); var new_post = document.getElementById('new_post'); new_post.onclick = function() { diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 681638d828..50d7d3864d 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -49,9 +49,9 @@ <div class="sidebar-block img-polaroid"> <div class="block-header"> <a target="_blank" href="../{category_id}.rss"><i class="icon-rss-sign icon-2x"></i></a> - <i class="icon-facebook-sign icon-2x"></i> + <a href="#" id="facebook-share"><i class="icon-facebook-sign icon-2x"></i></a> <a href="#" id="twitter-intent"><i class="icon-twitter-sign icon-2x"></i></a> - <i class="icon-google-plus-sign icon-2x"></i> + <a href="#" id="google-share"><i class="icon-google-plus-sign icon-2x"></i></a> </div> </div> <div class="sidebar-block img-polaroid"> @@ -87,4 +87,6 @@ <input type="hidden" template-variable="category_id" value="{category_id}" /> <input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" /> +<input type="hidden" template-variable="facebook-share-url" value="{facebook-share-url}" /> +<input type="hidden" template-variable="google-share-url" value="{google-share-url}" /> <script type="text/javascript" src="/src/forum/category.js"></script> \ No newline at end of file diff --git a/src/categories.js b/src/categories.js index 42ddfa065b..e3fe2fb683 100644 --- a/src/categories.js +++ b/src/categories.js @@ -31,7 +31,9 @@ var RDB = require('./redis.js'), 'category_id': category_id, 'active_users': [], 'topics' : [], - 'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(global.config.url + 'category/' + category_slug) + '&text=' + encodeURIComponent(category_name) + 'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(global.config.url + 'category/' + category_slug) + '&text=' + encodeURIComponent(category_name), + 'facebook-share-url': 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(global.config.url + 'category/' + category_slug), + 'google-share-url': 'https://plus.google.com/share?url=' + encodeURIComponent(global.config.url + 'category/' + category_slug) }; function getTopics(next) {