Skip to content

Instantly share code, notes, and snippets.

@ericksli
Created February 23, 2016 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericksli/b6dcc546a993bd76236d to your computer and use it in GitHub Desktop.
Save ericksli/b6dcc546a993bd76236d to your computer and use it in GitHub Desktop.
Social media share pop-up
<ul class="dropdown-menu dropdown-menu-right" role="menu" data-share-list="share" aria-labelledby="comment-dropup-menu-2929">
<li><a rel="nofollow" data-share="facebook" href="http://facebook.com/share.php?u=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-facebook"></i> Facebook</a></li>
<li><a rel="nofollow" data-share="twitter" href="https://twitter.com/intent/tweet?url=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-twitter"></i> Twitter</a></li>
<li><a rel="nofollow" data-share="googlePlus" href="http://plus.google.com/share?url=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-google-plus"></i> Google+</a></li>
<li><a rel="nofollow" data-share="renren" href="http://share.renren.com/share/buttonshare?link=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-renren"></i> 人人網</a></li>
<li><a rel="nofollow" data-share="sinaWeibo" href="http://v.t.sina.com.cn/share/share.php?url=http%3A%2F%2Fcityuge.swiftzer.net%2Fcomments%2F2929"><i class="fa fa-fw fa-weibo"></i> 新浪微博</a></li>
</ul>
<button type="button" id="comment-dropup-menu-2929" class="btn btn-comment-footer dropdown-toggle" data-toggle="dropdown">
var config = {
// Social media share pop-up sizes.
socialMedia: {
facebook: {
width: 520,
height: 350
},
twitter: {
width: 550,
height: 420
},
googlePlus: {
width: 500,
height: 380
},
renren: {
width: 626,
height: 436
},
sinaWeibo: {
width: 607,
height: 523
}
}
};
var comment = (function() {
var socialMediaLink = function() {
$('ul[data-share-list] a').click(function(e) {
e.preventDefault();
$el = $(this);
window.open($el.attr('href'), '', socialMediaPopUpSpec($el.attr('data-share')));
});
}
var socialMediaPopUpSpec = function(mediaKey) {
var socialMedia = config.socialMedia[mediaKey];
return 'scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=' + socialMedia.width
+ ',height=' + socialMedia.height
+ ',left=' + ((screen.width - socialMedia.width) / 2)
+ ',top=' + ((screen.height - socialMedia.height) / 2);
}
return {
initMasonry: function() {
if ($('#comment-container').length !== 0) {
new Masonry('#comment-container', {
transitionDuration: 0,
itemSelector: '.comment-wrapper',
columnWidth: '.comment-wrapper-dummy'
});
}
},
initComment: function() {
socialMediaLink();
$('[data-toggle="tooltip"]').tooltip();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment