« MediaWiki:Common.js » : différence entre les versions
Apparence
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
document.querySelectorAll('.copy-button').forEach(button => { | document.querySelectorAll('.copy-button').forEach(button => { | ||
| Ligne 20 : | Ligne 4 : | ||
const targetId = this.getAttribute('data-copy-target'); | const targetId = this.getAttribute('data-copy-target'); | ||
const target = document.getElementById(targetId); | const target = document.getElementById(targetId); | ||
if (!target) return; | if (!target) return; | ||
// 👇 Force le focus avant de copier | |||
window.focus(); | |||
const text = target.innerText || target.textContent; | const text = target.innerText || target.textContent; | ||
navigator.clipboard.writeText(text).then(() => { | |||
this.textContent = '✅ Copié'; | |||
setTimeout(() => this.textContent = '📋 Copier', 2000); | setTimeout(() => this.textContent = '📋 Copier', 2000); | ||
} | }).catch(err => { | ||
console.error("Erreur de copie :", err); | |||
this.textContent = '❌ Erreur'; | |||
}); | |||
}); | }); | ||
}); | }); | ||
}); | }); | ||
Version du 26 août 2025 à 15:45
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.copy-button').forEach(button => {
button.addEventListener('click', function () {
const targetId = this.getAttribute('data-copy-target');
const target = document.getElementById(targetId);
if (!target) return;
// 👇 Force le focus avant de copier
window.focus();
const text = target.innerText || target.textContent;
navigator.clipboard.writeText(text).then(() => {
this.textContent = '✅ Copié';
setTimeout(() => this.textContent = '📋 Copier', 2000);
}).catch(err => {
console.error("Erreur de copie :", err);
this.textContent = '❌ Erreur';
});
});
});
});