Giter Site home page Giter Site logo

socialsharer's Introduction

SocialSharer

最 Pure 的社会化分享按钮

演示

DEMO

安装

npm install social-sharer --save

使用

<!-- HTML -->
<div class="social-sharer"></div>

<!-- CSS (optional) -->
<link href="../dist/social-sharer.min.css">

<!-- JS -->
<script src="../dist/social-sharer.min.js"></script>
<script>
var socialSharer = new SocialSharer(".social-sharer");
</script>

<!-- jQuery -->
<script src="../dist/jquery.social-sharer.min.js"></script>
<script>
$(".social-sharer").socialSharer();
</script>

如果元素内包含带 data-service 属性的元素,插件会直接使用这些元素,并忽选项中的services 参数:

<div class="social-sharer">
    <a data-service="weibo"     title="分享到微博"></a>
    <a data-service="wechat"    title="分享到微信"></a>
    <a data-service="qq"        title="分享给QQ好友"></a>
    <a data-service="yingxiang" title="分享到印象笔记"></a>
</div>

选项

参数 类型 默认值 描述
url string "" 网址,dataset.url > meta[property="og:url"] > link[rel="canonical"] > location.href
title string "" 标题,dataset.title > meta[property="og:title"] > document.title
description string "" 描述,dataset.description > meta[property="og:description"] > meta[name="description"]
pic string "" 图片,dataset.pic > meta[property="og:image"] > document.images[0]
source string "" 网站名称,meta[property="og:site_name"]
weiboKey string "" 显示微博来源的 AppKey
twitterVia string "" Twitter 参数
twitterHashTags string "" 参见:https://dev.twitter.com/web/tweet-button/web-intent
wechatTitle string "分享到微信" 微信二维码标题
wechatTip string "用微信「扫一扫」上方二维码即可。" 微信二维码提示文字
qrcodeSize number 260 微信二维码尺寸
services array ["weibo", "wechat", "qzone", "qq", "douban", "yingxiang"] 要使用的服务列表,目前支持:weibo, wechat, qzone, qq, douban, yingxiang, renren, facebook, twitter, gplus, linkedin, evernote, email, webshare
classNamePrefix string "icon icon-" 分享图标的 CSS 类前缀
onRender function null 生成分享图标后会调用该函数,参数:icon:element, serviceName:string
onClick function null 点击分享图标后会调用该函数,参数:event:object, serviceName:string

你可以通过给元素设置 data-* 属性来设置对应选项(function类型除外)。例如:

<div class="social-sharer" data-title="标题" data-weibo-key="1234567" data-services="qq,weibo,linkedin"></div>

方法

静态方法

SocialSharer.addService(serviceName:string, urlTemplate:string)

添加服务

实例方法

getURL(serviceName:string)

返回服务的分享地址(微信返回二维码地址)

License

MIT

socialsharer's People

Contributors

cople avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yimik

socialsharer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.