Giter VIP home page Giter VIP logo

socialcount's Introduction

⚠️ Unmaintained: SocialCount

Per our unmaintained repository status documentation this repository is in an as-is state and is no longer accepting issue reports or pull requests.

Filament Group

Copyright (c) 2012 Filament Group, developed by @zachleat. MIT licensed.

Related: Filament Group Lab Post

The problems with social networking widgets are well documented. They're heavy and slow to load especially on high-latency mobile connections.

SocialCount is a small jQuery plugin for progressively enhanced, lazy loaded, mobile friendly social networking widgets.

  • Currently supports Facebook, Twitter, and Google Plus.
  • 1.12 kB CSS and 2.73 kB JS (after Min+GZip—compared to 366 kB, or 100 kB repeat view, for Facebook, Twitter, and Google Plus widgets)
  • 1 JS request, 1 CSS request, 1 optional request for icons (compared to 21 total requests for Facebook, Twitter, and Google Plus widgets)
  • Easy to fit in with existing page design
  • Ability to share without JavaScript or before JavaScript has loaded.
  • Works with mouse, touchscreen, or keyboard.
    • Mouse: On hover, loads a social network's native widget so that the user can Like/Recommend/+1 without leaving the current page.
    • Touch screen: simple redirects to dedicated network share pages.
    • Keyboard: Concise tab order.
  • Intelligent client-side caching so that two or more widgets with the same share URL only make one AJAX request.
  • Requires jQuery 1.6+

Note that while this project is named SocialCount, the server side code to fetch the share counts was removed. Both Twitter and Facebook have or will remove their public share count APIs. This functionality is going bye bye.

Getting Started

Install via NPM (npm install --save fg-socialcount).

Alternatively, the following archive contains both minified (socialcount.min.js+socialcount.min.css) and unminified (socialcount.js+socialcount.css) versions of the JS and CSS required to use SocialCount.

By default, the social networking icons are not included. However, SocialCount publishes a version that does include the social networking icons: Use the regular socialcount.js with socialcount-with-icons.css or socialcount-with-icons.min.css and the included SD and HD image sprites.

Markup with icons:

Customize the sample markup below or use the provided markup generator.

<!-- Replace YOUR_CUSTOM_URL with the URL you're sharing -->

<ul class="socialcount" data-url="YOUR_CUSTOM_URL">

<li class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=YOUR_CUSTOM_URL" title="Share on Facebook"><span class="social-icon icon-facebook"></span><span class="count">Like</span></a></li>

<li class="twitter"><a href="https://twitter.com/intent/tweet?text=YOUR_CUSTOM_URL" title="Share on Twitter"><span class="social-icon icon-twitter"></span><span class="count">Tweet</span></a></li>

<li class="googleplus"><a href="https://plus.google.com/share?url=YOUR_CUSTOM_URL" title="Share on Google Plus"><span class="social-icon icon-googleplus"></span><span class="count">+1</span></a></li>

</ul>

Tested with

  • Chrome Desktop 23
  • Firefox 16
  • Opera 12
  • Safari 6
  • Internet Explorer 7 (Links Only)
  • Internet Explorer 8
  • Internet Explorer 9
  • Internet Explorer 10
  • Windows Phone 7.5

Touchscreens (Links Only)

  • BlackBerry 5
  • BlackBerry 6.1
  • BlackBerry 7
  • iOS 6
  • Chrome for iOS 21
  • Android 2.3

Contributing

Add unit tests for any new or changed functionality. Lint and test your JavaScript code using grunt and the grunt qunit command.

