completed fb and g+ integration of buttons in category view

v1.18.x
Julian Lam 12 years ago
parent 2a946d52e0
commit 9098d61fe2

@ -2,13 +2,23 @@
var cid = templates.get('category_id'), var cid = templates.get('category_id'),
room = 'category_' + cid, room = 'category_' + cid,
twitterEl = document.getElementById('twitter-intent'), 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); app.enter_room(room);
twitterEl.addEventListener('click', function() { twitterEl.addEventListener('click', function() {
window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no');
}, false); }, 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'); var new_post = document.getElementById('new_post');
new_post.onclick = function() { new_post.onclick = function() {

@ -49,9 +49,9 @@
<div class="sidebar-block img-polaroid"> <div class="sidebar-block img-polaroid">
<div class="block-header"> <div class="block-header">
<a target="_blank" href="../{category_id}.rss"><i class="icon-rss-sign icon-2x"></i></a>&nbsp; <a target="_blank" href="../{category_id}.rss"><i class="icon-rss-sign icon-2x"></i></a>&nbsp;
<i class="icon-facebook-sign icon-2x"></i>&nbsp; <a href="#" id="facebook-share"><i class="icon-facebook-sign icon-2x"></i></a>&nbsp;
<a href="#" id="twitter-intent"><i class="icon-twitter-sign icon-2x"></i></a>&nbsp; <a href="#" id="twitter-intent"><i class="icon-twitter-sign icon-2x"></i></a>&nbsp;
<i class="icon-google-plus-sign icon-2x"></i>&nbsp; <a href="#" id="google-share"><i class="icon-google-plus-sign icon-2x"></i></a>&nbsp;
</div> </div>
</div> </div>
<div class="sidebar-block img-polaroid"> <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="category_id" value="{category_id}" />
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" /> <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> <script type="text/javascript" src="/src/forum/category.js"></script>

@ -31,7 +31,9 @@ var RDB = require('./redis.js'),
'category_id': category_id, 'category_id': category_id,
'active_users': [], 'active_users': [],
'topics' : [], '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) { function getTopics(next) {

Loading…
Cancel
Save