Minimal jQuery Social Sharing Plugin - BEShare

File Size: 87.7 KB
Views Total: 7964
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Minimal jQuery Social Sharing Plugin - BEShare

BEShare is a jQuery plugin that provides a simple way to integrate social share links into your web page. Currently supports Facebook, Twitter, Google Plus, Print, Emai, SMS and Linkedin.

How to use it:

1. Load the required stylesheet file in the head section of your document.

<link rel="stylesheet" href="./styles.css">

2. Load the jQuery BEShare plugin's script after jQuery library.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jQuery-BEShare.min.js"></script>

3. Create a 'popup' social share widget that displays a popup window containing social share links when you click on a toggle element.

$('.popup').BEShare({

  // CSS class to custom the popup
  'class': 'popup-share'
  
});

4. Create inline social share links with social icons on your web page.

$('.inline-share').BEShare({
  'type': 'inline',
  'targets': ['Facebook', 'Twitter', 'LinkedIn', 'GPlus', 'Print', 'Email'],
  'onShare': function(targetName) {
    ga('send', 'event', 'Social', 'Click', 'Share', targetName);
  }
});

5. Default plugin options.

$('SELECTOR').BEShare({

  // popup or inline
  'type': 'popup',

  // 'Facebook', 'Twitter', 'LinkedIn', 
  // 'GPlus', 'Print', 'Email', 'SMS'
  'targets': ['Facebook', 'Twitter'],

  // addional CSS class
  'class': PLUGIN_NAME,

  // CSS prefix & suffix 
  'prefix': 'icon-',
  'suffix': '',

  // adds aria-label parameter to link
  'aria-prefix': 'Share on ',

  // width / height of the social share window
  'width': '626',
  'height': '436',

  // for twitter
  'via': '',

  // message to share
  'message': document.title,

  // callback
  'onShare': null,

  // to use "rel" parameter as the url to share
  'altLink': null,

  // removes hash
  'removeHash': false

});

Changelog:

2018-07-30

  • Add removeHash option

2018-07-25

  • v0.2.0: Add SMS share option

2018-06-14

  • v0.1.1

2018-03-08

  • Add aria-label attributes

2016-05-13

  • Support using href as full share URL

2015-07-02

  • Support `@via` in shared Tweet

This awesome jQuery plugin is developed by BrandExtract. For more Advanced Usages, please check the demo page or visit the official website.