Release History

  • v0.1.0 Initial release
  • v0.1.1 Fix for IE (tested up to 9) issue with iframes and :hover rules
  • v0.1.2 Default AJAX request for counts to false, added zip download, better documentation for counts service.
  • v0.1.3 Added code to normalize service url directory (easier configuration).
  • v0.1.4 Fix for twitter widget share of non-current page URL. Added data-share-text.
  • v0.1.5 Option for activate on click, instead of hover. i18n Code, adds de_DE support. Fix for Google+ issue with disappearing tooltip. Local url filtering on counts service. More accurate Facebook counts.
  • v0.1.6 Added Pinterest button. Thanks @dustMason! Fix for IE10 support (wasn’t passing A-Grade test). Facebook button requires long form locale. Tweaks to German button sizes.
  • v0.1.7 Bug fix: #42
  • v0.1.8 Bug fix: #45
  • v0.1.9
  • v0.2.0 Removes Twitter from service, per Twitter’s API retirement.
  • v1.0.0

Advanced Options

  • SocialCount.activateOnClick = false; Global option to switch from load triggering on hover to a manual click.
  • SocialCount.thousandCharacter = 'K'; SocialCount.millionCharacter = 'M'; i18n Strings.
  • Use SocialCount.load( $element ) to programmatically load all of the SocialCount buttons in the $element object. You can pass a container with multiple types of buttons or a single button.

socialcount's People

Contributors

ddrager avatar dustmason avatar greenkeeperio-bot avatar idflood avatar jefflembeck avatar juukie avatar kkirsche avatar peterhry avatar zachleat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

socialcount's Issues

Twitter not picking up URL

Any idea why when I click the Twitter button the url is being ignored? Incidentally, this also doesn't work on the demo.

Incompatible with Font Awesome

I do think this is an issue since Font Awesome is highly popular font to use on websites for icons. When using both SocialCount does not show correctly since using of classes with "icon-" prefix is same as Font Awesome is using. Has anyone found a quick fix (without having to fix the whole CSS)?

Missing icon definitions from CSS

The content of socialcount-with-icons.css and socialcount.css is the same, so the icon definitions are missing from the -with-icons versions. The same with the minified versions.

Init problems when SocialCount is loaded too late.

If socialcount.js is executed after jQuery.ready() has fired no plugins will work.

Since the plugins are added at the end of the file, and "$(function() { ..." on line 327 will execute immediately when $().ready() has already been fired, init() will be called with empty plugins.

In my case this is happening because I'm using https://github.com/Cerdic/jQl to load jQuery and dependent code asynchronously.

Locale causing facebook not to work

In case someone else has the same problem. When locale is EL, the facebook like button does not work. Changeing the locale or removing it solves the problem.

URL granularity on Facebook

Reported by email, not yet confirmed

  1. Even though I've set the YOUR-URL to be specific to each Wordpress post, Facebook just see the main URL so it seems I've like the site, not specific pages.

  2. Facebook like doesn't seem to use the "add comment" version of the like button. This type of like shows up in a users feed, not just activity. A little better for site promotion.

Work with Ghostery extension

When remote script fail to load or buttons don't initialize correctly, the bare links should still be clickable.

Relative path for icons

Hi,

Thanks for this great module. I'm trying to make a drupal module for this and found that the images have "absolute" url in the css.

It's problematic when the library is included in another project. In this case the socialcount folder is placed in sites/all/libraries/.

So would it be to change /SocialCount/src/icon-hd-s9293bc9986.png to ./icon-hd-s9293bc9986.png ?

'Follow' variety

Hi,

I really like the social buttons in this way. I was wondering, though, if it would be possible to do the same for Twitter follow and maybe G+ 'add to circle'. For Facebook this is not really necessary, as - I believe - setting YOUR-URL as the FB page URL will like the page in question.

Thanks!

Define the minimum required jquery version

I've found that the javascript is not compatible with jQuery 1.4.4 (the version shipped with drupal 7).

The best solution for me would be to make the js compatible with this version but it would require to not depend on the deferred and promise. So if it's not possible there should be a note somewhere to tell the minimum version required.

Demo Doesn't Work

The demo page just shows some labels and nothing else at the moment.

Twitter button (at least on demo) blocked by Chrome's popup blocker

