This time I will share jQuery Plugin and tutorial about Simple jQuery Plugin For Custom Social Share Buttons – SocialJS, hope it will help you in programming stack.
SocialJS is a simple lightweight jQuery plugin to generate custom social buttons with share counts for sharing your webpage over 5 major social networking sites: Twitter, Facebook, Linkedin, Google Plus, and Reddit.
How to use it:
1. Load the stylesheet socialjs.css
in the head section for default social button styles.
1 |
< link href = "dist/socialjs.css" rel = "stylesheet" > |
2. Load the Font Awesome for social media icons (OPTIONAL).
1 |
< link rel = "stylesheet" href = "font-awesome.min.css" > |
3. Create a list of social share buttons and use data-
attribute to setup the sharing options.
data-sharetype
: twitter, facebook, linkedin, googleplus, reddit
data-basecount
: Base count
data-text
: If not specified the plugin will take the title of the page as text.
data-via
: For Twitter
data-related
: For Twitter
01 |
< div class = "socialjs" > |
04 |
< a class = "sharebutton facebook" |
06 |
data-sharetype = "facebook" |
07 |
data-text = "Text to share" |
08 |
title = "Title to share" |
10 |
< i class = " fa fa-facebook" ></ i > |
11 |
< span class = "count" ></ span > |
4. Call the plugin on the top element.
1 |
$( '.socialjs' ).socialjs(); |
5. Available options and callback functions. Options can be overwritten when initializing plugin, by passing an object literal, or after initialization.
05 |
container: '.socialjs' , |
12 |
GooglePlus: 'backend/GooglePlusCall.php' , |
25 |
onInit: function () {}, |
26 |
onLoad: function () {}, |
27 |
onDestroy: function () {}, |
28 |
onClick: function (){}, |
6. Public methods.
02 |
$( '#el' ).socialjs( 'destroy' ) |
05 |
$( '#el' ).socialjs( 'getTotalCount' ) |
08 |
$( '#el' ).socialjs( 'getFacebookCount' ) |
11 |
$( '#el' ).socialjs( 'getGoolgePlusCount' ) |
14 |
$( '#el' ).socialjs( 'getTwitterCount' ) |
17 |
$( '#el' ).socialjs( 'getRedditCount' ) |
20 |
$( '#el' ).socialjs( 'getLinkedinCount' ) |
Changelog:
2019-09-13
This awesome jQuery plugin is developed by SubZane. For more Advanced Usages, please check the demo page or visit the official website.