[frio] Add a conditional browser share button

This commit is contained in:
Hypolite Petovan 2022-01-09 10:15:04 -05:00
parent 18b32b68aa
commit f2af985350
4 changed files with 18 additions and 2 deletions

View File

@ -135,8 +135,6 @@ class Post
*/
public function getTemplateData(array $conv_responses, string $formSecurityToken, $thread_level = 1)
{
$a = DI::app();
$item = $this->getData();
$edited = false;
// If the time between "created" and "edited" differs we add
@ -480,6 +478,7 @@ class Post
'owner_photo' => DI::baseUrl()->remove(Contact::getAvatarUrlForUrl($item['owner-link'], $item['uid'], Proxy::SIZE_THUMB)),
'owner_name' => $this->getOwnerName(),
'plink' => Item::getPlink($item),
'browsershare' => DI::l10n()->t('Share'),
'edpost' => $edpost,
'ispinned' => $ispinned,
'pin' => $pin,

View File

@ -459,6 +459,10 @@ $(document).ready(function () {
$pokeSubmit.button("reset");
});
});
if (!navigator.canShare || !navigator.canShare()) {
$('.button-browser-share').hide();
}
});
function openClose(theID) {

View File

@ -177,6 +177,10 @@
{{/if}}
{{/if}}
{{if !$item.lock && !$item.connector}}
<span role="presentation" class="separator button-browser-share"></span>
<button type="button" class="btn-link button-browser-share" onclick="navigator.share({url: '{{$item.plink.orig}}'})"><i class="fa fa-share-alt"></i> {{$item.browsershare}}</button>
{{/if}}
{{* Put additional actions in a dropdown menu *}}
{{if $item.menu && ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || $item.drop.dropping)}}

View File

@ -330,6 +330,11 @@ as the value of $top_child_total (this is done at the end of this file)
{{/if}}
{{/if}}
{{if !$item.lock && !$item.connector}}
<span role="presentation" class="separator button-browser-share"></span>
<button type="button" class="btn-link button-browser-share" onclick="navigator.share({url: '{{$item.plink.orig}}'})"><i class="fa fa-share-alt"></i> {{$item.browsershare}}</button>
{{/if}}
{{* Put additional actions in a dropdown menu *}}
{{if $item.menu && ($item.edpost || $item.tagger || $item.filer || $item.pin || $item.star || $item.follow_thread || $item.ignore || $item.drop.dropping)}}
<span role="presentation" class="separator"></span>
@ -481,6 +486,10 @@ as the value of $top_child_total (this is done at the end of this file)
</div>
{{/if}}
{{if !$item.lock && !$item.connector}}
<button type="button" class="btn btn-sm button-browser-share" onclick="navigator.share({url: '{{$item.plink.orig}}'})" title="{{$item.browsershare}}"><i class="fa fa-share-alt"></i></button>
{{/if}}
{{* Put additional actions in a dropdown menu *}}
<div class="btn-group" role="group">
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />