Giter Club home page Giter Club logo

jssocials's Introduction

jsSocials - Simple Social Sharing

Build Status jsDelivr Hits

Project site js-socials.com

jsSocials is a simple social network sharing jQuery plugin. It's flexible and easily extensible. Configure visual appearance. Choose one of several themes provided. Add any yet unsupported social network if needed.

jsSocials

Demos

Find demos on the project site.

Getting Started

  1. Download the package or install it with bower

    $ bower install jssocials
  2. Add links to jssocials.css and chosen theme, e.g. jssocials-theme-flat.css

  3. Add link to font-awesome.css (it's used for social network logos by default, yet you can replace it with image logo or other font if necessary)

  4. Add link to jquery.js and plugin script jssocials.min.js

  5. Apply jsSocials to the element on the page $("#share").jsSocials({ shares: ["twitter"] })

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="jssocials.css" />
    <link rel="stylesheet" type="text/css" href="jssocials-theme-flat.css" />
</head>
<body>
    <div id="share"></div>

    <script src="jquery.js"></script>
    <script src="jssocials.min.js"></script>
    <script>
        $("#share").jsSocials({
            shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp"]
        });
    </script>
</body>
</html>

Documentation

Themes

To turn on a specific theme just link one of available stylesheets

  • jssocials-theme-flat.css - flat theme
  • jssocials-theme-classic.css - classical theme with raised buttons
  • jssocials-theme-minima.css - minimalistic theme with logos instead of buttons
  • jssocials-theme-plain.css - monochromatic theme

flat

jsSocials - flat theme

classic

jsSocials - classic theme

minima

jsSocials - minima theme

plain

jsSocials - plain theme

Configuration

The config object may contain following options:

{
    shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "pocket", "whatsapp", "viber", "messenger", "vkontakte", "telegram", "line", "rss"],
    url: "http://url.to.share",
    text: "text to share",
    showLabel: true,
    showCount: true,
    shareIn: "popup",
    on: {
        click: function(e) {},
        mouseenter: function(e) {},
        mouseleave: function(e) {},
        ...
    }
}

shares :Array

An array of shares.

Each share can be a

  • string - name of share from registry jsSocials.shares (e.g. "twitter")
  • config - plain object with share as name and custom parameters specific for each share. Read more about share config in Share section.

For instance for twitter the config might look like:

{
    share: "twitter",           // name of share
    label: "Tweet",             // share button text (optional)
    via: "artem_tabalin",       // custom twitter sharing param 'via' (optional)
    hashtags: "jquery,plugin"   // custom twitter sharing param 'hashtags' (optional)
}

url :String

A string specifying url to share. Value of window.location.href is used by default.

text :String

A string specifying text to share. The content of <meta name="description"> or <title> (if first is missing) is used by default.

showLabel :true|false|function(screenWidth)

A boolean specifying whether to show the text on the share button. Also accepts function returning true|false depending on the screen width for adaptive rendering. Read more in Adaptiveness section.

showCount :true|false|"inside"|function(screenWidth)

A boolean or "inside" specifying whether and how to show share count. Also accepts function returning true|false|"inside" depending on the screen width for adaptive rendering. Read more in Adaptiveness section.

shareIn : "blank"|"popup"|"self"

version added: 1.2

A string specifying the name of sharing strategy. All strategies are stored in the registry jsSocials.shareStrategy.

There are 3 built-in sharing strategies:

blank - share in the new browser tab popup - share in the new browser popup window self - share in the same browser tab

Custom sharing strategies can be added to registry jsSocials.shareStrategy. Find more in Custom Share Strategy section.

on :Object

version added: v1.0

An object specifying the sharing link event handlers. Handlers for all supported by DOMElement events can be specified. The handlers will be attached to the share link. The context of handler is the share config. The argument of the handler is a jQuery event.

In the following example once a user clicks twitter sharing link, the sharing url is printed to the browser console