Great code! Found a few issues before I can use it, though. Wanted to get them over to you to make sure they're on your radar...

First, when I click the twitter button after rollover and population of the "real" social plugin, the window created by the button is blocked by chrome's popup blocker (at least on your demo page). Seems like that's a bit detriment to use of those buttons.

No facebook event bindings

If i subscribe to the facebook event "edge.create" this its not being called when clicked from Socialcount.

Using a standard like button the event is thrown without problem.

Locale setting not 100% compatible with facebook.

I had an issue with the facebook button not appearing on a french page.

The problem is that the html lang attribute follow the "BCP47" format, and facebook want something like "ISO language and country codes respectively, concatenated by an underscore".

The BCP format concatenate the language and country with a "-" if i'm right. At least, on a french wordpress the language attribute is "fr-FR".

Eventually simply replacing the "-" with an underscore is not really enough. In switzerland for instance there is a french part and the country code is CH. But I tried with "fr_CH" and facebook was still not showing up, changing it to "fr_FR" worked.

So one option would be to add a "data-locale" attribute to the social count container. This is not ideal but would be the most flexible solution.

Another option would be to have a function to convert BCP47 format to facebook format, but it may not be enough for some combination of language and country.

Sources:
https://developer.mozilla.org/en/docs/HTML/Global_attributes#attr-lang
https://developers.facebook.com/docs/internationalization/

edit: I'm not sure "fr-CH" is a valid BCP47 format and fr-FR is most common, so maybe just replacing the "-" with a "_" is a good solution"

Trigger loading programmatically

Instead of having for the user to hover to show the loading.gif and then the actual clickable link, have a way to invoke that programatically. Maybe on document load, dom ready, etc.

In real world sites, hovering on icons and waiting for it to come will turn off users

LinkedIn

Would it be possible to add LinkedIn please? :)

Encode social icons with base64, to increase mobile performance

I've encoded the icons with the folowing online base64 converter:
http://webcodertools.com/imagetobase64converter/Create

So in socialcount-with-icons.css, line 237, instead of:

background: url('icon-s8df06ae4f6.png') no-repeat;

It's better to put this:

background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAARCAQAAAD3PnMmAAACR0lEQVR42p1V7VXCMBR9ntP/soHdwLBBmACcgHYCZILKBOAE1gnECSgTEDeoG2QDvXmN/UzbxMcB+vGS3Hfvy030Q3NxZ//nMz3zN3T+3/x/mZHz7YUkLUmNjI0pad0phmCe5J5V7fB5Iu2RucC8C2Tm+EoqaAK0QIIZ4I4jPVOJt9X7g2VtGwCaMP+FUicpt9bzBbIEX2W80iTo3cRyCUNeshoC9b/MwGs012A3pjWgCCbGwD47CLvRnk52LVHDJ3pskiKHJJsJEGtuCM2VfzCADfPwB/AwKEMzc5pe6Q2g2+t8OLJL5BxB2ytGLTpNmE6BTkYbo2GjAlP9liyb4InNov1QtOJ9cHPMu3aCJgben4X6oCWnl7x4Vm/GKnnZGfwOZmNwlvKYAmNy7mWTvZooNHNAztvsdQgZxvcQ9IWFpRrw+CRn5GVQI+Hr1HPjxdZdrqzLhQtOnRt3D0JccR6CDokXbJOE5bu2bGs/4xaq4xZmU7o5zUFJPHhauNojJGI0yKM1v4carJrx21WrQAW1jrg/OXPfHXr3KAkFnbB8BRY0vf1MX17unHeOkj2YF43rDpQsej4zcPQw0JIhV2elYSvBoeIDWnvPL+me6WhGOtw86tiKnrE72eovDSETr6NYentEAbi7GrKiTyjqKDiyh7EZUHBNMbtDI02fMYmmODGYLW/GuRDWPP0i91Eusn3Utvd01MpyHAcSbZGBBcn3c8f4YfRNSf+O6C4kW8MFhD3mr9BFeRikd/gjCbc85QE1EERo/AJ9OqeVrSSTMgAAAABJRU5ErkJggg==) no-repeat;

