Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecaed0adaa |
File diff suppressed because one or more lines are too long
@@ -172,7 +172,6 @@
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.poll-option[disabled] {
|
||||
@@ -183,10 +182,6 @@
|
||||
border-color: var(--border-light);
|
||||
}
|
||||
|
||||
.poll-option:not([disabled]):active {
|
||||
background-color: var(--bg-card-hover);
|
||||
}
|
||||
|
||||
.poll-option.chosen {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import { OptimisticAction } from "./OptimisticAction.js";
|
||||
export class PollManager extends OptimisticAction {
|
||||
constructor() {
|
||||
super();
|
||||
this.container = null;
|
||||
document.addEventListener("pointerdown", (event) => this.onClick(event));
|
||||
document.addEventListener("click", (event) => this.onClick(event));
|
||||
document.addEventListener("submit", (event) => this.onSubmit(event), true);
|
||||
}
|
||||
|
||||
@@ -43,8 +42,7 @@ export class PollManager extends OptimisticAction {
|
||||
}
|
||||
const pollUid = poll.dataset.pollUid;
|
||||
const optionUid = option.dataset.optionUid;
|
||||
this.container = poll;
|
||||
await this.submit(`/polls/${pollUid}/vote`, { option_uid: optionUid }, this.container, (result) => this.render(poll, result));
|
||||
await this.submit(`/polls/${pollUid}/vote`, { option_uid: optionUid }, null, (result) => this.render(poll, result));
|
||||
}
|
||||
|
||||
render(poll, result) {
|
||||
|
||||
@@ -5,18 +5,21 @@ import { OptimisticAction } from "./OptimisticAction.js";
|
||||
export class VoteManager extends OptimisticAction {
|
||||
constructor() {
|
||||
super();
|
||||
this.initVoteButtons();
|
||||
document.addEventListener("click", (event) => this.onClick(event));
|
||||
}
|
||||
|
||||
initVoteButtons() {
|
||||
document.querySelectorAll('form[action^="/votes/"] button[type="submit"]').forEach((button) => {
|
||||
const form = button.closest("form");
|
||||
button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.cast(form, button);
|
||||
});
|
||||
});
|
||||
onClick(event) {
|
||||
const button = event.target.closest('form[action^="/votes/"] button[type="submit"]');
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
const form = button.closest("form");
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.cast(form, button);
|
||||
}
|
||||
|
||||
cast(form, button) {
|
||||
|
||||
@@ -29,7 +29,7 @@ def is_self(user, uid) -> bool:
|
||||
def guest_disabled(user) -> Markup:
|
||||
if user:
|
||||
return Markup("")
|
||||
return Markup(' disabled aria-disabled="true"')
|
||||
return Markup(' disabled aria-disabled="true" title="Log in to vote"')
|
||||
|
||||
|
||||
def static_url(path) -> str:
|
||||
|
||||
Reference in New Issue
Block a user