Giter VIP home page Giter VIP logo

share.js's Introduction

share.js

A simple, lightweight jQuery plugin that provides a considered approach to social sharing, allowing for complete control of styling (no iframes) and supporting share counts for both Facebook and Twitter.

Currently in pre-release, feedback and issues welcome.

Installation

Include script after the jQuery library:

<script src="/path/to/share.js"></script>

Usage

Any link on a site can become sharable through the use of the following data tags:

<a href="#share" 
   data-share="twitter" 
   data-url="https://github.com/scottsanders/share.js" 
   data-message="Finally, a simple solution to social sharing" 
   data-via="scottsanders">share.js</a>

Then in your jQuery call the plugin as follows:

jQuery('a[data-share]').share();

The data attributes currently supported by the plugin are:

data-share : The social network you want to share on, currently supports facebook, twitter, whatsapp, email and print

data-url : The url to be shared, used to retrieve share count, defaults to page url

data-message : The default text of the shared message, supported by twitter, whatsapp, and email

data-via : The twitter username to include with the shared message, only supported by twitter

data-popup : The sharing screen shows in a popup window rather than redirecting, defaults to true

data-count : Determines whether or not to show the share count on this specific share link, defaults to true

Options

This plugin supports the following options:

jQuery('a').share({
  threshold: 0,
  abbreviate: true,
  counts: true
});

threshold : Hides the sharing count until a certain number of shares has been reached

abbreviate : Abbreviates large numbers when sharing is high, so 15101 shares become 15k.

counts : Determines whether to show share counts, can be overwridden per share link with data-count

Authors

Scott Sanders

share.js's People

Contributors

scottsanders avatar tommaitland avatar

Watchers

James Cloos avatar

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.