Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Reddit #3
  • Loading branch information
wcoder committed Jun 12, 2018
commit a3c022929effee24efe6c5881ae35734f4fa8540
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Simple social buttons for your site.
* Twitter
* Telegram
* Pocket
* Reddit
* EMail

## Browser support
Expand Down
2 changes: 1 addition & 1 deletion dist/share-buttons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<a class="btn-twitter" data-id="tw"><i class="fab fa-twitter"></i> Twitter</a>
<a class="btn-telegram" data-id="tg"><i class="fab fa-telegram"></i> Telegram</a>
<a class="btn-pocket" data-id="pk"><i class="fab fa-get-pocket"></i> Pocket</a>
<a class="btn-reddit" data-id="re"><i class="fab fa-reddit"></i> Reddit</a>
<a class="btn-mail" data-id="mail"><i class="fas fa-at"></i> EMail</a>
</div>

Expand Down
8 changes: 8 additions & 0 deletions src/share-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
TW_LINK_FORMAT = 'https://twitter.com/intent/tweet?url={0}&text={1}',
TG_LINK_FORMAT = 'https://t.me/share/url?url={0}&text={1}',
POCKET_LINK_FORMAT = 'https://getpocket.com/edit?url={0}&title={1}',
RE_LINK_FORMAT = 'https://reddit.com/submit/?url={0}',
MAIL_LINK_FORMAT = 'mailto:?Subject={0}{1}&body={2}{3}',
FB_CLASS_NAME = 'fb',
VK_CLASS_NAME = 'vk',
TW_CLASS_NAME = 'tw',
TG_CLASS_NAME = 'tg',
PK_CLASS_NAME = 'pk',
RE_CLASS_NAME = 're',
MAIL_CLASS_NAME = 'mail',

// from https://wcoder.github.io/notes/string-format-for-string-formating-in-javascript
Expand Down Expand Up @@ -165,6 +167,12 @@
titleDef);
break;

case RE_CLASS_NAME:
this.popupCenter(
stringFormat(RE_LINK_FORMAT, [url]),
titleDef);
break;

case MAIL_CLASS_NAME:
if (title.length > 0 && desc.length > 0) {
text = mergeForTitle([title, desc]);
Expand Down