Skip to content

Instantly share code, notes, and snippets.

@leobauza
Last active August 29, 2015 14:01
Show Gist options
  • Save leobauza/4c2f9b72489f9944ee6a to your computer and use it in GitHub Desktop.
Save leobauza/4c2f9b72489f9944ee6a to your computer and use it in GitHub Desktop.
Popups for Twitter or Facebook
App.social = (function () {
var tweet = '.share ul li:first-child a',
fbook = '.share ul li:nth-child(2) a',
pin = '.share ul li:last-child a';
function openIntent(url, w, h) {
the_window = window.open(url, '', 'width=' + w + ',height=' + h)
the_window.focus();
}
function init () {
var $tweet = $(tweet),
$fbook = $(fbook);
$pin = $(pin)
if(!$tweet.length || !$fbook.length || !$pin.length) {
console.log('no social btn');
return;
}
//unbind if already bound to prevent stacking
$(tweet + ',' + fbook + ',' + pin).unbind("click");
//tweet button handler
$tweet.click(function(e){
e.preventDefault();
var pass_tweet_url = $(this).attr('href');
openIntent(pass_tweet_url, 540, 420);
});
//facebook share button handler
$fbook.click(function(e){
e.preventDefault();
var pass_share_url = $(this).attr('href');
openIntent(pass_share_url, 640, 394);
});
pin share button handler
$pin.click(function(e){
e.preventDefault();
var pass_share_url = $(this).attr('href');
openIntent(pass_share_url, 750, 288);
});
}
init();
return {
init: init
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment