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() {
|
window.onload = function() {
|
||||||
// let buttons set keyboard focus
|
// let buttons set keyboard focus
|
||||||
Array.from(document.getElementsByClassName('toggle-control'))
|
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'))
|
Array.from(document.getElementsByClassName('interaction'))
|
||||||
.forEach(t => t.onsubmit = interact);
|
.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
|
// set hover, if appropriate
|
||||||
var hover = e.target.getAttribute('data-hover-target')
|
var hover = e.target.getAttribute('data-hover-target')
|
||||||
if (hover) {
|
if (hover) {
|
||||||
|
@ -33,15 +37,8 @@ function interact(e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reply(e) {
|
function selectAll(e) {
|
||||||
e.preventDefault();
|
e.target.parentElement.parentElement.querySelectorAll('[type="checkbox"]')
|
||||||
ajaxPost(e.target);
|
|
||||||
// TODO: display comment
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectAll(el) {
|
|
||||||
el.parentElement.querySelectorAll('[type="checkbox"]')
|
|
||||||
.forEach(t => t.checked=true);
|
.forEach(t => t.checked=true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="block pt-1" onclick="selectAll(this)">
|
<div class="block pt-1 select-all">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<input type="checkbox" class="checkbox">
|
<input type="checkbox" class="checkbox">
|
||||||
Select all
|
Select all
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% load bookwyrm_tags %}
|
{% 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">
|
<div class="columns is-align-items-flex-end">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="reply_parent" value="{{ status.id }}">
|
<input type="hidden" name="reply_parent" value="{{ status.id }}">
|
||||||
|
|
Loading…
Reference in a new issue