Add email as a sharing option

This commit is contained in:
Neil Lalonde 2013-04-12 18:06:36 -04:00
parent 4413d2a92b
commit 48d5cb02c2
4 changed files with 20 additions and 4 deletions

View File

@ -19,13 +19,17 @@ Discourse.ShareLink = Discourse.Model.extend({
iconClass: function() { iconClass: function() {
return Discourse.ShareLink.iconClasses[this.get('target')]; return Discourse.ShareLink.iconClasses[this.get('target')];
}.property('target'),
openInPopup: function() {
return( this.get('target') != 'email' );
}.property('target') }.property('target')
}); });
Discourse.ShareLink.reopenClass({ Discourse.ShareLink.reopenClass({
supportedTargets: ['twitter', 'facebook', 'google+'], supportedTargets: ['twitter', 'facebook', 'google+', 'email'],
urlFor: function(target,link,title) { urlFor: function(target,link,title) {
switch(target) { switch(target) {
@ -35,6 +39,8 @@ Discourse.ShareLink.reopenClass({
return this.facebookUrl(link,title); return this.facebookUrl(link,title);
case 'google+': case 'google+':
return this.googlePlusUrl(link); return this.googlePlusUrl(link);
case 'email':
return this.emailUrl(link,title);
} }
}, },
@ -50,10 +56,15 @@ Discourse.ShareLink.reopenClass({
return ("https://plus.google.com/share?url=" + encodeURIComponent(link)); return ("https://plus.google.com/share?url=" + encodeURIComponent(link));
}, },
emailUrl: function(link, title) {
return ("mailto:?to=&subject=" + encodeURIComponent('[' + Discourse.SiteSettings.title + '] ' + title) + "&body=" + encodeURIComponent(link));
},
iconClasses: { iconClasses: {
twitter: 'icon-twitter', twitter: 'icon-twitter',
facebook: 'icon-facebook-sign', facebook: 'icon-facebook-sign',
'google+': 'icon-google-plus' 'google+': 'icon-google-plus',
email: 'icon-envelope-alt'
}, },
popupHeights: { popupHeights: {

View File

@ -1 +1,5 @@
{{#if openInPopup}}
<a href="#" {{action sharePopup target href}} {{bindAttr title="title"}}><i {{bindAttr class=":icon iconClass"}}></i></a> <a href="#" {{action sharePopup target href}} {{bindAttr title="title"}}><i {{bindAttr class=":icon iconClass"}}></i></a>
{{else}}
<a {{bindAttr href="href"}} {{bindAttr title="title"}} target="_blank"><i {{bindAttr class=":icon iconClass"}}></i></a>
{{/if}}

View File

@ -19,7 +19,7 @@ class SiteSetting < ActiveRecord::Base
client_setting(:traditional_markdown_linebreaks, false) client_setting(:traditional_markdown_linebreaks, false)
client_setting(:top_menu, 'latest|hot|new|unread|favorited|categories') client_setting(:top_menu, 'latest|hot|new|unread|favorited|categories')
client_setting(:post_menu, 'like|edit|flag|delete|share|bookmark|reply') client_setting(:post_menu, 'like|edit|flag|delete|share|bookmark|reply')
client_setting(:share_links, 'twitter|facebook|google+') client_setting(:share_links, 'twitter|facebook|google+|email')
client_setting(:track_external_right_clicks, false) client_setting(:track_external_right_clicks, false)
client_setting(:must_approve_users, false) client_setting(:must_approve_users, false)
client_setting(:ga_tracking_code, "") client_setting(:ga_tracking_code, "")

View File

@ -11,6 +11,7 @@ en:
twitter: 'share this link on Twitter' twitter: 'share this link on Twitter'
facebook: 'share this link on Facebook' facebook: 'share this link on Facebook'
google+: 'share this link on Google+' google+: 'share this link on Google+'
email: 'send this link in an email'
edit: 'edit the title and category of this topic' edit: 'edit the title and category of this topic'
not_implemented: "That feature hasn't been implemented yet, sorry!" not_implemented: "That feature hasn't been implemented yet, sorry!"