{
    on: {
        click: function(e) {
            if(this.share === "twitter") {
                console.log("tweet \"" + this.url + "\" at " + e.timeStamp);
            }
        }
    }
}

Methods

destroy()

Destroys the shares control and brings the Node to its initial state.

$("#share").jsSocials("destroy");

option(optionName, [optionValue])

Gets or sets the value of an option.

optionName is the name of the option.

optionValue is the new option value to set.

If optionValue is not specified, then the value of the option optionName will be returned.

// turn off share count
$("#share").jsSocials("option", "showCount", false);

// get sharing text
var text = $("#share").jsSocials("option", "text");

refresh()

Refreshes sharing control.

$("#share").jsSocials("refresh");

shareOption(shareName|shareIndex, optionName, [optionValue])

version added: 1.1

Gets or sets the value of a share option.

shareName|shareIndex is the name or the index of the share to get/set the option value.

optionName is the name of the share option.

optionValue is the new option value to set.

If optionValue is not specified, then the value of the share option optionName will be returned.

// change label of twitter share
$("#share").jsSocials("shareOption", "twitter", "label", "Tweet!");

// get label of the 2nd share
var secondShareOption = $("#share").jsSocials("shareOption", 1, "label");

jsSocials.setDefaults(config)

Set default options for all jsSocials.

jsSocials.setDefaults({
    showLabel: false,
    showCount: "inside"
});

jsSocials.setDefaults(shareName, config)

Set default options of particular share.

jsSocials.setDefaults("twitter", {
    via: "artem_tabalin",
    hashtags: "jquery,plugin"
});

Share

A share config has few applicable for all shares parameters. Yet each share may have specific parameters.

{
    share: "twitter",
    label: "Tweet",
    logo: "fa fa-twitter",
    css: "custom-class",
    shareIn: "blank",
    renderer: function() { ... }
}

share :String

A string name of the share. jsSocials supports following build-in shares: "email" | "twitter" | "facebook" | "googleplus" | "linkedin" | "pinterest" | "stumbleupon" | "pocket" | "whatsapp" | "viber" | "messenger" | "vkontakte" | "telegram" | "line" | "rss"

Adding any new share is simple and described in Custom Share section.

label :String

A string specifying the text to show on share button.

logo :String

A string specifying the share logo. It accepts following values:

  • css class - any non-url string is rendered as <i class="css class"></i>. Font awesome is used by default, but it can be redefined with any other css class.
  • image url - string in image url format is rendered as <img src="image url" />.
  • image base64 url - string in image base64 url format is rendered as <img src="image base64 url" />.

css: String

A string specifying spaces-separated custom css classes to attach to share DOM element.

shareIn : "blank"|"popup"|"self"

version added: 1.2

A string specifying the name of sharing strategy. It's identical to shareIn option of jsSocials, but specifies sharing strategy for a particular share.

Accepts the following values for built-in strategies:

blank - share in the new browser tab popup - share in the new browser popup window self - share in the same browser tab

Custom sharing strategies can be added to registry jsSocials.shareStrategy. Find more in Custom Share Strategy section.

renderer :function()

A function returning <div> with custom share content. The renderer is used for custom share scenario, e.g. using standard sharing component for particular network. If renderer is specified, then all other share parameters are ignored.

This is how to render native google plus share button with renderer:

$("#share").jsSocials({
    shares: [{
        renderer: function() {
            var $result = $("<div>");
    
            var script = document.createElement("script");
            script.src = "https://apis.google.com/js/platform.js";
            $result.append(script);
    
            $("<div>").addClass("g-plus")
                .attr({
                    "data-action": "share",
                    "data-annotation": "bubble"
                })
                .appendTo($result);
    
            return $result;
        }
    }]
});

Build-in Shares

The build-in social network shares have following configuration

email

{
    label: "E-mail",
    logo: "fa fa-at",
    to: "[email protected]",
    shareIn: "self"
}

twitter

