forked from Wixel/share
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.share.js
31 lines (29 loc) · 1.16 KB
/
jquery.share.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*!
* Share jQuery plugin
*
* @author : http://twitter.com/nicovanzyl
* @author : http://twitter.com/wixelhq
* @url : https://github.com/Wixel/share.git
* @copyright: 2015 Wixel
* @license : MIT license
* @version : 0.0.1
*/
(function($) {
// Get the current URL
var pathname = window.location,
// Get data to share
shareTitle = $('.share-title').text(),
shareSubtitle = $('.share-sub').text(),
// shareBody = $('.share-body').text(),
// twitterHandle = 'wixelhq', - add into URL: &via=wixelhq
// Create the URL's
tweeturl = 'http://twitter.com/share?url='+encodeURI(pathname)+'&text='+shareTitle+' '+shareSubtitle,
fburl = 'http://www.facebook.com/sharer.php?u='+pathname,
gpurl = 'https://plus.google.com/share?url='+pathname,
liurl = 'https://www.linkedin.com/shareArticle?mini=true&url='+pathname+'&title='+shareTitle+'&summary='+shareSubtitle;
// add the URL's to anchors
$('.share-twitter').attr('href', tweeturl);
$('.share-fb').attr('href', fburl);
$('.share-gplus').attr('href', gpurl);
$('.share-linkedin').attr('href', liurl);
}(jQuery));