]> _ Git - fluidbook-html5.git/commitdiff
done #1979 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Mar 2018 11:49:49 +0000 (12:49 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Mar 2018 11:49:49 +0000 (12:49 +0100)
js/libs/fluidbook/fluidbook.share.js

index 5023fdbd87c21b6075f033df21b784a89775fe80..c32b15812f1e655c8c3676c142bc7b81db678f18 100644 (file)
@@ -101,6 +101,33 @@ FluidbookShare.prototype = {
         return this.fluidbook.datas.title;
     },
 
+    getEmailSubject: function () {
+        if (this.fluidbook.datas.email_title == '') {
+            return this.fluidbook.datas.title;
+        }
+        return this.fluidbook.datas.email_title;
+    },
+
+    getEmailBody: function (url) {
+        var body;
+        var u = this.getShareURL(url);
+        if (this.fluidbook.datas.email_body == '') {
+            body = this.fluidbook.l10n.__('Veuillez cliquer sur le lien suivant pour ouvrir %title%\n%link%');
+        } else {
+            body = this.fluidbook.datas.email_body;
+        }
+        body = body.trim();
+        body = body.replace(/\%title\%/g, this.fluidbook.datas.title);
+
+        if (body.indexOf('%link%') === -1) {
+            body += "\n\n" + u;
+        } else {
+            body = body.replace(/\%link\%/g, u);
+        }
+
+        return body;
+    },
+
     getSEOArticle: function (title) {
         return this.fluidbook.datas.seoArticles[title];
     },
@@ -200,7 +227,7 @@ FluidbookShare.prototype = {
 
 
     sendEmail: function (url) {
-        window.location = 'mailto:?subject=' + encodeURIComponent(this.getShareTitle(url)) + '&body=' + encodeURIComponent(this.getShareTitle(url) + ' : ' + this.getShareURL(url));
+        window.location = 'mailto:?subject=' + encodeURIComponent(this.getEmailSubject()) + '&body=' + encodeURIComponent(this.getEmailBody(url));
         this.fluidbook.stats.track(5);
     },
     sendTwitter: function (url) {