{
    label: "Tweet",
    logo: "fa fa-twitter",
    via: "",                // a Twitter username specifying the source of a Tweet.
    hashtags: ""            // a comma-separated list of hashtags to be appended to Tweet text.
}

facebook

{
    label: "Like",
    logo: "fa fa-facebook"
}

googleplus

{
    label: "+1",
    logo: "fa fa-google-plus"
}

linkedin

{
    label: "Share",
    logo: "fa fa-linkedin"
}

pinterest

{
    label: "Pin it",
    logo: "fa fa-pinterest",
    media: ""               // a url of media to share
}

stumbleupon

{
    label: "StumbleUpon",
    logo: "fa fa-stumbleupon"
}

pocket

version added: 1.4

{
    label: "Pocket",
    logo: "fa fa-get-pocket"
}

whatsapp

version added: 1.1

{
    label: "WhatsApp",
    logo: "fa fa-whatsapp",
    shareIn: "self"
}

viber

version added: 1.4

{
    label: "Viber",
    logo: "fa fa-volume-control-phone",
    shareIn: "self"
}

messenger

version added: 1.4

{
    label: "Share",
    logo: "fa fa-commenting",
    shareIn: "self"
}

vkontakte

version added: 1.4

{
    label: "Like",
    logo: "fa fa-vk"
}

telegram

version added: 1.3

{
    label: "Telegram",
    logo: "fa fa-paper-plane"
}

line

{
    label: "LINE",
    logo: "fa fa-comment"
}

rss

version added: 1.5

{
    label: "RSS",
    logo: "fa fa-rss"
}

Custom Share

To register a custom share add it to jsSocials.shares registry.

This is how the twitter share is defined:

jsSocials.shares.twitter = {
    label: "Tweet",
    logo: "fa fa-twitter",
    shareUrl: "https://twitter.com/share?url={url}&text={text}&via={via}&hashtags={hashtags}",
    countUrl: "https://cdn.api.twitter.com/1/urls/count.json?url={url}&callback=?",
    getCount: function(data) {
        return data.count;
    }
};

If you wish to get your share styling for all supported themes, add its name and color to _shares.scss and build css.

Currently _shares.scss contains following collections:

