Mercurial > hg > webaudioevaluationtool
changeset 2346:5f1e2b66d8bb
Fix for #62 #63. No longer calculating left justification, using table to align content into cells.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 16 May 2016 10:46:31 +0100 |
parents | 9239f1d74f01 |
children | 7de03d416f38 |
files | css/core.css js/core.js |
diffstat | 2 files changed, 55 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/css/core.css Mon May 16 10:29:43 2016 +0100 +++ b/css/core.css Mon May 16 10:46:31 2016 +0100 @@ -99,6 +99,18 @@ margin-right: 15px; } +table.popup-option-list { + margin: auto; +} + +table.popup-option-list tr { + padding: 5px; +} + +table.popup-option-list tr td { + padding: 5px; +} + button#popup-proceed { bottom: 10px; right: 10px;
--- a/js/core.js Mon May 16 10:29:43 2016 +0100 +++ b/js/core.js Mon May 16 10:46:31 2016 +0100 @@ -708,61 +708,68 @@ node.response = Array(node.specification.options.length); } var index = 0; - var max_w = 0; + var table = document.createElement("table"); + table.className = "popup-option-list"; + table.border = "0"; for (var option of node.specification.options) { - var input = document.createElement('input'); - input.id = option.name; + var tr = document.createElement("tr"); + table.appendChild(tr); + var td = document.createElement("td"); + tr.appendChild(td); + var input = document.createElement('input'); + input.id = option.name; input.type = 'checkbox'; + td.appendChild(input); + + td = document.createElement("td"); + tr.appendChild(td); var span = document.createElement('span'); span.textContent = option.text; - var hold = document.createElement('div'); - hold.setAttribute('name','option'); - hold.className = "popup-option-checbox"; - hold.appendChild(input); - hold.appendChild(span); - this.popupResponse.appendChild(hold); + td.appendChild(span); + var tr = document.createElement('div'); + tr.setAttribute('name','option'); + tr.className = "popup-option-checbox"; if (node.response[index] != undefined){ if (node.response[index].checked == true) { input.checked = "true"; } } - var w = $(hold).width(); - if (w > max_w) - max_w = w; - index++; - } - this.popupResponse.style.textAlign=""; - var leftP = 50-(((max_w/$('#popupContent').width())/2)*100); - this.popupResponse.style.left=leftP+"%"; + } + this.popupResponse.appendChild(table); } else if (node.specification.type == 'radio') { if (node.response == undefined) { node.response = {name: "", text: ""}; } var index = 0; - var max_w = 0; + var table = document.createElement("table"); + table.className = "popup-option-list"; + table.border = "0"; for (var option of node.specification.options) { - var input = document.createElement('input'); - input.id = option.name; + var tr = document.createElement("tr"); + table.appendChild(tr); + var td = document.createElement("td"); + tr.appendChild(td); + var input = document.createElement('input'); + input.id = option.name; input.type = 'radio'; - input.name = node.specification.id; + input.name = node.specification.id; + td.appendChild(input); + + td = document.createElement("td"); + tr.appendChild(td); var span = document.createElement('span'); span.textContent = option.text; - var hold = document.createElement('div'); - hold.setAttribute('name','option'); - hold.className = "popup-option-checbox"; - hold.appendChild(input); - hold.appendChild(span); - this.popupResponse.appendChild(hold); - if (input.id == node.response.name) { - input.checked = "true"; + td.appendChild(span); + var tr = document.createElement('div'); + tr.setAttribute('name','option'); + tr.className = "popup-option-checbox"; + if (node.response[index] != undefined){ + if (node.response[index].checked == true) { + input.checked = "true"; + } } - var w = $(hold).width(); - if (w > max_w) - max_w = w; - } - this.popupResponse.style.textAlign=""; - var leftP = 50-(((max_w/$('#popupContent').width())/2)*100); - this.popupResponse.style.left=leftP+"%"; + } + this.popupResponse.appendChild(table); } else if (node.specification.type == 'number') { var input = document.createElement('input'); input.type = 'textarea';