Same for all other icons.

Facebook balloon hidden

The balloon popup that opens from the Facebook button on desktop devices is mostly hidden due to overflow:hidden on .socialcount.

This is currently reproducible on the demo page.

Ability to define a hovering time until activation

In order to prevent users from accidentially activating a button it would be great if one would be able to define a timespan of continous hovering before a button activates.

A typical scenario where this would help is when a user moves the mouse accross the screen and then also passes accross the button. Longer hovering and/or a click would guarantee that it is the user's intention to activate it.

Background: Here in Germany sites are not allowed to activate social plugins without permission from the user, because of privacy reasons. Not complying with that can get very expensive.

Info bubble when activated by click

When Social Count is configured to activate on click it should tell people when they click that they just activated the button and that they now need to click again to complete their action. Currently there is no indication of what is happening, so people think they have already shared the page with their first click.

Facebook appears to require PHP

For those of us who use something other than PHP (like Rails, Sinatra, Django, etc.) This plugin doesn't work. It appears to be calling for FB to send a PHP document which can't be rendered within any other environment.

The G+ and Twitter plugins work just fine...

thx, Art

Google+ button markup needs data-href specified

Code needs to be changed to

<div class="g-plusone" data-size="medium" data-annotation="none" data-href="' + url + '"></div>

since otherwise the button is prepopulated with the wrong URL when your site is using hashbangs (or anchors).

Does SocialCount allow text sharing?

I am looking for a widget that I can drop onto my web page with a textbox that allows comments to be shared on social networks? i.e. for visitors to be able to leave a comment about one of my products, which will then be uploaded to whichever social network they choose along with a recommendation or like. Have you got any suggestions? Can I do this using SocialCount? It seems to be limited to simple likes and recommendations at the moment.

thanks

Simon

Activate on 'click' instead of on 'mouseenter'

I like the plugin, as it is simple and functional, but wouldn't it be possible to activate the social widgets only on 'click' instead of on 'mouseenter'.
With on 'mouseenter' a user may accidentaly activate the widget and therefor send data to facebook, google+ or twitter.
I know it is probably not the plugin's main intention, but changing the code a little, or implementing an option to do so, could easily make it a good option for social-share-privacy-issues.

Not working in IE10 (with workaround)

The hover trigger doesn't fire on IE10, so when you hover over one of the elements it changes hover state but you don't see the "Loading" image and the native button for the service doesn't appear.

I've done this to address the issue for myself:
iaincollins@cf76fb0

I say workaround as it may not behave as expected on Windows tablet devices with this, but I suspect a lot of people are pretty indifferent to that.

Facebook button breaks when locale parameter is set

Twitter API Restricted

The Twitter API url used in SocialCount works when only minimal calls are made to the Twitter API. After throwing several hundred requests at it (probably 150, the logged-out API limit) I began to receive errors.

After checking out the dev documents, it was stated several times that using this method to get Tweet counts is not authorized and that developers should not use it.

They stated that the proper way is to set up an Application in your account and then use the Streaming API to get these counts.

Of course, that is all well and good, but it is considerably more difficult than currently so I'm not sure what a good solution to this is. Just wanted to open an issue to let others know about this, because it will begin to fail if you throw a lot of requests at it.

Google+ popover disappears on mouseover

Been having a problem with the Google+ sharing popover — appears fine when you click/hover on the button, but disappears as soon as you mouseleave the containing <li>

The quickest hack I could do to fix it was getting rid of the binding on mouseleave — it leaves the official share button displayed forever (so not the default behaviour) but at least it lets you actually click the Google+ share button in the popover!

$a.closest('li').bind('mouseenter', function() {
    $( this ).closest( 'li' ).addClass( 'hover' );
});

Any other solutions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.