$share-names: ('twitter', 'facebook', 'googleplus', 'linkedin', 'pinterest', 'email', 'stumbleupon', 'whatsapp', 'telegram', 'line', 'viber', 'pocket', 'messenger', 'vkontakte', 'rss');
$share-colors: (#00aced, #3b5998, #dd4b39, #007bb6, #cb2027, #3490F3, #eb4823, #29a628, #2ca5e0, #25af00, #7b519d, #ef4056, #0084ff, #45668e, #ff9900);

Each share has following parameters:

label :String

The default value of share label to display on the share button.

logo :String

A default value of share logo. Accepts css class or image url.

shareUrl :String|function()

A string or a function returning a string specifying the sharing url. It can contain any parameters in curly braces {param}. These parameters will be taken from share config. The {url} and {text} parameters are taken from jsSocials config.

countUrl :String|function()

A string or a function returning a string specifying the url to request shares count. It can contain any parameters in curly braces {param}. These parameters will be taken from share config. The {url} parameter is taken from jsSocials config. The countUrl option should be specified only if you are going to show share count (showCount is not false).

getCount :function(data)

A function retrieving count value from response received from countUrl. Accepts response data. The response data is used as count if function is not specified. If getCount returns a number, it will be formatted (e.g. 1200 to 1.2K). Return a string value to avoid automatic formatting.

Adaptiveness

Options showLabel and showCount accept function(screenWidth) that has screen width as an input parameter and returns the value specifying whether to show label (or count).

By default showLabel function returns following values:

  • true for all screens wider than 1024px (large screen)
  • true for all screens wider than 640px (small screen) when showCount is false
  • false in all other cases

By default showCount function returns following values:

  • true for all screens wider than 640px (small screen)
  • "inside" for all screens with width less than 640px (small screen)

These breakpoints are defined with jsSocials config options:

{
    smallScreenWidth: 640,
    largeScreenWidth: 1024
}

Thus these breakpoint values can be redefined in jsSocials config.

The adaptive behavior can be easily redefined with custom showLabel and showCount functions.

In this example we show counter for all screens wider than 1024px hiding count for other screens, and show label for screens wider 1280px hiding for other screens:

$("#share").jsSocials({
    showCount: function(screenWidth) {
        return (screenWidth > 1024);
    },
    
    showLabel: function(screenWidth) {
        return (screenWidth > 1280);
    },
    
    ...
});

Custom Share Strategy

version added: 1.2

A custom share strategy can be used to redefine standard behavior of sharing or customize rendering of a sharing control.
The sharing strategy is a function that accepts a single parameter { shareUrl: "http://your.share.url" } and should return a jQuery element. It should be added to jsSocials.shareStrategies hash.

In the following example we define a sharing strategy that shares in a browser window with custom params and instead of link <a> uses custom <div> element:

jsSocials.shareStrategies["my_popup"] = function(args) {
    return $("<div>").click(function() {
            window.open(args.shareUrl, "MyShareWindow", 
                "width=800, height=600, location=1, resizeable=1, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0");
        });
};

$("#share").jsSocials({
    shareIn: "my_popup",
    shares: ["twitter", "facebook", "googleplus"]
});

License

MIT © Artem Tabalin

jssocials's People

Contributors

andpozo avatar awaisdar001 avatar baca130 avatar capitalh avatar cedricvaneer avatar eranshmil avatar fgo avatar ifedapoolarewaju avatar ignotus avatar jacobdorman avatar lahphim avatar lukasdrgon avatar michi88 avatar ruud68 avatar tabalinas 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

jssocials's Issues

Popup instead new page

It is possible to configure popup on click instead of opening in share in new page (tab)?

Thank you in advance

WhatsApp question(s)

Hi, been trying to get whatsapp as part of one of the buttons and run into the following 'issue'.
the whatsapp url only has 1 parameter: 'text', but sending only text is not usefull when you are sharing a webpage :)

I have the following code in the jssocials.js:

        whatsapp: {
            label: "WhatsApp",
            logo: "fa fa-whatsapp",
            shareUrl: "whatsapp://send?text={text}",
            countUrl: ""
        },

What I want to do is sent the text AND the url, but your script doesn't parse that correctly...
shareUrl: "whatsapp://send?text={text} {url}", > doesn't work > result is "this is my article text {url}"
shareUrl: "whatsapp://send?text={text} ={url}", > doesn't work > result is "this is my article text ={url}"
shareUrl: "whatsapp://send?text={text}&url={url}", > url gets constructed, but whatsapp chokes on it :( > result is "this is my article text&url=https://...."

what I am now doing as a workaround is to construct the text + url in php and parse this to the jssocials script
{ share: "whatsapp", text: "this is my article text https://andthismyurl"},

so the question is, is it possible to parse the url via the jssocials.js script without the "&url="?

question 2: can I do a PR for my changes to the .css and .js files for adding whatsapp?

Add new function in shares

hello there!

i am new in doing web programming. Can i know is that anyway to add in new function into the shares. Say, when i click on the facebook button, i want to save something into my database or just simply alert something.

Thanks :)

Do not package the .sass-cache dir

Disclaimer: I do not use the package, this was found during automated npm packages downloading.

Your current package size is 1.1 KiB packed, 6.2 MiB unpacked. 5.9 MiB of that are inside the .sass-cache dir. I suspect that this probably got packed to the release by mistake.

You could add that dir to the .gitignore.

WhatsApp link generation broken?

First off - love the plugin - this is the first issue I've run across on the newer version.

I've tried the Whatsapp link from a webpage on a desktop in chrome, or on my ipad in safari - neither link works.

In safari I get a popup "Safari cannot open the page because the address is invalid".

