don't show checkboxes on confirmation dialog when there's only one picture

This commit is contained in:
howard-stearns 2016-08-12 11:50:11 -07:00
parent ae9af88db2
commit 1b62332058

View file

@ -46,7 +46,7 @@
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script> <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="js/eventBridgeLoader.js"></script> <script type="text/javascript" src="js/eventBridgeLoader.js"></script>
<script> <script>
var paths = [], idCounter = 0; var paths = [], idCounter = 0, useCheckboxes;
function addImage(data) { function addImage(data) {
var div = document.createElement("DIV"), var div = document.createElement("DIV"),
input = document.createElement("INPUT"), input = document.createElement("INPUT"),
@ -56,15 +56,17 @@
function toggle() { data.share = input.checked; } function toggle() { data.share = input.checked; }
img.src = data.localPath; img.src = data.localPath;
div.appendChild(img); div.appendChild(img);
// Our stylesheet(?) requires input.id to match label.for. Otherwise input doesn't display the check state. if (useCheckboxes) { // I'd rather use css, but the included stylesheet is quite particular.
label.setAttribute('for', id); // cannot do label.for = // Our stylesheet(?) requires input.id to match label.for. Otherwise input doesn't display the check state.
input.id = id; label.setAttribute('for', id); // cannot do label.for =
input.type = "checkbox"; input.id = id;
input.checked = data.share = true; input.type = "checkbox";
input.addEventListener('change', toggle); input.checked = data.share = true;
div.class = "property checkbox"; input.addEventListener('change', toggle);
div.appendChild(input); div.class = "property checkbox";
div.appendChild(label); div.appendChild(input);
div.appendChild(label);
}
document.getElementById("snapshot-images").appendChild(div); document.getElementById("snapshot-images").appendChild(div);
paths.push(data); paths.push(data);
@ -93,6 +95,7 @@
handleShareButtons(shareMsg); handleShareButtons(shareMsg);
// rest are image paths which we add // rest are image paths which we add
useCheckboxes = message.length > 1;
message.forEach(addImage); message.forEach(addImage);
}); });
EventBridge.emitWebEvent('ready'); EventBridge.emitWebEvent('ready');