From 77520f759aaffc4a8ba7fdadbfe54b5f192db738 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 21 Jan 2020 10:11:59 +0100 Subject: [PATCH] wip #3358 @0.25 --- js/libs/fluidbook/fluidbook.share.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.share.js b/js/libs/fluidbook/fluidbook.share.js index 26abcd5b..ef17b9da 100644 --- a/js/libs/fluidbook/fluidbook.share.js +++ b/js/libs/fluidbook/fluidbook.share.js @@ -179,6 +179,9 @@ FluidbookShare.prototype = { if (this.fluidbook.datas.twitter) { shareLinks['twitter'] = 'Twitter'; } + if (this.fluidbook.datas.whatsapp) { + shareLinks['whatsapp'] = 'WhatsApp'; + } if (this.fluidbook.datas.googleplus) { shareLinks['googleplus'] = 'Google Plus'; } @@ -286,7 +289,8 @@ FluidbookShare.prototype = { window.location = mailto; this.fluidbook.stats.track(5); }, - sendTwitter: function (url, context) { + + _getShortShare: function (url, context) { var tweet = this.getTweetContent(url, context); var hasUrlInTweet = tweet.indexOf('%url%') >= 0 || tweet.indexOf('%short%') >= 0; @@ -299,10 +303,20 @@ FluidbookShare.prototype = { if (!hasUrlInTweet) { urlshare = '&url=' + escaped_url; } + return {url: urlshare, content: tweet}; + }, - this.fluidbook.wopen('http://twitter.com/intent/tweet?source=webclient' + urlshare + '&text=' + encodeURIComponent(tweet), 'share_twitter', 'width=650,height=400'); + sendTwitter: function (url, context) { + var data = this._getShortShare(url, context); + + this.fluidbook.wopen('https://twitter.com/intent/tweet?source=webclient' + data.url + '&text=' + encodeURIComponent(data.content), 'share_twitter', 'width=650,height=400'); this.fluidbook.stats.track(13); }, + sendWhatsapp: function (url, context) { + var data = this._getShortShare(url, context); + this.fluidbook.wopen('https://api.whatsapp.com/send?text=' + encodeURIComponent(data.content), 'share_whatsapp', 'width=600,height=600'); + this.fluidbook.stats.track(12); + }, sendFacebook: function (url, context) { this.fluidbook.wopen('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(this.getShareURL(url)), 'share_facebook', 'width=650,height=400'); this.fluidbook.stats.track(12); -- 2.39.5