If I try the whatsapp link from http://js-socials.com/ - in firefox it errors "The address wasn't understood" and this is in the addressbar whatsapp://send?text=http%3A%2F%2Fjs-socials.com%2F%20Simple%20Social%20Network%20Sharing%20Plugin

Any ideas for a quick patch? Will this even work from a desktop browser?

Thanks!

Customizing output

Hi!

  1. How can i divide 8 logos output to two rows with 4 logos on each?
    I anderstand its possible to make throw div1.jsSocials and div2.jsSocials but in large screen i need 2 rows in phones 1 row..
  2. And when a minimize screen - icons not aligned by cell - one icon not exactly under up icons.
  3. And one more q: how can i add to class jssocials-share my own classes?

How added Telegram Social...

#1) On jssocials.js

telegram: { label: "Telegram", logo: "fa fa-paper-plane", shareUrl: "tg://msg?text={url} {text}", countUrl: "", shareIn: "self" },

on css :

.jssocials-share-telegram .jssocials-share-link{background:#2CA5E0} .jssocials-share-telegram .jssocials-share-link:hover{background:#076D9F}

Regards

Mobile devices detection > private messaging > whatsapp

Hi, really love your script and I am currently working with it in a Joomla website.
I am currently investigating to implement private messaging (e.g. whatsapp).
This is possible with your script, but one functionality is missing that could come in handy.

Whatsapp is only available on mobile devices, so it would be really cool if it didn't show up on eg tablet or desktop.

Not sure if mobile device detection should be part of your script but maybe this is an idea that you could work with? Love to hear your thoughts on this!

Thanks a lot for sharing your amazing work with the world :)

whatsapp issue on some mobile browsers

Hi,
more and more people are using my Joomla plugin that displays the jssocials buttons on Joomla content pages.
Thats is good news... but I recently ran into an issue with a user where the whatsapp button didn't work.
As it turned out this user was running a specific browser for android and clicking the button resulted in a page not found error.
At first I thought it was an issue with his specific browser as using stock browser or firefox on his device did work.
Then he provided me with a website with whatsapp button that worked perfectly for his browser...

Did some digging and found the culprit in the way jssocials constructs the href for whatsapp (and for all buttons as that is a generic function)

According to whatsapp documentation (https://www.whatsapp.com/faq/nl/android/28000012) the url should be constructed as follows:

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

The way jssocials constructs this url is with target="_blank"

That is when it goes wrong... when omitting the target part from _createShareLink: function(share)
It works okay, but then there is the issue that the buttons (twitter, linkedin, facebook, etc.) do not open in a new window but override the current window.
For twitter, facebook, etc a new browser window should be opened as that is where the action takes place, for whats app a new window should not be opened: clicking the url kicks off the start of the app.

As I am not a JavaScript hero :) I was wondering if the target="_blank" part could be configured / toggled?

Doesn't work with gulp and main-bower-files plugin

I can't get this to work with gulp and main-bower-files plugin. I have checked bower.json all main files are there, but for some reason they doesn't get in the pipe.

This is snippet from my gulpfile.js:

var gulp = require('gulp'),
    bower = require('main-bower-files'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    plumber = require('gulp-plumber');

gulp.task('js', [], () => {
    var src = bower(['**/*.js']).concat([
        // Add custom files
    ]);
    return gulp.src(src)
        .pipe(plumber())
        .pipe(uglify())
        .pipe(concat('all.min.js'))
        .pipe(gulp.dest('dist/assets/js'));
});

Am I missing something?
Thanks

Adding "share via email"

Hi there,
Great plugin, very well done!
I would like to know though, is it possible to add an extra option to share pages via email?
Thanks :)

Populate count from element data

I'm looking for a way to populate count directly through HTML.

Something like
<div class="share" data-facebook-count="2" data-pinterest-count="4"> etc.

Any ideas appreciated.. I don't really want to modify the jssocials.js to do this, but I think there is no other way?
It would be nice if there was some function I could override to achieve this.

Thanks a lot for any help!

Facebook closes

