]> _ Git - fluidbook-html5.git/commitdiff
fix #3115 @0:20
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Oct 2019 14:23:21 +0000 (16:23 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Oct 2019 14:23:21 +0000 (16:23 +0200)
js/libs/fluidbook/fluidbook.share.js

index 4a52d6969d8475d67738845876b927899489a219..98bc4b5115965e12740ff15586c923f942662acc 100644 (file)
@@ -104,7 +104,7 @@ FluidbookShare.prototype = {
         return this.fluidbook.datas.title;
     },
 
-    getEmailSubject: function (context) {
+    getEmailSubject: function (url, context) {
         if (context === 'publication') {
             if (this.fluidbook.datas.email_title === '') {
                 return this.fluidbook.datas.title;
@@ -112,12 +112,15 @@ FluidbookShare.prototype = {
             return this.fluidbook.datas.email_title;
         } else if (context === 'product') {
             return this.fluidbook.datas.product_email_title;
+        } else if (context === 'article') {
+            return this.getSEOArticle(url).title;
         }
     },
 
     getEmailBody: function (url, context) {
         var body;
         var u = this.getShareURL(url);
+        var title = this.fluidbook.datas.title;
         if (context === 'publication') {
             if (this.fluidbook.datas.email_body === '') {
                 body = this.fluidbook.l10n.__('Veuillez cliquer sur le lien suivant pour ouvrir %title%\\n%link%');
@@ -126,9 +129,12 @@ FluidbookShare.prototype = {
             }
         } else if (context === 'product') {
             body = this.fluidbook.datas.product_email_body;
+        } else if (context === 'article') {
+            body = '%title%\\n%link%';
+            title = this.getSEOArticle(url).title;
         }
         body = body.trim();
-        body = body.replace(/\%title\%/g, this.fluidbook.datas.title);
+        body = body.replace(/\%title\%/g, title);
 
         if (body.indexOf('%link%') === -1) {
             body += "\n\n" + u;
@@ -143,6 +149,9 @@ FluidbookShare.prototype = {
     },
 
     getSEOArticle: function (title) {
+        if (title.indexOf('article:') === 0) {
+            title = title.substr(8);
+        }
         return this.fluidbook.datas.seoArticles[title];
     },
 
@@ -181,7 +190,7 @@ FluidbookShare.prototype = {
         // Generate links
         for (var shareType in shareLinks) {
             if (shareLinks.hasOwnProperty(shareType)) { // Ensure we don't get inherited properties
-                shareHTML += '<li data-level="0"><a href="#" data-service="' + shareType + '" data-url="' + url + '" data-context="'+context+'" class="share level0">';
+                shareHTML += '<li data-level="0"><a href="#" data-service="' + shareType + '" data-url="' + url + '" data-context="' + context + '" class="share level0">';
                 shareHTML += getSpriteIcon('share-' + shareType);
                 if (!hideLabels) {
                     shareHTML += ' ' + shareLinks[shareType];
@@ -201,9 +210,10 @@ FluidbookShare.prototype = {
             url = '';
         }
         if (context === undefined || context === null) {
-            context = 'publication';
+            context = url.indexOf('article:') === 0 ? 'article' : 'publication';
         }
 
+
         view = '<div class="caption">' + this.fluidbook.menu.closeButton() + '<h2>' + this.fluidbook.l10n.__('share') + '</h2></div>';
         view += '<div class="content">';
         view += this.getShareLinks(false, url, context);
@@ -256,7 +266,7 @@ FluidbookShare.prototype = {
     },
 
     sendEmail: function (url, context) {
-        window.location = 'mailto:?subject=' + encodeURIComponent(this.getEmailSubject(context)) + '&body=' + encodeURIComponent(this.getEmailBody(url, context));
+        window.location = 'mailto:?subject=' + encodeURIComponent(this.getEmailSubject(url, context)) + '&body=' + encodeURIComponent(this.getEmailBody(url, context));
         this.fluidbook.stats.track(5);
     },
     sendTwitter: function (url, context) {