Skip to content

Get Social Network Share Counts with Vanilla JS

License

Notifications You must be signed in to change notification settings

uzen/Socialight

 
 

Repository files navigation

Socialight

Get Social Network Share Counts with Vanilla JS

Demo

View demo here.

How to use?

In HTML, set the element that will be displayed counters, an example can be seen below:

<div class="social" data-url="http://www.pinceladasdaweb.com.br/"></div>

Socialight is a Vanilla JS plugin with no dependancies. Include the socialight.min.js in the footer of your page and initialise it:

(function(window, document, undefined) {
    "use strict";

    function SocialightFacade ($element) {
        var socialight = new Socialight({
                container: $element,
                url: $element.getAttribute("data-url")
            });

        socialight.add(new Twitter());
        socialight.add(new Facebook());
        socialight.add(new GooglePlus());
        socialight.add(new LinkedIn());
        socialight.add(new Buffer());
        socialight.add(new Pinterest());

        socialight.draw();
    }

    var el = document.querySelectorAll(".social"), i, len;

    for (i = 0, len = el.length; i < len; i++) {
        SocialightFacade(el[i]);
    }

}(window, document));

The plus.php file is responsible for making the request to return the data from Google+.

Browser support

IE8+ and modern browsers.

License

Socialight is licensed under the MIT License.

About

Get Social Network Share Counts with Vanilla JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 78.9%
  • HTML 8.4%
  • PHP 7.7%
  • CSS 5.0%