98 lines
4.9 KiB
PHP
98 lines
4.9 KiB
PHP
@php
|
|
$circle = isset($circle) ? '-circle' : '';
|
|
$hash = uniqid('', true);
|
|
@endphp
|
|
@switch($socialNetwork)
|
|
@case('facebook')
|
|
<a data-share="facebook-{{ $hash }}"
|
|
href="https://www.facebook.com/sharer/sharer.php?u={{ urlencode(str_replace('http://', 'https://', request()->fullurl())) }}&t={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur Facebook') }}" role="button" target="_blank" rel="me">
|
|
<img class="mx-2 my-1" src="{{ Vite::asset("resources/assets/images/facebook{$circle}.png") }}" alt="Facebook">
|
|
</a>
|
|
@break
|
|
|
|
@case('twitter')
|
|
<a data-share="twitter-{{ $hash }}"
|
|
href="https://twitter.com/share?url={{ urlencode(str_replace('http://', 'https://', request()->fullurl())) }}&text={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur Twitter') }}" role="button" target="_blank" rel="me">
|
|
<img class="mx-2 my-1" src="{{ Vite::asset("resources/assets/images/twitter{$circle}.png") }}" alt="Twitter">
|
|
</a>
|
|
@break
|
|
|
|
@case('linkedin')
|
|
<a data-share="linkedin-{{ $hash }}"
|
|
href="http://www.linkedin.com/shareArticle?mini=true&url={{ urlencode(str_replace('http://', 'https://', request()->fullurl())) }}&title={{ urlencode($title) }}"
|
|
title="{{ __('Partager sur LinkedIn') }}" role="button" target="_blank" rel="me">
|
|
<img class="mx-2 my-1" src="{{ Vite::asset("resources/assets/images/linkedin{$circle}.png") }}" alt="Linkedin">
|
|
</a>
|
|
@break
|
|
|
|
@case('mail')
|
|
<a data-share="mail-{{ $hash }}" href="mailto:?subject={{ $subject }}&body={{ $title }}"
|
|
title="{{ __('Partager par E-mail') }}" role="button" target="_blank">
|
|
<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 class="mail-letter" id="Rectangle_115" 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 class="mail-letter" id="Tracé_294" 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 }}"
|
|
href="https://wa.me?text={{ urlencode($title) }} : {{ urlencode(str_replace('http://', 'https://', request()->fullurl())) }}"
|
|
title="{{ __('Partager sur Whatsapp') }}" role="button" target="_blank" rel="me">
|
|
<img class="mx-2 my-1" src="{{ Vite::asset("resources/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
|