Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created February 24, 2018 02:12
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 ayamflow/a3f1bd88c11c3e8a0c542e470c8de94a to your computer and use it in GitHub Desktop.
Save ayamflow/a3f1bd88c11c3e8a0c542e470c8de94a to your computer and use it in GitHub Desktop.
Inline sharing
export default {
facebook(url) {
if (url.indexOf('http') < 0) {
url = location.protocol + '//' + location.host + url;
}
window.open('http://www.facebook.com/dialog/feed?app_id=' + FACEBOOK_ID +
'&link=' + SITE__URL +
'&picture=' + url +
'&name=' + encodeURIComponent('title') +
'&caption=' + encodeURIComponent('caption') +
'&description=' + encodeURIComponent('description') +
// '&redirect_uri=' + SITE_URL + // in WebViews (IG, TW, FB Browsers), impossible to open tabs so need redirect back to the site
'&display=popup', '_blank');
},
twitter(url) {
if (url.indexOf('http') < 0) {
url = location.protocol + '//' + location.host + url;
}
window.open('https://twitter.com/intent/tweet?original_referer=' + url + '&source=tweetbutton&text=' + encodeURIComponent(url) + '&', '_blank');
},
download(url) {
if (url.indexOf('http') < 0) {
url = location.protocol + '//' + location.host + url;
}
window.open(url, '_blank');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment