Btw, at the moment as it is, you can only vote by clicking the little checkmark. If we use this script in the default header editor by flarum, we can make the whole button responsive on click.
<script>
document.addEventListener("DOMContentLoaded", function() {
// Function to toggle checkbox state
function toggleCheckbox(checkbox) {
checkbox.checked = !checkbox.checked;
checkbox.dispatchEvent(new Event('change')); // Trigger change event to handle voting
}
// Function to handle click events
function handlePollOptionClick(event) {
if (!event.target.closest('.PollAnswer-checkbox')) {
const checkbox = event.currentTarget.querySelector('input[type="checkbox"]');
if (checkbox) {
toggleCheckbox(checkbox);
}
}
}
// Attach event listeners to all poll options
function attachPollEventListeners() {
document.querySelectorAll('.PollOption').forEach(function(pollOption) {
pollOption.removeEventListener('click', handlePollOptionClick); // Remove old listeners to avoid duplication
pollOption.addEventListener('click', handlePollOptionClick);
});
}
// Initial call to attach event listeners
attachPollEventListeners();
// Reattach listeners if new polls are dynamically added
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
attachPollEventListeners();
}
});
});
// Start observing for changes in the document
observer.observe(document.body, { childList: true, subtree: true });
});
</script>
Since you are the developer, I just wanted to ask you if it's fine to do this until a feature is added one day.