From 55910249335d944fb6104262350f6ac2e136a24f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 14 Jan 2021 14:38:33 -0800 Subject: [PATCH] Moves interaction javascript out of html --- bookwyrm/static/js/shared.js | 13 ++++++++----- bookwyrm/templates/snippets/boost_button.html | 4 ++-- bookwyrm/templates/snippets/fav_button.html | 4 ++-- bookwyrm/templates/snippets/follow_button.html | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index 60e78052..55d0d64d 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -1,9 +1,12 @@ +// set up javascript listeners window.onload = function() { - var toggles = document.getElementsByClassName('toggle-control'); - // .forEach(t => t.onclick = toggle_action); - for (var i=0; i t.onclick = toggle_action); + + // javascript interactions + Array.from(document.getElementsByClassName('interaction')) + .forEach(t => t.onsubmit = interact); }; function toggle_action(e) { diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index e6688124..08daae64 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -1,7 +1,7 @@ {% load bookwyrm_tags %} {% with status.id|uuid as uuid %} -
+ {% csrf_token %}
-
+ {% csrf_token %}
-
+ {% csrf_token %} {% endif %}
-