]> _ Git - fluidbook-html5.git/commitdiff
wip #3358 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Jan 2020 09:11:59 +0000 (10:11 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Jan 2020 09:11:59 +0000 (10:11 +0100)
js/libs/fluidbook/fluidbook.share.js

index 26abcd5b3825f25a3593a67406b543675254a3bc..ef17b9da7087903524fe8351cc55a8b74ee90326 100644 (file)
@@ -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);