]> _ Git - fluidbook-html5.git/commitdiff
wait #2786 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 13:43:39 +0000 (15:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 May 2019 13:43:39 +0000 (15:43 +0200)
js/libs/fluidbook/fluidbook.share.js

index aaeaba83e1df16cd8ac68e4524f06f5257fbcd9d..df8bdc3a361921af1a530165826f9c29c722d8de 100644 (file)
@@ -234,11 +234,20 @@ FluidbookShare.prototype = {
         this.fluidbook.stats.track(5);
     },
     sendTwitter: function (url) {
-        var tweet = this.fluidbook.datas.twitter_description.replace('%title%', this.getShareTitle(url))
-        tweet = tweet.replace('%short%', '');
-        tweet = tweet.replace('%url%', '');
+        var tweet = this.fluidbook.datas.twitter_description.replace('%title%', this.getShareTitle(url));
+        var hasUrlInTweet = tweet.indexOf('%url%') >= 0 || tweet.indexOf('%short%') >= 0;
 
-        this.fluidbook.wopen('http://twitter.com/intent/tweet?source=webclient&url=' + encodeURIComponent(this.getShareURL(url)) + '&text=' + encodeURIComponent(tweet), 'share_twitter', 'width=650,height=400');
+        url = this.getShareURL(url);
+        var escaped_url = encodeURIComponent(url);
+        tweet = tweet.replace('%short%', url);
+        tweet = tweet.replace('%url%', url);
+
+        var urlshare = '';
+        if (!hasUrlInTweet) {
+            urlshare = '&url=' + escaped_url;
+        }
+
+        this.fluidbook.wopen('http://twitter.com/intent/tweet?source=webclient' + urlshare + '&text=' + encodeURIComponent(tweet), 'share_twitter', 'width=650,height=400');
         this.fluidbook.stats.track(13);
     },
     sendFacebook: function (url) {