From fd0a6f26860d110d2807e23823f211b8466a5e88 Mon Sep 17 00:00:00 2001 From: Nicolas Beauvais Date: Tue, 19 Feb 2019 12:03:01 +0100 Subject: [PATCH] Tag 2.4.0 --- CHANGELOG.md | 6 ++++++ bower.json | 2 +- dist/vue-social-sharing.common.js | 29 +++++++++++++++++------------ dist/vue-social-sharing.js | 29 +++++++++++++++++------------ dist/vue-social-sharing.min.js | 4 ++-- src/index.js | 2 +- 6 files changed, 44 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41927c1..888e992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +# [2.4.0](https://github.com/nicolasbeauvais/vue-social-sharing/compare/2.3.4...2.4.0) (2019-02-19) +- Fix facebook hashtags +- Move rollup-plugin-json to devDependencies +- Improve readme + # [2.3.4](https://github.com/nicolasbeauvais/vue-social-sharing/compare/2.3.3...2.3.4) (2019-02-11) - Add support for facebook hashtags (PR #120) diff --git a/bower.json b/bower.json index c850890..b08c818 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vue-social-sharing", - "version": "2.3.4", + "version": "2.4.0", "homepage": "https://github.com/nicolasbeauvais/vue-social-sharing", "authors": [ "nicolasbeauvais " diff --git a/dist/vue-social-sharing.common.js b/dist/vue-social-sharing.common.js index f87e473..7c5b612 100644 --- a/dist/vue-social-sharing.common.js +++ b/dist/vue-social-sharing.common.js @@ -1,5 +1,5 @@ /*! - * vue-social-sharing v2.3.4 + * vue-social-sharing v2.4.0 * (c) 2019 nicolasbeauvais * Released under the MIT License. */ @@ -234,23 +234,27 @@ var SocialSharing = { .replace(/@title/g, encodeURIComponent(this.title)) .replace(/@description/g, encodeURIComponent(this.description)) .replace(/@quote/g, encodeURIComponent(this.quote)) - .replace(/@hashtags/g, this.encodeFacebookHashtags(network, this.hashtags)) + .replace(/@hashtags/g, this.generateHashtags(network, this.hashtags)) .replace(/@media/g, this.media) .replace(/@twitteruser/g, this.twitterUser ? '&via=' + this.twitterUser : ''); }, /** - * encode hash tag for facebook url - * @param network to check if the current network is facebbok - * @param hashtags all hashtags specified - * @return encoded hashtag [only the first one because of facebook policy] + * Encode hashtags for the specified social network. + * + * @param network Social network key + * @param hashtags All hashtags specified */ - encodeFacebookHashtags: function encodeFacebookHashtags (network, hashtags) { - return network === 'facebook' ? '%23' + hashtags : hashtags; + generateHashtags: function generateHashtags (network, hashtags) { + if (network === 'facebook') { + return '%23' + hashtags.split(',')[0]; + } + + return hashtags; }, /** * Shares URL in specified network. * - * @param string network Social network key. + * @param network Social network key. */ share: function share (network) { this.openSharer(network, this.createSharingUrl(network)); @@ -262,7 +266,7 @@ var SocialSharing = { /** * Touches network and emits click event. * - * @param string network Social network key. + * @param network Social network key. */ touch: function touch (network) { window.open(this.createSharingUrl(network), '_self'); @@ -274,7 +278,8 @@ var SocialSharing = { /** * Opens sharer popup. * - * @param string url Url to share. + * @param network Social network key + * @param url Url to share. */ openSharer: function openSharer (network, url) { var this$1 = this; @@ -360,7 +365,7 @@ var SocialSharing = { } }; -SocialSharing.version = '2.3.4'; +SocialSharing.version = '2.4.0'; SocialSharing.install = function (Vue) { Vue.component('social-sharing', SocialSharing); diff --git a/dist/vue-social-sharing.js b/dist/vue-social-sharing.js index 1aa7bb8..e7b438d 100644 --- a/dist/vue-social-sharing.js +++ b/dist/vue-social-sharing.js @@ -1,5 +1,5 @@ /*! - * vue-social-sharing v2.3.4 + * vue-social-sharing v2.4.0 * (c) 2019 nicolasbeauvais * Released under the MIT License. */ @@ -236,23 +236,27 @@ var SocialSharing = { .replace(/@title/g, encodeURIComponent(this.title)) .replace(/@description/g, encodeURIComponent(this.description)) .replace(/@quote/g, encodeURIComponent(this.quote)) - .replace(/@hashtags/g, this.encodeFacebookHashtags(network, this.hashtags)) + .replace(/@hashtags/g, this.generateHashtags(network, this.hashtags)) .replace(/@media/g, this.media) .replace(/@twitteruser/g, this.twitterUser ? '&via=' + this.twitterUser : ''); }, /** - * encode hash tag for facebook url - * @param network to check if the current network is facebbok - * @param hashtags all hashtags specified - * @return encoded hashtag [only the first one because of facebook policy] + * Encode hashtags for the specified social network. + * + * @param network Social network key + * @param hashtags All hashtags specified */ - encodeFacebookHashtags: function encodeFacebookHashtags (network, hashtags) { - return network === 'facebook' ? '%23' + hashtags : hashtags; + generateHashtags: function generateHashtags (network, hashtags) { + if (network === 'facebook') { + return '%23' + hashtags.split(',')[0]; + } + + return hashtags; }, /** * Shares URL in specified network. * - * @param string network Social network key. + * @param network Social network key. */ share: function share (network) { this.openSharer(network, this.createSharingUrl(network)); @@ -264,7 +268,7 @@ var SocialSharing = { /** * Touches network and emits click event. * - * @param string network Social network key. + * @param network Social network key. */ touch: function touch (network) { window.open(this.createSharingUrl(network), '_self'); @@ -276,7 +280,8 @@ var SocialSharing = { /** * Opens sharer popup. * - * @param string url Url to share. + * @param network Social network key + * @param url Url to share. */ openSharer: function openSharer (network, url) { var this$1 = this; @@ -362,7 +367,7 @@ var SocialSharing = { } }; -SocialSharing.version = '2.3.4'; +SocialSharing.version = '2.4.0'; SocialSharing.install = function (Vue) { Vue.component('social-sharing', SocialSharing); diff --git a/dist/vue-social-sharing.min.js b/dist/vue-social-sharing.min.js index bfe1dd5..f8a6f94 100644 --- a/dist/vue-social-sharing.min.js +++ b/dist/vue-social-sharing.min.js @@ -1,6 +1,6 @@ /*! - * vue-social-sharing v2.3.4 + * vue-social-sharing v2.4.0 * (c) 2019 nicolasbeauvais * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.VueSocialSharing=e(t.Vue)}(this,function(t){"use strict";t="default"in t?t.default:t;var e={functional:!0,props:{network:{type:String,default:""}},render:function(t,e){var r=e.parent._data.baseNetworks[e.props.network];return r?t(e.parent.networkTag,{staticClass:e.data.staticClass||null,staticStyle:e.data.staticStyle||null,class:e.data.class||null,style:e.data.style||null,attrs:{id:e.data.attrs.id||null,"data-link":"popup"===r.type?"#share-"+e.props.network:e.parent.createSharingUrl(e.props.network),"data-action":"popup"===r.type?null:r.action},on:{click:"popup"===r.type?function(){e.parent.share(e.props.network)}:function(){e.parent.touch(e.props.network)}}},e.children):console.warn("Network "+e.props.network+" does not exist")}},r={sharer:"mailto:?subject=@title&body=@url%0D%0A%0D%0A@description",type:"direct"},i={sharer:"https://www.facebook.com/sharer/sharer.php?u=@url&title=@title&description=@description"e=@quote&hashtag=@hashtags",type:"popup"},o={sharer:"https://plus.google.com/share?url=@url",type:"popup"},p={sharer:"http://line.me/R/msg/text/?@description%0D%0A@url",type:"popup"},s={sharer:"https://www.linkedin.com/shareArticle?mini=true&url=@url&title=@title&summary=@description",type:"popup"},n={sharer:"https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=@url&st.comments=@description",type:"popup"},a={sharer:"https://pinterest.com/pin/create/button/?url=@url&media=@media&description=@title",type:"popup"},l={sharer:"https://www.reddit.com/submit?url=@url&title=@title",type:"popup"},u={sharer:"https://web.skype.com/share?url=@description%0D%0A@url",type:"popup"},h={sharer:"https://t.me/share/url?url=@url&text=@description",type:"popup"},c={sharer:"https://twitter.com/intent/tweet?text=@title&url=@url&hashtags=@hashtags@twitteruser",type:"popup"},d={sharer:"viber://forward?text=@url @description",type:"direct"},w={sharer:"https://vk.com/share.php?url=@url&title=@title&description=@description&image=@media&noparse=true",type:"popup"},m={sharer:"http://service.weibo.com/share/share.php?url=@url&title=@title",type:"popup"},f={sharer:"whatsapp://send?text=@description%0D%0A@url",type:"direct",action:"share/whatsapp/share"},g={sharer:"sms:?body=@url%20@description",type:"direct"},y={email:r,facebook:i,googleplus:o,line:p,linkedin:s,odnoklassniki:n,pinterest:a,reddit:l,skype:u,telegram:h,twitter:c,viber:d,vk:w,weibo:m,whatsapp:f,sms:g},b="undefined"!=typeof window,k=b?window:null,v={props:{url:{type:String,default:b?window.location.href:""},title:{type:String,default:""},description:{type:String,default:""},quote:{type:String,default:""},hashtags:{type:String,default:""},twitterUser:{type:String,default:""},withCounts:{type:[String,Boolean],default:!1},googleKey:{type:String,default:void 0},media:{type:String,default:""},networkTag:{type:String,default:"span"},networks:{type:Object,default:function(){return{}}}},data:function(){return{baseNetworks:y,popup:{status:!1,resizable:!0,toolbar:!1,menubar:!1,scrollbars:!1,location:!1,directories:!1,width:626,height:436,top:0,left:0,window:void 0,interval:null}}},methods:{createSharingUrl:function(t){return this.baseNetworks[t].sharer.replace(/@url/g,encodeURIComponent(this.url)).replace(/@title/g,encodeURIComponent(this.title)).replace(/@description/g,encodeURIComponent(this.description)).replace(/@quote/g,encodeURIComponent(this.quote)).replace(/@hashtags/g,this.encodeFacebookHashtags(t,this.hashtags)).replace(/@media/g,this.media).replace(/@twitteruser/g,this.twitterUser?"&via="+this.twitterUser:"")},encodeFacebookHashtags:function(t,e){return"facebook"===t?"%23"+e:e},share:function(t){this.openSharer(t,this.createSharingUrl(t)),this.$root.$emit("social_shares_open",t,this.url),this.$emit("open",t,this.url)},touch:function(t){window.open(this.createSharingUrl(t),"_self"),this.$root.$emit("social_shares_open",t,this.url),this.$emit("open",t,this.url)},openSharer:function(t,e){var r=this;this.popup.window&&this.popup.interval&&(clearInterval(this.popup.interval),this.popup.window.close(),this.$root.$emit("social_shares_change",t,this.url),this.$emit("change",t,this.url)),this.popup.window=window.open(e,"sharer","status="+(this.popup.status?"yes":"no")+",height="+this.popup.height+",width="+this.popup.width+",resizable="+(this.popup.resizable?"yes":"no")+",left="+this.popup.left+",top="+this.popup.top+",screenX="+this.popup.left+",screenY="+this.popup.top+",toolbar="+(this.popup.toolbar?"yes":"no")+",menubar="+(this.popup.menubar?"yes":"no")+",scrollbars="+(this.popup.scrollbars?"yes":"no")+",location="+(this.popup.location?"yes":"no")+",directories="+(this.popup.directories?"yes":"no")),this.popup.window.focus(),this.popup.interval=setInterval(function(){r.popup.window.closed&&(clearInterval(r.popup.interval),r.popup.window=void 0,r.$root.$emit("social_shares_close",t,r.url),r.$emit("close",t,r.url))},500)}},beforeMount:function(){this.baseNetworks=t.util.extend(this.baseNetworks,this.networks)},mounted:function(){if(b){var t=void 0!==k.screenLeft?k.screenLeft:screen.left,e=void 0!==k.screenTop?k.screenTop:screen.top,r=k.innerWidth?k.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=k.innerHeight?k.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;this.popup.left=r/2-this.popup.width/2+t,this.popup.top=i/2-this.popup.height/2+e}},components:{network:e}};return v.version="2.3.4",v.install=function(t){t.component("social-sharing",v)},"undefined"!=typeof window&&(window.SocialSharing=v),v}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):t.VueSocialSharing=e(t.Vue)}(this,function(t){"use strict";t="default"in t?t.default:t;var e={functional:!0,props:{network:{type:String,default:""}},render:function(t,e){var r=e.parent._data.baseNetworks[e.props.network];return r?t(e.parent.networkTag,{staticClass:e.data.staticClass||null,staticStyle:e.data.staticStyle||null,class:e.data.class||null,style:e.data.style||null,attrs:{id:e.data.attrs.id||null,"data-link":"popup"===r.type?"#share-"+e.props.network:e.parent.createSharingUrl(e.props.network),"data-action":"popup"===r.type?null:r.action},on:{click:"popup"===r.type?function(){e.parent.share(e.props.network)}:function(){e.parent.touch(e.props.network)}}},e.children):console.warn("Network "+e.props.network+" does not exist")}},r={sharer:"mailto:?subject=@title&body=@url%0D%0A%0D%0A@description",type:"direct"},i={sharer:"https://www.facebook.com/sharer/sharer.php?u=@url&title=@title&description=@description"e=@quote&hashtag=@hashtags",type:"popup"},o={sharer:"https://plus.google.com/share?url=@url",type:"popup"},p={sharer:"http://line.me/R/msg/text/?@description%0D%0A@url",type:"popup"},s={sharer:"https://www.linkedin.com/shareArticle?mini=true&url=@url&title=@title&summary=@description",type:"popup"},n={sharer:"https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=@url&st.comments=@description",type:"popup"},a={sharer:"https://pinterest.com/pin/create/button/?url=@url&media=@media&description=@title",type:"popup"},l={sharer:"https://www.reddit.com/submit?url=@url&title=@title",type:"popup"},u={sharer:"https://web.skype.com/share?url=@description%0D%0A@url",type:"popup"},h={sharer:"https://t.me/share/url?url=@url&text=@description",type:"popup"},c={sharer:"https://twitter.com/intent/tweet?text=@title&url=@url&hashtags=@hashtags@twitteruser",type:"popup"},d={sharer:"viber://forward?text=@url @description",type:"direct"},w={sharer:"https://vk.com/share.php?url=@url&title=@title&description=@description&image=@media&noparse=true",type:"popup"},m={sharer:"http://service.weibo.com/share/share.php?url=@url&title=@title",type:"popup"},f={sharer:"whatsapp://send?text=@description%0D%0A@url",type:"direct",action:"share/whatsapp/share"},g={sharer:"sms:?body=@url%20@description",type:"direct"},y={email:r,facebook:i,googleplus:o,line:p,linkedin:s,odnoklassniki:n,pinterest:a,reddit:l,skype:u,telegram:h,twitter:c,viber:d,vk:w,weibo:m,whatsapp:f,sms:g},b="undefined"!=typeof window,k=b?window:null,v={props:{url:{type:String,default:b?window.location.href:""},title:{type:String,default:""},description:{type:String,default:""},quote:{type:String,default:""},hashtags:{type:String,default:""},twitterUser:{type:String,default:""},withCounts:{type:[String,Boolean],default:!1},googleKey:{type:String,default:void 0},media:{type:String,default:""},networkTag:{type:String,default:"span"},networks:{type:Object,default:function(){return{}}}},data:function(){return{baseNetworks:y,popup:{status:!1,resizable:!0,toolbar:!1,menubar:!1,scrollbars:!1,location:!1,directories:!1,width:626,height:436,top:0,left:0,window:void 0,interval:null}}},methods:{createSharingUrl:function(t){return this.baseNetworks[t].sharer.replace(/@url/g,encodeURIComponent(this.url)).replace(/@title/g,encodeURIComponent(this.title)).replace(/@description/g,encodeURIComponent(this.description)).replace(/@quote/g,encodeURIComponent(this.quote)).replace(/@hashtags/g,this.generateHashtags(t,this.hashtags)).replace(/@media/g,this.media).replace(/@twitteruser/g,this.twitterUser?"&via="+this.twitterUser:"")},generateHashtags:function(t,e){return"facebook"===t?"%23"+e.split(",")[0]:e},share:function(t){this.openSharer(t,this.createSharingUrl(t)),this.$root.$emit("social_shares_open",t,this.url),this.$emit("open",t,this.url)},touch:function(t){window.open(this.createSharingUrl(t),"_self"),this.$root.$emit("social_shares_open",t,this.url),this.$emit("open",t,this.url)},openSharer:function(t,e){var r=this;this.popup.window&&this.popup.interval&&(clearInterval(this.popup.interval),this.popup.window.close(),this.$root.$emit("social_shares_change",t,this.url),this.$emit("change",t,this.url)),this.popup.window=window.open(e,"sharer","status="+(this.popup.status?"yes":"no")+",height="+this.popup.height+",width="+this.popup.width+",resizable="+(this.popup.resizable?"yes":"no")+",left="+this.popup.left+",top="+this.popup.top+",screenX="+this.popup.left+",screenY="+this.popup.top+",toolbar="+(this.popup.toolbar?"yes":"no")+",menubar="+(this.popup.menubar?"yes":"no")+",scrollbars="+(this.popup.scrollbars?"yes":"no")+",location="+(this.popup.location?"yes":"no")+",directories="+(this.popup.directories?"yes":"no")),this.popup.window.focus(),this.popup.interval=setInterval(function(){r.popup.window.closed&&(clearInterval(r.popup.interval),r.popup.window=void 0,r.$root.$emit("social_shares_close",t,r.url),r.$emit("close",t,r.url))},500)}},beforeMount:function(){this.baseNetworks=t.util.extend(this.baseNetworks,this.networks)},mounted:function(){if(b){var t=void 0!==k.screenLeft?k.screenLeft:screen.left,e=void 0!==k.screenTop?k.screenTop:screen.top,r=k.innerWidth?k.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=k.innerHeight?k.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;this.popup.left=r/2-this.popup.width/2+t,this.popup.top=i/2-this.popup.height/2+e}},components:{network:e}};return v.version="2.4.0",v.install=function(t){t.component("social-sharing",v)},"undefined"!=typeof window&&(window.SocialSharing=v),v}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 31153a8..997691c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ import SocialSharing from './social-sharing'; -SocialSharing.version = '2.3.4'; +SocialSharing.version = '2.4.0'; SocialSharing.install = (Vue) => { Vue.component('social-sharing', SocialSharing);