Hi everything is working perfectly except facebook which opens and closes imediatly
Please if you have a way to solve this, please help me out

Can't get email adress on email share

I can 'r get the mail adress to be merged into the mailto querystring on the email share

Here is the script I've tried.

Can anybody help?

     <div id="shareIcons" style="text-align: right"></div>
                <script>
                    $("#shareIcons").jsSocials({
                        url: "http://www.rampelys.dk",
                        text: "Rampelys Silkeborg",
                        showLabel: false,
                        showCount: false,
                        shares: [{ share: "email", label: "[email protected]", text: "besked fra rampelys.dk", url:"" }, "facebook", "googleplus"] });

                    //$("#shareIcons").jsSocials("shareOption", "email", "text", "Besked fra www.rampelys.dk:");
                    //$("#shareIcons").jsSocials("shareOption", "email", "E-mail", "[email protected]");
                    //$("#shareIcons").jsSocials("shareOption", "email", "mailto", "[email protected]");
                    //$("#shareIcons").jsSocials("shareOption", "email", "url", "");


                </script>

`

sharing to Facebook doesn't take into account specified text

Following this example, Facebook doesn't set the text of the share dialog to "Google Search Page"

 $("#shareIconsCountInside").jsSocials({
     url: "http://www.google.com",
     text: "Google Search Page",
     showLabel: false,
     showCount: "inside",
     shares: ["twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp"]
 });

Accessibility

Hi,
I have integrated a little into jssocials, to make it usable for disabled person, especially for blind people and people with motoric disability.
a) I integrated in the definition of the shares in the .js file, a "title" like:

   ... whatsapp: {
           label: "WhatsApp",
           logo: "fa fa-whatsapp",
            shareUrl: "whatsapp://send?text={url} {text}",
            countUrl: "",
            **title**: "WhatsApp"
        }, ...

b) In the html definition I integrated a "tabindex" like:

      ... shares: [{
                 share: "facebook",
                 logo: "images/socials/fb_icon.png",
                 ** tabindex**: 19
              }, ...

c) in the function : _createShareLink: function(share)
I added following changes:

            var shareZiel = getOrApply(share.title, share)
            var $result = $("<a>").addClass(this.shareLinkClass)
                .attr({ href: this._getShareUrl(share), target: "_blank" })
                .attr({ alt: "Button, um Webseite zu teilen über "+shareZiel} )
                .attr({ title: "Button:"+shareZiel} )
                .attr({ tabindex: share.tabindex } )
                .append(this._createShareLogo(share));

Its german text - for the website I used jssocials.
Now, every Button has an "alt" and an "title" text for blind users and can be reached by the given "tabindex" with the keybord by users who have to use the keybord, to reach and click a link.

Thanks for your code tabalinas!!

Adding SVG base 64 support

Hi

First of all thank you very very much for this wonderful and easy to use social sharing plugin. After searching for days I can say this is the best plugin ever.

I did some minor changes to the core files to add base64 svg support for social logos.

In jssocial.js file I changed line 16 to the following:

var IMG_SRC_REGEX = /(\.(jpeg|png|gif|bmp|svg\+xml)$|^data:image\/(jpeg|png|gif|bmp|svg\+xml);base64)/i;

I hope this could help some people who just like me prefer SVG icons to font icons when you only need 1 or 2 of them.

Uncaught TypeError: $ is not a function

I get this about that :

<script>
        $("#share").jsSocials({
            shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "whatsapp"]
        });
    </script>

facebook preview not showing correctly

Hi Artem,

I integrated jssocials plugin in the website conceptcradle.com. When I try to share in facebook the preview is only showing the title and the url. How can I display the image and description in the facebook preview? Is there a way to control the previews for facebook and google plus?

Thanks,

Con

Updating an option doesn't refresh the links

When I'm updating an option with the so called method, the social links don't get refreshed.

$social.jsSocials("option", "url", newUrl);

The refresh method does refresh the code, but as the new option value is not pushed to the "shares" object, the shared link doesn't get refreshed.

A working option method looks likes this for me.

option: function(key, value) {
    if(arguments.length === 1) {
        return this[key];
    }

    this[key] = value;

    $.each(this.shares, function(idx, share) {
        share[key] = value;
    });

    this.refresh();
}

Comments are welcome.

getCount for new StumbleUpon

Hi,
I am working on new share: StumbleUpon, I cannot seem to get the share counter right :(

         stumbleupon: {
            label: "StumbleUpon",
            logo: "fa fa-stumbleupon",
            shareUrl: "http://www.stumbleupon.com/submit?url={url}&title={title}",
            countUrl:  "https://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}",
            getCount: function(data) {
                return parseFloat((data.match(/\"views\":([.0-9E]+)/) || [])[1]);
            }

when I do https://www.stumbleupon.com/services/1.01/badge.getinfo?url=https://www.google.com
this is what is returned:

{"result":{"url":"https:\/\/www.google.com\/","in_index":true,"publicid":"1krtS0","views":14834,"title":"Google","thumbnail":"http:\/\/cdn.stumble-upon.com\/mthumb\/647\/5593647.jpg","thumbnail_b":"http:\/\/cdn.stumble-upon.com\/bthumb\/647\/5593647.jpg","submit_link":"http:\/\/www.stumbleupon.com\/badge\/?url=https:\/\/www.google.com\/","badge_link":"http:\/\/www.stumbleupon.com\/badge\/?url=https:\/\/www.google.com\/","info_link":"http:\/\/www.stumbleupon.com\/url\/https%253A\/\/www.google.com\/"},"timestamp":1455201235,"success":true}

What is de function / regex to get the views out of this response?
I'm really lacking Javascript knowledge :(
If I get this working and confirmed by a user I will do a PR for the changes :)

Pulling in Data to facebook

When I use your script I can not get the data to display in the popout window for facebook. Here is my code

$(".social-share-block").jsSocials({ url: window.location.href, text: {TEXT HERE}, showCount: false, showLabel: false, shares: [ "email", "twitter", "facebook", "googleplus" ] });

When I use this, the facebook screen just displays the url and nothing else, the twitter popout includes url and text.

Share for Tumblr

Hi, this plugin is great, but I need some help.
Can you show me how to implement Tumblr in this plugin. (sorry, my english is not so good).
Thank you.

PopUp not working

http://game2mena.com/oldcss/full-program

please look when load more post it's not working and i also use

<script> $(function() { var url = "http://google.com"; var text = "Some text to share"; $("#shareInPopup").jsSocials({ url: url, text: text, shareIn: "popup", showCount: "inside", shares: ["twitter", "facebook", "googleplus", "linkedin"] }); }); </script>

Title of page coming with white space and new lines as share text

I am getting this strange behaviour, If my page title as some white space and new line, its picking up those and.

  <title>      My cool title with location, New Delhi India 
     &middot; AppName</title>

Now when I am sharing it its showing it like this

  My cool title with location, New Delhi India 
     · AppName http://localhost:8000/AppName

Since title is generated from PHP backend I am not able to keep it in single line, if jssocial can clean the text a lil will be good

 92.         return $.extend({ url: this.url, text: this.text }, share, shareConfig);

I thing adding .trim() on desct or title should do it

dynamic share url support

Thanks for great plugin, I have a list of thumbnails and all have the jsSocials attached to them, but I want to make the url of individual thumbnail not the hole page url. Here is my html it has a data-url which i wanted to use as share link.

     <div class="sharing" data-url="http://localhost:8000/post/167">
          <img ... />
     </div>

     <div class="sharing" data-url="http://localhost:8000/post/147">
          <img ... />
     </div>

I have initialise plugin like this

    $(".sharing").jsSocials({
        url : $(this).data('url'),
        showLabel : false,
        shares: ["facebook", "twitter", "pinterest", "googleplus"]
    });

Please help how can I do it.

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.