2022-01-07 15:18:07 +00:00
|
|
|
const { createCopyButton } = require("./copycode.js")
|
|
|
|
const Clipboard = require("clipboard")
|
2022-01-06 12:58:10 +00:00
|
|
|
|
2021-05-21 09:33:17 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
2022-01-06 12:58:10 +00:00
|
|
|
let clipboard = new Clipboard(".clip")
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
clipboard.on("success", function (e) {
|
2022-01-06 12:58:10 +00:00
|
|
|
const trigger = e.trigger
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
if (trigger.hasAttribute("data-copy-feedback")) {
|
2022-01-06 12:58:10 +00:00
|
|
|
trigger.classList.add("gdoc-post__codecopy--success")
|
2022-04-30 11:37:07 +00:00
|
|
|
trigger.querySelector(".gdoc-icon.copy").classList.add("hidden")
|
|
|
|
trigger.querySelector(".gdoc-icon.check").classList.remove("hidden")
|
2021-11-07 21:12:14 +00:00
|
|
|
|
|
|
|
setTimeout(function () {
|
2022-01-06 12:58:10 +00:00
|
|
|
trigger.classList.remove("gdoc-post__codecopy--success")
|
2022-04-30 11:37:07 +00:00
|
|
|
trigger.querySelector(".gdoc-icon.copy").classList.remove("hidden")
|
|
|
|
trigger.querySelector(".gdoc-icon.check").classList.add("hidden")
|
2022-01-06 12:58:10 +00:00
|
|
|
}, 3000)
|
2021-11-07 21:12:14 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 12:58:10 +00:00
|
|
|
e.clearSelection()
|
|
|
|
})
|
|
|
|
|
|
|
|
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv))
|
|
|
|
})
|