Skip to content

Commit

Permalink
fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dotslashtarun committed Jan 10, 2023
1 parent 2139dbb commit a2f3b01
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions website/static/js/code-block-buttons.js
@@ -1,6 +1,6 @@
// Turn off ESLint for this file because it's sent down to users as-is.
/* eslint-disable */
window.addEventListener("load", function () {
"use strict";

window.addEventListener("load", () => {
function button(label, ariaLabel, icon, className) {
const btn = document.createElement("button");
btn.classList.add("btnIcon", className);
Expand All @@ -17,9 +17,9 @@ window.addEventListener("load", function () {
}

function addButtons(codeBlockSelector, btn) {
document.querySelectorAll(codeBlockSelector).forEach(function (code) {
for (const code of document.querySelectorAll(codeBlockSelector)) {
code.parentNode.appendChild(btn.cloneNode(true));
});
}
}

const copyIcon =
Expand All @@ -29,18 +29,18 @@ window.addEventListener("load", function () {
".hljs",
button("Copy", "Copy code to clipboard", copyIcon, "btnClipboard")
);

// eslint-disable-next-line no-undef
const clipboard = new ClipboardJS(".btnClipboard", {
target: function (trigger) {
target(trigger) {
return trigger.parentNode.querySelector("code");
},
});

clipboard.on("success", function (event) {
clipboard.on("success", (event) => {
event.clearSelection();
const textEl = event.trigger.querySelector(".btnIcon__label");
textEl.textContent = "Copied";
setTimeout(function () {
setTimeout(() => {
textEl.textContent = "Copy";
}, 2000);
});
Expand Down

0 comments on commit a2f3b01

Please sign in to comment.