Skip to content

Commit

Permalink
Share button added
Browse files Browse the repository at this point in the history
  • Loading branch information
Simounet committed Jan 8, 2024
1 parent 5de28a7 commit 9ad95ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions article_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<h1><a href="{$value->getLink()}">{$value->getTitle()}</a></h1>
<div>{if="$creator"}<span class="article-author">{$creator}</span> - {/if}<span class="article-pubdate">{function="date('H:i Y-m-d', $value->getPubdate())"}</span></div>
{function="Plugin::callHook("event_post_top_options", array(&$value))"}
<button class="share-button" data-share-title="{$value->getTitle()}" data-share-url="{$value->getLink()}">{function="_t('LEEDVIBES_SHARE')"}</button>
</header>
{$value->getContent()}
</div>
15 changes: 14 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ function _t (key, args) {
addListeners();
})();

const shareButtonAction = async (title, url) => {
const shareData = {
title,
url
};
await navigator.share(shareData);
};

$(function () {
'use strict';

Expand Down Expand Up @@ -470,13 +478,18 @@ function refreshEvents (syncCode) {
function getBubblingTarget (current, targetClass) {
const parentEl = current.parents('.' + targetClass);
return parentEl.length === 1
? parentEl : current;
? parentEl
: current;
}

function EventObject (event) {
'use strict';
this.target = $(event.target);

if (typeof event.target.dataset.shareTitle === 'string' && event.target.dataset.shareTitle.length > 0) {
shareButtonAction(event.target.dataset.shareTitle, event.target.dataset.shareUrl);
}

this.entry = $(event.currentTarget);
this.content = this.entry.find('.' + this.contentClass);

Expand Down
1 change: 1 addition & 0 deletions locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"LEEDVIBES_NO_MORE_EVENT": "The last item has already been shown.",
"LEEDVIBES_NO_NEW_EVENTS": "There is no new events since the last time.",
"LEEDVIBES_READ_ALL_CONFIRM": "Mark all events as read?",
"LEEDVIBES_SHARE": "Share",
"LEEDVIBES_SHORTCUTS_BUTTON_TITLE": "Shortcut list",
"LEEDVIBES_SHORTCUTS_ICON": "Shortcuts icon",
"LEEDVIBES_UNREAD": "unread",
Expand Down
1 change: 1 addition & 0 deletions locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"LEEDVIBES_NO_MORE_EVENT": "La dernière entrée est déjà affichée.",
"LEEDVIBES_NO_NEW_EVENTS": "Aucun nouvel article n'est disponible.",
"LEEDVIBES_READ_ALL_CONFIRM": "Marquer toutes les entrées comme lues ?",
"LEEDVIBES_SHARE": "Partager",
"LEEDVIBES_SHORTCUTS_BUTTON_TITLE": "Liste des raccourcis",
"LEEDVIBES_SHORTCUTS_ICON": "Icone des raccourcis",
"LEEDVIBES_UNREAD": "non lu",
Expand Down

0 comments on commit 9ad95ab

Please sign in to comment.