module.exports.init = function() { $(".shareBtns").find('a').click(function(e) { e.preventDefault() var url = $(this).attr('href') var social_platform = $(this).data('social') switch (social_platform) { case 'facebook': faceWindow(url) break case 'twitter': tweetWindow(url) break case 'pinterest': pinterestWindow(url) break case 'linkedin': linkedInWindow(url) break } }) // Facebook function faceWindow(url) { // var url = 'httpster.net' //location.href // var title = document.title // "http://www.facebook.com/sharer.php?u=" + // encodeURIComponent(url) + "&t=" + // encodeURIComponent(title), window.open( url, "facebook", windowFeatures(555, 588) ) } // Twitter function tweetWindow(url) { window.open( url, "tweet", windowFeatures(550, 250) ) } // Twitter function pinterestWindow(url) { window.open( url, "pinterest", windowFeatures(750, 520) ) } // LinkedIn function linkedInWindow(url) { window.open( url, "linkedin", windowFeatures(650, 478) ) } function windowFeatures(w, h) { var left_offset = (window.screen.width / 2) - ((w / 2) + 10); var top_offset = (window.screen.height / 2) - ((h / 2) + 50); return [ 'width=' + w, 'height=' + h, 'status=no', 'resizable=1', 'left=' + left_offset, 'screenX=' + left_offset, 'top=' + top_offset, 'screenY=' + top_offset, ].join(',') } }