Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.5 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.5 KB

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.