88 lines
4.6 KiB
PHP
88 lines
4.6 KiB
PHP
@php $circle = isset($circle) ? '-circle' : ''; $hash = uniqid('', true); @endphp
|
|
@switch($socialNetwork)
|
|
@case('facebook')
|
|
<a data-share="facebook-{{ $hash }}" role="button" target="_blank" rel="me"
|
|
href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode(str_replace("http://", "https://", request()->fullurl())) }}&t={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur Facebook') }}">
|
|
<img class="mx-2 my-1" src="{{ asset("build/assets/images/facebook{$circle}.png") }}" alt="Facebook">
|
|
</a>
|
|
@break
|
|
@case('twitter')
|
|
<a data-share="twitter-{{ $hash }}" role="button" target="_blank" rel="me"
|
|
href="https://twitter.com/share?url={{ urlencode(str_replace("http://", "https://", request()->fullurl())) }}&text={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur Twitter') }}">
|
|
<img class="mx-2 my-1" src="{{ asset("build/assets/images/twitter{$circle}.png") }}" alt="Twitter">
|
|
</a>
|
|
@break
|
|
@case('linkedin')
|
|
<a data-share="linkedin-{{ $hash }}" role="button" target="_blank" rel="me"
|
|
href="http://www.linkedin.com/shareArticle?mini=true&url={{ urlencode(str_replace("http://", "https://", request()->fullurl())) }}&title={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur LinkedIn') }}">
|
|
<img class="mx-2 my-1" src="{{ asset("build/assets/images/linkedin{$circle}.png") }}" alt="Linkedin">
|
|
</a>
|
|
@break
|
|
@case('mail')
|
|
<a data-share="mail-{{ $hash }}" role="button" target="_blank"
|
|
href="mailto:?subject={{ $subject }}&body={{ $title }}"
|
|
title="{{ __('Partager par E-mail') }}">
|
|
<svg class="mx-2 my-1" xmlns="http://www.w3.org/2000/svg" width="19.368" height="12.959" viewBox="0 0 19.368 12.959">
|
|
<g id="Groupe_297" data-name="Groupe 297" transform="translate(-1200.423 -609.899)">
|
|
<g id="Rectangle_115" class="mail-letter" data-name="Rectangle 115" transform="translate(1200.423 609.899)" fill="none" stroke-linejoin="round" stroke-width="1.5">
|
|
<rect width="19.154" height="12.959" rx="1" stroke="none"/>
|
|
<rect x="0.75" y="0.75" width="17.654" height="11.459" rx="0.25" fill="none"/>
|
|
</g>
|
|
<path id="Tracé_294" class="mail-letter" data-name="Tracé 294" d="M6693.393,1761.567l8.581,5.714,8.636-5.714" transform="translate(-5491.858 -1150.417)" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
|
|
</g>
|
|
</svg>
|
|
</a>
|
|
@break
|
|
@case('whatsapp')
|
|
<a data-share="whatsapp-{{ $hash }}" role="button" target="_blank" rel="me"
|
|
href="https://wa.me?text={{ urlencode($title) }} : {{ urlencode(str_replace("http://", "https://", request()->fullurl())) }}"
|
|
title="{{ __('Partager sur Whatsapp') }}">
|
|
<img class="mx-2 my-1" src="{{ asset("build/assets/images/whatsapp{$circle}.png") }}" alt="Whatsapp">
|
|
</a>
|
|
@break
|
|
@default
|
|
@dd('Unhandled share')
|
|
@endswitch
|
|
|
|
@push('scripts')
|
|
<script nonce="{{ $nonce }}">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
/** @type {HTMLLinkElement|null} */
|
|
const facebook = document.querySelector('a[data-share="facebook-{{ $hash }}"]');
|
|
/** @type {HTMLLinkElement|null} */
|
|
const twitter = document.querySelector('a[data-share="twitter-{{ $hash }}"]');
|
|
/** @type {HTMLLinkElement|null} */
|
|
const linkedin = document.querySelector('a[data-share="linkedin-{{ $hash }}"]');
|
|
/** @type {HTMLLinkElement|null} */
|
|
const mail = document.querySelector('a[data-share="mail-{{ $hash }}"]');
|
|
|
|
if(facebook) {
|
|
facebook.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
window.open(this.href, "Facebook", "height=285,width=550,resizable=1");
|
|
});
|
|
}
|
|
if(twitter) {
|
|
twitter.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
window.open(this.href, "Twitter", "height=385,width=550,resizable=1");
|
|
});
|
|
}
|
|
if(linkedin) {
|
|
linkedin.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
window.open(this.href, "LinkedIn", "height=485,width=550,resizable=1");
|
|
});
|
|
}
|
|
if(mail) {
|
|
mail.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
window.open(this.href, "Mail", "height=485,width=550,resizable=1");
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|