Skip to content

Commit ab4e4c3

Browse files
authored
Merge pull request #7 from wcoder/feature/reddit
Add Reddit closed #3
2 parents e38998b + a3c0229 commit ab4e4c3

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Simple social buttons for your site.
1111
* Twitter
1212
* Telegram
1313
* Pocket
14+
* Reddit
1415
* EMail
1516

1617
## Browser support

dist/share-buttons.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<a class="btn-twitter" data-id="tw"><i class="fab fa-twitter"></i> Twitter</a>
3434
<a class="btn-telegram" data-id="tg"><i class="fab fa-telegram"></i> Telegram</a>
3535
<a class="btn-pocket" data-id="pk"><i class="fab fa-get-pocket"></i> Pocket</a>
36+
<a class="btn-reddit" data-id="re"><i class="fab fa-reddit"></i> Reddit</a>
3637
<a class="btn-mail" data-id="mail"><i class="fas fa-at"></i> EMail</a>
3738
</div>
3839

src/share-buttons.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
TW_LINK_FORMAT = 'https://twitter.com/intent/tweet?url={0}&text={1}',
1616
TG_LINK_FORMAT = 'https://t.me/share/url?url={0}&text={1}',
1717
POCKET_LINK_FORMAT = 'https://getpocket.com/edit?url={0}&title={1}',
18+
RE_LINK_FORMAT = 'https://reddit.com/submit/?url={0}',
1819
MAIL_LINK_FORMAT = 'mailto:?Subject={0}{1}&body={2}{3}',
1920
FB_CLASS_NAME = 'fb',
2021
VK_CLASS_NAME = 'vk',
2122
TW_CLASS_NAME = 'tw',
2223
TG_CLASS_NAME = 'tg',
2324
PK_CLASS_NAME = 'pk',
25+
RE_CLASS_NAME = 're',
2426
MAIL_CLASS_NAME = 'mail',
2527

2628
// from https://wcoder.github.io/notes/string-format-for-string-formating-in-javascript
@@ -165,6 +167,12 @@
165167
titleDef);
166168
break;
167169

170+
case RE_CLASS_NAME:
171+
this.popupCenter(
172+
stringFormat(RE_LINK_FORMAT, [url]),
173+
titleDef);
174+
break;
175+
168176
case MAIL_CLASS_NAME:
169177
if (title.length > 0 && desc.length > 0) {
170178
text = mergeForTitle([title, desc]);

0 commit comments

Comments
 (0)