87,984
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
.social-share li {display: inline-block;margin-right: 5px;transition: transform 0.5s;}
.social-share li a {color: #fff;display: inline-block;text-align: center;border-radius:50%;-webkit-border-radius:50%;-moz-border-radius:50%;-ms-border-radius:50%;-o-border-radius:50%;}
.social-share li:hover {transform: rotate(360deg);}
.social-share-lg li a {font-size: 24px;height: 64px;width: 64px;line-height: 64px;}
.social-share-md li a {font-size: 20px;height: 48px;width: 48px;line-height: 48px;}
.social-share-sm li a {font-size: 16px;height: 36px;width: 36px;line-height: 36px;}
.social-share-xs li a {font-size: 12px;height: 24px;width: 24px;line-height: 24px;}
/* qrcode */
.qrcode-dialog {width: auto;display: none;position: fixed;top: 50%;left: 50%;width: 286px;height: 322px;margin-top: -150px;margin-left: -143px;box-shadow: 0 5px 15px rgba(0, 0, 0, .5);background: #FFF;}
.qrcode-dialog.show {display: block;}
.qrcode-dialog .qrcode-header{padding: 15px 15px 5px;}
.qrcode-dialog .qrcode-header .dismiss {float: right;font-weight: bold;cursor: pointer;}
.qrcode-dialog .qrcode-body {padding: 10px 15px;}
/* brand logos */
.social-share .qq a {cursor:pointer;background:#4DAFEA url(public/share-qq.png) no-repeat 0;background-size: cover;}
.social-share .qzone a {cursor:pointer;background:#EECF3D url(public/share-qzone.png) no-repeat 0;background-size: cover;}
.social-share .sina a {cursor:pointer;background:#DF4D69 url(public/share-sina.png) no-repeat 0;background-size: cover;}
.social-share .wechat a {cursor:pointer;background:#3EB135 url(public/share-weixin.png) no-repeat 0;background-size: cover;}
</style>
</head>
<body>
<div class="socialShare"></div>
<script src="https://cdn.bootcss.com/jquery/1.8.2/jquery.js"></script>
<script src="https://rawgit.com/harttle/social-share/master/src/qrcode.min.js"></script>
<script>
(function($) {
var defaultConfig = {
size: 'md',
links: {},
blank: true,
classMapping: {}
};
function socialShare(config) {
config = $.extend({}, defaultConfig, config);
var links = parseLinks(config.links),
$this = $(this);
var $ul = $('<ul class="list-unstyled social-share">');
$ul.addClass('social-share-' + config.size);
links.map(function(link) {
$ul.append(render(link, config));
});
$this.append($ul);
}
function render(link, config) {
var cls = 'fa-' + (config.classMapping[link.name] || link.name),
$li = $('<li class="social-share-item">'),
$a = $('<a>', {
href: link.url
}),
$i = $('<i>', {
class: 'fa ' + cls
});
$a.append($i);
if (config.blank) $a.attr('target', '_blank');
$li.append($a);
$li.addClass(link.name);
if(link.name === 'wechat'){
$a.removeAttr('href');
$a.removeAttr('target');
$li.click(function(){
qrCodeHandler(link.url);
});
}
return $li;
}
function parseLinks(links) {
var res = [];
for (var k in links) {
if (links.hasOwnProperty(k)) {
res.push({
name: k,
index: links[k].index,
url: links[k].url,
});
}
}
res.sort(function(lhs, rhs) {
return lhs.index - rhs.index;
});
return res;
}
function qrCodeHandler(url) {
var tml =
'<div class="qrcode-dialog"> ' +
' <div class="qrcode-header">' +
' <span class="dismiss">×</span>' +
' <header>手机扫描二维码</header>' +
' </div>' +
' <div class="qrcode-body"> ' +
' </div>' +
'</div>',
$modal = $(tml);
var qrcode = new QRCode($modal.find('.qrcode-body').get(0), {
text: url,
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#FFFFFF",
correctLevel: QRCode.CorrectLevel.H
});
$modal.find('.qrcode-header .dismiss').click(function() {
$modal.remove();
});
$modal.appendTo('body').addClass('show');
}
$.fn.socialShare = socialShare;
})(jQuery);
</script>
<script>
var weiboConfig = {
appkey: '234466545656',
title: encodeURIComponent('分享标题'),
desc: encodeURIComponent('分享描述'),
site: encodeURIComponent('来源网站'),
pics: encodeURIComponent('http://www.baidu.com/logo.gif'),
url: encodeURIComponent('http://www.baidu.com/')
},
links = {
qq: {
index: 1,
url: 'http://connect.qq.com/widget/shareqq/index.html?url='+weiboConfig.url+'&title='+weiboConfig.title+'&desc='+weiboConfig.desc+'&summary=&site='+weiboConfig.site+'&pics='+weiboConfig.pics
},
qzone: {
index: 2,
url: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+weiboConfig.url+'&title='+weiboConfig.title+'&desc='+weiboConfig.desc+'&summary=&site='+weiboConfig.site+'&pics='+weiboConfig.pics
},
sina: {
index: 3,
url: 'http://service.weibo.com/share/share.php?url='+weiboConfig.url+'&title='+weiboConfig.title+'&appkey='+weiboConfig.appkey+'&pic='+weiboConfig.pics+'&searchPic=true'
},
wechat: {
index: 4,
url: location.href
}
};
$('div.socialShare').socialShare({ links: links, size: 'lg'});
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
.social-share li {display: inline-block;margin-right: 5px;transition: transform 0.5s;}
.social-share li a {color: #fff;display: inline-block;text-align: center;}
.social-share li:hover {transform: rotate(360deg);}
.social-share-lg li a {font-size: 24px;height: 64px;width: 64px;line-height: 64px;}
.social-share-md li a {font-size: 20px;height: 48px;width: 48px;line-height: 48px;}
.social-share-sm li a {font-size: 16px;height: 36px;width: 36px;line-height: 36px;}
.social-share-xs li a {font-size: 12px;height: 24px;width: 24px;line-height: 24px;}
/* qrcode */
.qrcode-dialog {width: auto;display: none;position: fixed;top: 50%;left: 50%;width: 286px;height: 322px;margin-top: -150px;margin-left: -143px;box-shadow: 0 5px 15px rgba(0, 0, 0, .5);background: #FFF;}
.qrcode-dialog.show {display: block;}
.qrcode-dialog .qrcode-header{padding: 15px 15px 5px;}
.qrcode-dialog .qrcode-header .dismiss {float: right;font-weight: bold;cursor: pointer;}
.qrcode-dialog .qrcode-body {padding: 10px 15px;}
/* brand logos */
.social-share .qq a {cursor:pointer;background:#4DAFEA url(public/share-qq.png) no-repeat 0;background-size: cover;}
.social-share .qzone a {cursor:pointer;background:#EECF3D url(public/share-qzone.png) no-repeat 0;background-size: cover;}
.social-share .sina a {cursor:pointer;background:#DF4D69 url(public/share-sina.png) no-repeat 0;background-size: cover;}
.social-share .wechat a {cursor:pointer;background:#3EB135 url(public/share-weixin.png) no-repeat 0;background-size: cover;}
</style>
</head>
<body>
<div class="socialShare"></div>
<script src="https://cdn.bootcss.com/jquery/1.8.2/jquery.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="https://rawgit.com/harttle/social-share/master/src/qrcode.min.js"></script>
<script>
(function($) {
var defaultConfig = {
size: 'md',
links: {},
blank: true,
classMapping: {}
};
function socialShare(config) {
config = $.extend({}, defaultConfig, config);
var links = parseLinks(config.links),
$this = $(this);
var $ul = $('<ul class="list-unstyled social-share">');
$ul.addClass('social-share-' + config.size);
for (var i = 0, len = links.length; i < len; i++)
$ul.append(render(links[i], config));
$this.append($ul);
}
function render(link, config) {
var cls = 'fa-' + (config.classMapping[link.name] || link.name),
$li = $('<li class="social-share-item">'),
$a = $('<a>', {
href: link.url
}),
$i = $('<i>', {
"class": 'fa ' + cls
});
$a.append($i);
if (config.blank) $a.attr('target', '_blank');
$li.append($a);
$li.addClass(link.name);
if(link.name === 'wechat'){
$a.removeAttr('href');
$a.removeAttr('target');
$li.click(function(){
qrCodeHandler(link.url);
});
}
return $li;
}
function parseLinks(links) {
var res = [];
for (var k in links) {
if (links.hasOwnProperty(k)) {
res.push({
name: k,
index: links[k].index,
url: links[k].url,
});
}
}
res.sort(function(lhs, rhs) {
return lhs.index - rhs.index;
});
return res;
}
function qrCodeHandler(url) {
var tml =
'<div class="qrcode-dialog"> ' +
' <div class="qrcode-header">' +
' <span class="dismiss">×</span>' +
' <header>手机扫描二维码</header>' +
' </div>' +
' <div class="qrcode-body"> ' +
' </div>' +
'</div>',
$modal = $(tml);
var qrcode = new QRCode($modal.find('.qrcode-body').get(0), {
text: url,
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#FFFFFF",
correctLevel: QRCode.CorrectLevel.H
});
$modal.find('.qrcode-header .dismiss').click(function() {
$modal.remove();
});
$modal.appendTo('body').addClass('show');
}
$.fn.socialShare = socialShare;
})(jQuery);
var weiboConfig = {
appkey: '234466545656',
title: encodeURIComponent('分享标题'),
desc: encodeURIComponent('分享描述'),
site: encodeURIComponent('来源网站'),
pics: encodeURIComponent('http://www.baidu.com/logo.gif'),
url: encodeURIComponent('http://www.baidu.com/')
},
links = {
qq: {
index: 1,
url: 'http://connect.qq.com/widget/shareqq/index.html?url='+weiboConfig.url+'&title='+weiboConfig.title+'&desc='+weiboConfig.desc+'&summary=&site='+weiboConfig.site+'&pics='+weiboConfig.pics
},
qzone: {
index: 2,
url: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+weiboConfig.url+'&title='+weiboConfig.title+'&desc='+weiboConfig.desc+'&summary=&site='+weiboConfig.site+'&pics='+weiboConfig.pics
},
sina: {
index: 3,
url: 'http://service.weibo.com/share/share.php?url='+weiboConfig.url+'&title='+weiboConfig.title+'&appkey='+weiboConfig.appkey+'&pic='+weiboConfig.pics+'&searchPic=true'
},
wechat: {
index: 4,
url: location.href
}
};
$('div.socialShare').socialShare({ links: links, size: 'lg'});
</script>
</body>
</html>