closed polls no longer hide the checkbox

This commit is contained in:
iou1name 2018-07-27 13:29:42 -04:00
parent 209d759dcd
commit 1abf8eb8e1
4 changed files with 25 additions and 12 deletions

View File

@ -148,7 +148,7 @@ h3 {
padding: 0.2em; padding: 0.2em;
} }
.pollCheckBox label:after { .pollCheckBox label::after {
content: "\2713"; content: "\2713";
color: #bfbfbf; color: #bfbfbf;
opacity: 0.3; opacity: 0.3;
@ -158,11 +158,15 @@ h3 {
opacity: 0.5; opacity: 0.5;
} }
.pollCheckBox input[type=checkbox]:checked + label:after { .pollCheckBox input:checked + label::after {
opacity: 1; opacity: 1;
color: black; color: black;
} }
.pollCheckBox input:disabled + label {
opacity: 0.3;
}
#writeinInput { #writeinInput {
width: 100%; width: 100%;
} }

View File

@ -56,7 +56,10 @@ socket.on('close_post', function(data) {
/* end QM only */ /* end QM only */
if (post.parentElement.classList.contains('pollPost')) { if (post.parentElement.classList.contains('pollPost')) {
let table = document.getElementById('poll-' + data.post_id); let table = document.getElementById('poll-' + data.post_id);
table.getElementsByTagName("col")[0].style.visibility = 'collapse'; let boxes = table.getElementsByTagName('input');
for (let i = 0; i < boxes.length; i++) {
boxes[i].disabled = true;
}
let writein = document.getElementById('writeinContainer'); let writein = document.getElementById('writeinContainer');
if (writein) { if (writein) {
writein.style.display = 'none'; writein.style.display = 'none';
@ -72,8 +75,11 @@ socket.on('open_post', function(data) {
document.getElementById('open_post_id-' + data.post_id).style.display = 'none'; document.getElementById('open_post_id-' + data.post_id).style.display = 'none';
/* end QM only */ /* end QM only */
if (post.parentElement.classList.contains('pollPost')) { if (post.parentElement.classList.contains('pollPost')) {
table = document.getElementById('poll-' + data.post_id); let table = document.getElementById('poll-' + data.post_id);
table.getElementsByTagName("col")[0].style.visibility = ''; let boxes = table.getElementsByTagName('input');
for (let i = 0; i < boxes.length; i++) {
boxes[i].disabled = false;
}
let writein = document.getElementById('writeinContainer'); let writein = document.getElementById('writeinContainer');
if (writein) { if (writein) {
writein.style.display = 'initial'; writein.style.display = 'initial';

View File

@ -83,7 +83,10 @@ socket.on('close_post', function(data) {
post.children[0].textContent = post.children[0].textContent.replace('Open', 'Closed'); post.children[0].textContent = post.children[0].textContent.replace('Open', 'Closed');
if (post.parentElement.classList.contains('pollPost')) { if (post.parentElement.classList.contains('pollPost')) {
let table = document.getElementById('poll-' + data.post_id); let table = document.getElementById('poll-' + data.post_id);
table.getElementsByTagName("col")[0].style.visibility = 'collapse'; let boxes = table.getElementsByTagName('input');
for (let i = 0; i < boxes.length; i++) {
boxes[i].disabled = true;
}
let writein = document.getElementById('writeinContainer'); let writein = document.getElementById('writeinContainer');
if (writein) { if (writein) {
writein.style.display = 'none'; writein.style.display = 'none';
@ -95,7 +98,10 @@ socket.on('open_post', function(data) {
post.firstElementChild.textContent = post.firstElementChild.textContent.replace('Closed', 'Open'); post.firstElementChild.textContent = post.firstElementChild.textContent.replace('Closed', 'Open');
if (post.parentElement.classList.contains('pollPost')) { if (post.parentElement.classList.contains('pollPost')) {
table = document.getElementById('poll-' + data.post_id); table = document.getElementById('poll-' + data.post_id);
table.getElementsByTagName("col")[0].style.visibility = ''; let boxes = table.getElementsByTagName('input');
for (let i = 0; i < boxes.length; i++) {
boxes[i].disabled = false;
}
let writein = document.getElementById('writeinContainer'); let writein = document.getElementById('writeinContainer');
if (writein) { if (writein) {
writein.style.display = 'initial'; writein.style.display = 'initial';
@ -116,7 +122,7 @@ socket.on('vote', function(data) {
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
new_tbody.appendChild(arr[i]); new_tbody.appendChild(arr[i]);
} }
table.replaceChild(new_tbody, table.children[1]); table.replaceChild(new_tbody, table.children[0]);
}); });
socket.on('toggle_option_box', function(data) { socket.on('toggle_option_box', function(data) {
document.getElementById('pollInput-' + data.option_id).checked = data.polarity; document.getElementById('pollInput-' + data.option_id).checked = data.polarity;

View File

@ -66,13 +66,10 @@
{% elif quest_post[3] == "poll" %} {% elif quest_post[3] == "poll" %}
<h3>{{ quest_post[4] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3> <h3>{{ quest_post[4] }} - {% if quest_post[0] == open_post_id %}Open{% else %}Closed{% endif %}</h3>
<table class="poll" id="poll-{{ quest_post[0] }}"> <table class="poll" id="poll-{{ quest_post[0] }}">
<col{% if quest_post[0] != open_post_id %} style="visibility: collapse;"{% endif %}/>
<col/>
<col/>
{% for option in options.get(quest_post[0], []) %} {% for option in options.get(quest_post[0], []) %}
<tr id="optionRow-{{ option[0] }}"> <tr id="optionRow-{{ option[0] }}">
<td class="pollCheckBox"> <td class="pollCheckBox">
<input type="checkbox" {% if ip_address in poll_votes.get(option[0], []) %}checked="true"{% endif %} id="pollInput-{{ option[0] }}" onchange="pollVote({{ quest_post[0] }}, {{ option[0] }})"/> <input type="checkbox" {% if ip_address in poll_votes.get(option[0], []) %}checked="true"{% endif %} id="pollInput-{{ option[0] }}" onchange="pollVote({{ quest_post[0] }}, {{ option[0] }})"{% if quest_post[0] != open_post_id %} disabled{% endif %}/>
<label for="pollInput-{{ option[0] }}"></label> <label for="pollInput-{{ option[0] }}"></label>
</td> </td>
<td class="option_text">{{ option[2] }}</td> <td class="option_text">{{ option[2] }}</td>