Skip to content

Commit

Permalink
Release: v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tabalinas committed Apr 4, 2016
1 parent 61e5909 commit 4dfa000
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jssocials",
"version": "1.1.0",
"version": "1.2.0",
"main": [
"dist/jssocials.js",
"dist/jssocials.css",
Expand Down
14 changes: 13 additions & 1 deletion dist/jssocials-theme-classic.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.jssocials-share-twitter .jssocials-share-link {
background: #00aced;
border: 1px solid #0099d3; }
border: 1px solid #0099d4; }
.jssocials-share-twitter .jssocials-share-link:hover {
background: #0087ba; }

Expand Down Expand Up @@ -40,6 +40,18 @@
.jssocials-share-whatsapp .jssocials-share-link:hover {
background: #1f7d1e; }

.jssocials-share-line .jssocials-share-link {
background: #25af00;
border: 1px solid #209600; }
.jssocials-share-line .jssocials-share-link:hover {
background: #1a7c00; }

.jssocials-share-stumbleupon .jssocials-share-link {
background: #eb4823;
border: 1px solid #e03a14; }
.jssocials-share-stumbleupon .jssocials-share-link:hover {
background: #c93412; }

.jssocials-share-link {
padding: .5em .6em;
border-radius: 0.3em;
Expand Down
10 changes: 10 additions & 0 deletions dist/jssocials-theme-flat.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
.jssocials-share-whatsapp .jssocials-share-link:hover {
background: #1f7d1e; }

.jssocials-share-line .jssocials-share-link {
background: #25af00; }
.jssocials-share-line .jssocials-share-link:hover {
background: #1a7c00; }

.jssocials-share-stumbleupon .jssocials-share-link {
background: #eb4823; }
.jssocials-share-stumbleupon .jssocials-share-link:hover {
background: #c93412; }

.jssocials-share-link {
padding: .5em .6em;
color: #fff;
Expand Down
18 changes: 18 additions & 0 deletions dist/jssocials-theme-minima.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@
.jssocials-share-whatsapp .jssocials-share-link:hover .jssocials-share-label, .jssocials-share-whatsapp .jssocials-share-link:focus .jssocials-share-label, .jssocials-share-whatsapp .jssocials-share-link:active .jssocials-share-label {
color: #1f7d1e; }

.jssocials-share-line .jssocials-share-link {
color: #25af00; }
.jssocials-share-line .jssocials-share-link .jssocials-share-label {
color: #25af00; }
.jssocials-share-line .jssocials-share-link:hover, .jssocials-share-line .jssocials-share-link:focus, .jssocials-share-line .jssocials-share-link:active {
color: #1a7c00; }
.jssocials-share-line .jssocials-share-link:hover .jssocials-share-label, .jssocials-share-line .jssocials-share-link:focus .jssocials-share-label, .jssocials-share-line .jssocials-share-link:active .jssocials-share-label {
color: #1a7c00; }

.jssocials-share-stumbleupon .jssocials-share-link {
color: #eb4823; }
.jssocials-share-stumbleupon .jssocials-share-link .jssocials-share-label {
color: #eb4823; }
.jssocials-share-stumbleupon .jssocials-share-link:hover, .jssocials-share-stumbleupon .jssocials-share-link:focus, .jssocials-share-stumbleupon .jssocials-share-link:active {
color: #c93412; }
.jssocials-share-stumbleupon .jssocials-share-link:hover .jssocials-share-label, .jssocials-share-stumbleupon .jssocials-share-link:focus .jssocials-share-label, .jssocials-share-stumbleupon .jssocials-share-link:active .jssocials-share-label {
color: #c93412; }

.jssocials-share-link {
-webkit-transition: color 200ms ease-in-out;
transition: color 200ms ease-in-out; }
Expand Down
104 changes: 76 additions & 28 deletions dist/jssocials.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! jssocials - v1.1.0 - 2015-12-19
/*! jssocials - v1.2.0 - 2016-04-04
* http://js-socials.com
* Copyright (c) 2015 Artem Tabalin; Licensed MIT */
* Copyright (c) 2016 Artem Tabalin; Licensed MIT */
(function(window, $, undefined) {

var JSSOCIALS = "JSSocials",
Expand All @@ -14,16 +14,15 @@
};

var IMG_SRC_REGEX = /(\.(jpeg|png|gif|bmp)$|^data:image\/(jpeg|png|gif|bmp);base64)/i;
var URL_PARAMS_REGEX = /(&?[a-zA-Z0-9]+=)\{([a-zA-Z0-9]+)\}/g;
var FIELD_SUBSTITUTION_REGEX = /\{([a-zA-Z0-9]+)\}/g;
var URL_PARAMS_REGEX = /(&?[a-zA-Z0-9]+=)?\{([a-zA-Z0-9]+)\}/g;

var MEASURES = {
"G": 1000000000,
"M": 1000000,
"K": 1000
};

var shares = [];
var shares = {};

function Socials(element, config) {
var $element = $(element);
Expand All @@ -41,6 +40,7 @@
Socials.prototype = {
url: "",
text: "",
shareIn: "blank",

showLabel: function(screenWidth) {
return (this.showCount === false) ?
Expand Down Expand Up @@ -167,23 +167,37 @@
},

_createShareLink: function(share) {
var $result = $("<a>").addClass(this.shareLinkClass)
.attr({ href: this._getShareUrl(share), target: "_blank" })
var shareStrategy = this._getShareStrategy(share);

var $result = shareStrategy({
shareUrl: this._getShareUrl(share)
});

$result.addClass(this.shareLinkClass)
.append(this._createShareLogo(share));

if(this._showLabel) {
$result.append(this._createShareLabel(share));
}

$.each(this.on || {}, function(event, handler) {
if($.isFunction(handler)) {
$result.on(event, $.proxy(handler, share));
}
});

if(this._showLabel) {
$result.append(this._createShareLabel(share));
}

return $result;
},

_getShareStrategy: function(share) {
var result = shareStrategies[share.shareIn || this.shareIn];

if(!result)
throw Error("Share strategy '" + this.shareIn + "' not found");

return result;
},

_getShareUrl: function(share) {
var shareUrl = getOrApply(share.shareUrl, share);
return this._formatShareUrl(shareUrl, share);
Expand Down Expand Up @@ -265,14 +279,9 @@
},

_formatShareUrl: function(url, share) {
url = url.replace(URL_PARAMS_REGEX, function(match, key, field) {
return url.replace(URL_PARAMS_REGEX, function(match, key, field) {
var value = share[field] || "";
return value ? (key + window.encodeURIComponent(value)) : "";
});

return url.replace(FIELD_SUBSTITUTION_REGEX, function(match, field) {
var value = share[field] || "";
return value ? window.encodeURIComponent(value) : "";
return value ? (key || "") + window.encodeURIComponent(value) : "";
});
},

Expand Down Expand Up @@ -343,7 +352,6 @@
share[key] = value;
this.refresh();
}

};


Expand Down Expand Up @@ -390,30 +398,44 @@
$.extend(component, config);
};

var shareStrategies = {
popup: function(args) {
return $("<a>").attr("href", "#")
.on("click", function() {
window.open(args.shareUrl, null, "width=600, height=400, location=0, menubar=0, resizeable=0, scrollbars=0, status=0, titlebar=0, toolbar=0");
return false;
});
},

blank: function(args) {
return $("<a>").attr({ target: "_blank", href: args.shareUrl });
},

self: function(args) {
return $("<a>").attr({ target: "_self", href: args.shareUrl });
}
};

window.jsSocials = {
Socials: Socials,
shares: shares,
shareStrategies: shareStrategies,
setDefaults: setDefaults
};

}(window, jQuery));


(function(window, $, jsSocials, undefined) {

$.extend(jsSocials.shares, {

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

email: {
label: "E-mail",
logo: "fa fa-at",
shareUrl: "mailto:?subject={text}&body={url}",
countUrl: ""
shareUrl: "mailto:{to}?subject={text}&body={url}",
countUrl: "",
shareIn: "self"
},

twitter: {
Expand Down Expand Up @@ -465,8 +487,34 @@
getCount: function(data) {
return data.count;
}
},

stumbleupon: {
label: "Share",
logo: "fa fa-stumbleupon",
shareUrl: "http://www.stumbleupon.com/submit?url={url}&title={title}",
countUrl: "https://cors-anywhere.herokuapp.com/https://www.stumbleupon.com/services/1.01/badge.getinfo?url={url}",
getCount: function(data) {
return data.result.views;
}
},

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

line: {
label: "LINE",
logo: "fa fa-comment",
shareUrl: "http://line.me/R/msg/text/?{text} {url}",
countUrl: ""
}

});

}(window, jQuery, window.jsSocials));

Loading

0 comments on commit 4dfa000

Please sign in to comment.