Fix js following review

This commit is contained in:
Joachim 2021-12-04 16:31:38 +01:00
parent 407d471065
commit 57502c1f3c

View file

@ -449,13 +449,20 @@ let BookWyrm = new class {
const copyButtonEl = document.createElement('button'); const copyButtonEl = document.createElement('button');
copyButtonEl.textContent = textareaEl.dataset.copytextLabel; copyButtonEl.textContent = textareaEl.dataset.copytextLabel;
copyButtonEl.classList.add("mt-2","button","is-small","is-fullwidth","is-primary","is-light"); copyButtonEl.classList.add(
"mt-2",
"button",
"is-small",
"is-fullwidth",
"is-primary",
"is-light"
);
copyButtonEl.addEventListener('click', () => { copyButtonEl.addEventListener('click', () => {
navigator.clipboard.writeText(text).then(function() { navigator.clipboard.writeText(text).then(function() {
textareaEl.classList.add('is-success'); textareaEl.classList.add('is-success');
copyButtonEl.classList.replace('is-primary', 'is-success'); copyButtonEl.classList.replace('is-primary', 'is-success');
copyButtonEl.textContent = textareaEl.dataset.copytextSuccess; copyButtonEl.textContent = textareaEl.dataset.copytextSuccess;
}); });
}); });
textareaEl.parentNode.appendChild(copyButtonEl) textareaEl.parentNode.appendChild(copyButtonEl)