Skip to content

Instantly share code, notes, and snippets.

@pyshchyk-o
pyshchyk-o / custom_social_media_share_buttons.md
Created June 16, 2016 10:06 — forked from cioddi/custom_social_media_share_buttons.md
social media share buttons with custom Text
@pyshchyk-o
pyshchyk-o / gist:1ebba39ce37f77644d7fa7608775e473
Created June 16, 2016 09:56 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@pyshchyk-o
pyshchyk-o / has_class.js
Created February 20, 2016 16:20 — forked from MakingJamie/has_class.js
has class function - vanilla JS. Check if element has specified class
// hasClass, takes two params: element and classname
function hasClass(el, cls) {
return el.className && new RegExp("(\\s|^)" + cls + "(\\s|$)").test(el.className);
}
/* use like below */
// Check if an element has class "foo"
if (hasClass(element, "foo")) {