Refactor to copy button script

This commit is contained in:
Daniel_I_Am 2022-06-14 17:26:41 +02:00
parent 0847809834
commit 7fe413d720
2 changed files with 3 additions and 2 deletions

View File

@ -1,10 +1,10 @@
import clickableMaker from "./clickable-maker"; import clickableMaker from "./clickable-maker";
import codeBlockFormatter from "./code-block-formatter"; import copyButton from "./copy-button";
import tabbed from "./tabbed"; import tabbed from "./tabbed";
import _ from "./lunr"; import _ from "./lunr";
window.addEventListener('load', () => { window.addEventListener('load', () => {
clickableMaker(); clickableMaker();
codeBlockFormatter(); copyButton();
tabbed(); tabbed();
}); });

View File

@ -2,6 +2,7 @@ export default function() {
Array.from(document.querySelectorAll('[data-copy-button=true]')).forEach(e => { Array.from(document.querySelectorAll('[data-copy-button=true]')).forEach(e => {
const copyButton = document.createElement('button'); const copyButton = document.createElement('button');
copyButton.classList.add('copy-button'); copyButton.classList.add('copy-button');
copyButton.title = "Click to copy";
copyButton.addEventListener('click', () => { copyButton.addEventListener('click', () => {
const addTemporaryClass = (className, time) => { const addTemporaryClass = (className, time) => {