This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/sharing-sources.js.es6
2015-11-10 13:09:05 -05:00

49 lines
1.4 KiB
JavaScript

import Sharing from 'discourse/lib/sharing';
export default {
name: 'sharing-sources',
initialize: function() {
Sharing.addSource({
id: 'twitter',
faIcon: 'fa-twitter-square',
generateUrl: function(link, title) {
return "http://twitter.com/intent/tweet?url=" + encodeURIComponent(link) + "&text=" + encodeURIComponent(title);
},
shouldOpenInPopup: true,
title: I18n.t('share.twitter'),
popupHeight: 265
});
Sharing.addSource({
id: 'facebook',
faIcon: 'fa-facebook-square',
title: I18n.t('share.facebook'),
generateUrl: function(link, title) {
return "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(link) + '&t=' + encodeURIComponent(title);
},
shouldOpenInPopup: true
});
Sharing.addSource({
id: 'google+',
faIcon: 'fa-google-plus-square',
title: I18n.t('share.google+'),
generateUrl: function(link) {
return "https://plus.google.com/share?url=" + encodeURIComponent(link);
},
shouldOpenInPopup: true,
popupHeight: 600
});
Sharing.addSource({
id: 'email',
faIcon: 'fa-envelope-square',
title: I18n.t('share.email'),
generateUrl: function(link, title) {
return "mailto:?to=&subject=" + encodeURIComponent('[' + Discourse.SiteSettings.title + '] ' + title) + "&body=" + encodeURIComponent(link);
}
});
}
};