Compare commits

..

No commits in common. "562be8f9a780f22080e7cad4c560c794db16f46f" and "d7c3d33bd87e8bbcece2050f31f88f62e2d0639e" have entirely different histories.

4 changed files with 1 additions and 61 deletions

View File

@ -3,10 +3,6 @@
@apply px-8;
}
#cite-reference {
@apply hidden;
}
.tags__title {
@apply text-lg uppercase font-semibold mt-0 my-4 nunito;
}

View File

@ -6,7 +6,6 @@ import alternatePictures from './alternate-pictures';
import { searchBarInit } from './search-bar';
import singlesInit from './singles/singles';
import archivesInit from './archives/archives';
import handleCiteButton from './singles/cite-button';
window.addEventListener('load', function () {
menuInit();
@ -17,5 +16,4 @@ window.addEventListener('load', function () {
searchBarInit();
singlesInit();
archivesInit();
handleCiteButton();
});

View File

@ -1,52 +0,0 @@
export default function handleCiteButton(): void {
const citeButton: HTMLElement | null = document.querySelector(
'.socials-buttons__button--cite',
);
const citeReference: HTMLElement | null = document.querySelector('#cite-reference');
if (!citeButton || !citeReference) return;
if (!window.isSecureContext) {
citeButton.setAttribute('disabled', 'true');
citeButton.setAttribute(
'title',
'Vous devez utiliser un navigation sécurisé (https) pour copier la citation',
);
}
citeButton.addEventListener('click', () => {
const textToCopy = citeReference.textContent;
if (!textToCopy) return;
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard
.writeText(textToCopy)
.then(() => {
const notyf = new Notyf({
duration: 4000,
ripple: false,
dismissible: true,
types: [
{
type: 'success',
icon: {
className: 'notyf__icon--success',
tagName: 'i',
},
},
],
position: {
x: 'right',
y: 'top',
},
});
notyf.success(
'Citation copiée dans le presse-papiers ! <br> Vous pouvez maintenant la coller dans votre document.',
);
})
.catch((err) => {
console.error('Failed to copy text: ', err);
});
}
});
}

View File

@ -2,13 +2,11 @@
$currentPostType = get_post_type();
$shareUrls = build_share_urls();
$handleCitation = post_type_supports($currentPostType, 'carhop-citations') ?? false;
$citeReference = get_field('cite_reference', get_the_ID());
// write_log($handleCitation);
?>
<div class="socials-buttons">
<?php if ($handleCitation && !empty($citeReference)) : ?>
<?php if ($handleCitation) : ?>
<button class="socials-buttons__button socials-buttons__button--cite" <?php echo empty($citeReference) ? 'disabled' : ''; ?> title="<?php echo empty($citeReference) ? 'Citation non disponible' : 'Copier la citation'; ?>">
<img src="<?php echo get_template_directory_uri(); ?>/resources/img/icons/carhop-citer-article.svg" alt="">
Citer