27 lines
729 B
JavaScript
27 lines
729 B
JavaScript
|
// Inicializar Clipboard.js
|
||
|
const clipboard = new ClipboardJS(".clipboard");
|
||
|
|
||
|
// Manejar el evento de éxito
|
||
|
clipboard.on("success", function (e) {
|
||
|
const clipboardDiv = e.trigger;
|
||
|
|
||
|
// Cambiar el fondo y el color del texto
|
||
|
clipboardDiv.classList.remove("bg-white", "hover:bg-gray-100");
|
||
|
clipboardDiv.classList.add("bg-green-100");
|
||
|
|
||
|
// Mostrar mensaje
|
||
|
const feedback = document.getElementById("feedback");
|
||
|
feedback.classList.remove("hidden");
|
||
|
|
||
|
// Restaurar el color después de 2 segundos
|
||
|
setTimeout(() => {
|
||
|
feedback.classList.add("hidden");
|
||
|
clipboardDiv.classList.remove("bg-green-100");
|
||
|
}, 2000);
|
||
|
});
|
||
|
|
||
|
// Manejar errores
|
||
|
clipboard.on("error", function (e) {
|
||
|
console.error("Failed to copy:", e);
|
||
|
});
|