From 4d4e692f4950f5c279290b294c06a71740e3dc69 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 14 Jan 2021 15:16:18 -0800 Subject: [PATCH] Javascript cleanup --- bookwyrm/static/js/shared.js | 21 +++++++++------------ bookwyrm/templates/import_status.html | 2 +- bookwyrm/templates/snippets/reply_form.html | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index 55d0d64d..54d2a1b7 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -2,14 +2,18 @@ window.onload = function() { // let buttons set keyboard focus Array.from(document.getElementsByClassName('toggle-control')) - .forEach(t => t.onclick = toggle_action); + .forEach(t => t.onclick = toggleAction); - // javascript interactions + // javascript interactions (boost/fav) Array.from(document.getElementsByClassName('interaction')) .forEach(t => t.onsubmit = interact); + + // select all + Array.from(document.getElementsByClassName('select-all')) + .forEach(t => t.onclick = selectAll); }; -function toggle_action(e) { +function toggleAction(e) { // set hover, if appropriate var hover = e.target.getAttribute('data-hover-target') if (hover) { @@ -33,15 +37,8 @@ function interact(e) { return true; } -function reply(e) { - e.preventDefault(); - ajaxPost(e.target); - // TODO: display comment - return true; -} - -function selectAll(el) { - el.parentElement.querySelectorAll('[type="checkbox"]') +function selectAll(e) { + e.target.parentElement.parentElement.querySelectorAll('[type="checkbox"]') .forEach(t => t.checked=true); } diff --git a/bookwyrm/templates/import_status.html b/bookwyrm/templates/import_status.html index c58635d1..ba462eee 100644 --- a/bookwyrm/templates/import_status.html +++ b/bookwyrm/templates/import_status.html @@ -50,7 +50,7 @@ {% endfor %} -
+