Skip to content

Commit

Permalink
Share: Added ability to auto-generate additional links (fixes #3866)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjackson28 committed Dec 9, 2013
1 parent 84ad38b commit 42dbe4d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
8 changes: 2 additions & 6 deletions src/plugins/share/share-en.hbs
Expand Up @@ -12,9 +12,7 @@
<div class="wb-share"></div>
<p class="text-right">
<strong>Add a second link:</strong>
<a href="#shr-pg" aria-controls="shr-pg" class="shr-opn overlay-lnk" role="button">
<span class="glyphicon glyphicon-share"></span> Share this page
</a>
<div class="wb-share link-only text-right"></div>
</p>

<details>
Expand All @@ -23,9 +21,7 @@
<code>&lt;div class="wb-share"&gt;&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;Add a second link:&lt;/strong&gt;
&lt;a href="#shr-pg" aria-controls="shr-pg" class="shr-opn overlay-lnk" role="button"&gt;
&lt;span class="glyphicon glyphicon-share"&gt;&lt;/span&gt; Share this page
&lt;/a&gt;
&lt;div class="wb-share link-only text-right"&gt;&lt;/div&gt;
&lt;/p&gt;</code>
</pre>
</details>
8 changes: 2 additions & 6 deletions src/plugins/share/share-fr.hbs
Expand Up @@ -12,9 +12,7 @@
<div class="wb-share"></div>
<p class="text-right">
<strong>Ajouter un deuxième lien&#160;:</strong>
<a href="#shr-pg" aria-controls="shr-pg" class="shr-opn overlay-lnk" role="button">
<span class="glyphicon glyphicon-share"></span> Partager cette page
</a>
<div class="wb-share link-only text-right"></div>
</p>

<details>
Expand All @@ -23,9 +21,7 @@
<code>&lt;div class="wb-share"&gt;&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;Ajouter un deuxième lien&amp;#160;:&lt;/strong&gt;
&lt;a href="#shr-pg" aria-controls="shr-pg" class="shr-opn overlay-lnk" role="button"&gt;
&lt;span class="glyphicon glyphicon-share"&gt;&lt;/span&gt; Partager cette page
&lt;/a&gt;
&lt;div class="wb-share link-only text-right"&gt;&lt;/div&gt;
&lt;/p&gt;</code>
</pre>
</details>
33 changes: 18 additions & 15 deletions src/plugins/share/share.js
Expand Up @@ -150,25 +150,28 @@ var pluginName = "wb-share",
};
}

panel = "<section id='shr-pg' class='shr-pg wb-overlay modal-content overlay-def wb-panel-r" +
"'><header class='modal-header'><" + heading + " class='modal-title'>" +
i18nText.shareText + "</" + heading + "></header><ul class='colcount-xs-2'>";

for ( site in sites ) {
siteProperties = sites[ site ];
url = siteProperties.url
.replace( /\{u\}/, pageHref )
.replace( /\{t\}/, pageTitle )
.replace( /\{i\}/, pageImage )
.replace( /\{d\}/, pageDescription );
panel += "<li><a href='" + url + "' class='" + shareLink + " " + site + " btn btn-default' target='_blank'>" + siteProperties.name + "</a></li>";
// Don't create the panel for the second link (class="link-only")
if ( elm.className.indexOf( "link-only" ) === -1 ) {
panel = "<section id='shr-pg' class='shr-pg wb-overlay modal-content overlay-def wb-panel-r" +
"'><header class='modal-header'><" + heading + " class='modal-title'>" +
i18nText.shareText + "</" + heading + "></header><ul class='colcount-xs-2'>";

for ( site in sites ) {
siteProperties = sites[ site ];
url = siteProperties.url
.replace( /\{u\}/, pageHref )
.replace( /\{t\}/, pageTitle )
.replace( /\{i\}/, pageImage )
.replace( /\{d\}/, pageDescription );
panel += "<li><a href='" + url + "' class='" + shareLink + " " + site + " btn btn-default' target='_blank'>" + siteProperties.name + "</a></li>";
}

panel += "</ul><div class='clearfix'></div><p class='col-sm-12'>" + i18nText.disclaimer + "</p></section>";
}

panel += "</ul><div class='clearfix'></div><p class='col-sm-12'>" + i18nText.disclaimer + "</p></section>";
link = "<a href='#shr-pg' aria-controls='shr-pg' class='shr-opn overlay-lnk'><span class='glyphicon glyphicon-share'></span> " +
i18nText.shareText + "</a>";

$share = $( panel + link );
$share = $( ( panel ? panel : "" ) + link );

$elm.append( $share );

Expand Down

0 comments on commit 42dbe4d

Please sign in to comment.