forked from mirrors/bookwyrm
Javascript cleanup
This commit is contained in:
parent
5591024933
commit
4d4e692f49
3 changed files with 11 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
{% endfor %}
|
||||
</fieldset>
|
||||
</ul>
|
||||
<div class="block pt-1" onclick="selectAll(this)">
|
||||
<div class="block pt-1 select-all">
|
||||
<label class="label">
|
||||
<input type="checkbox" class="checkbox">
|
||||
Select all
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load bookwyrm_tags %}
|
||||
<form class="is-flex-grow-1" name="reply" action="/reply" method="post" onsubmit="return reply(event)">
|
||||
<form class="is-flex-grow-1" name="reply" action="/reply" method="post">
|
||||
<div class="columns is-align-items-flex-end">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="reply_parent" value="{{ status.id }}">
|
||||
|
|
Loading…
Reference in a new issue