Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 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 | d347dbab980d |
children | 7de03d416f38 |
comparison
equal
deleted
inserted
replaced
2345:9239f1d74f01 | 2346:5f1e2b66d8bb |
---|---|
706 } else if (node.specification.type == 'checkbox') { | 706 } else if (node.specification.type == 'checkbox') { |
707 if (node.response == undefined) { | 707 if (node.response == undefined) { |
708 node.response = Array(node.specification.options.length); | 708 node.response = Array(node.specification.options.length); |
709 } | 709 } |
710 var index = 0; | 710 var index = 0; |
711 var max_w = 0; | 711 var table = document.createElement("table"); |
712 table.className = "popup-option-list"; | |
713 table.border = "0"; | |
712 for (var option of node.specification.options) { | 714 for (var option of node.specification.options) { |
713 var input = document.createElement('input'); | 715 var tr = document.createElement("tr"); |
714 input.id = option.name; | 716 table.appendChild(tr); |
717 var td = document.createElement("td"); | |
718 tr.appendChild(td); | |
719 var input = document.createElement('input'); | |
720 input.id = option.name; | |
715 input.type = 'checkbox'; | 721 input.type = 'checkbox'; |
722 td.appendChild(input); | |
723 | |
724 td = document.createElement("td"); | |
725 tr.appendChild(td); | |
716 var span = document.createElement('span'); | 726 var span = document.createElement('span'); |
717 span.textContent = option.text; | 727 span.textContent = option.text; |
718 var hold = document.createElement('div'); | 728 td.appendChild(span); |
719 hold.setAttribute('name','option'); | 729 var tr = document.createElement('div'); |
720 hold.className = "popup-option-checbox"; | 730 tr.setAttribute('name','option'); |
721 hold.appendChild(input); | 731 tr.className = "popup-option-checbox"; |
722 hold.appendChild(span); | |
723 this.popupResponse.appendChild(hold); | |
724 if (node.response[index] != undefined){ | 732 if (node.response[index] != undefined){ |
725 if (node.response[index].checked == true) { | 733 if (node.response[index].checked == true) { |
726 input.checked = "true"; | 734 input.checked = "true"; |
727 } | 735 } |
728 } | 736 } |
729 var w = $(hold).width(); | 737 } |
730 if (w > max_w) | 738 this.popupResponse.appendChild(table); |
731 max_w = w; | |
732 index++; | |
733 } | |
734 this.popupResponse.style.textAlign=""; | |
735 var leftP = 50-(((max_w/$('#popupContent').width())/2)*100); | |
736 this.popupResponse.style.left=leftP+"%"; | |
737 } else if (node.specification.type == 'radio') { | 739 } else if (node.specification.type == 'radio') { |
738 if (node.response == undefined) { | 740 if (node.response == undefined) { |
739 node.response = {name: "", text: ""}; | 741 node.response = {name: "", text: ""}; |
740 } | 742 } |
741 var index = 0; | 743 var index = 0; |
742 var max_w = 0; | 744 var table = document.createElement("table"); |
745 table.className = "popup-option-list"; | |
746 table.border = "0"; | |
743 for (var option of node.specification.options) { | 747 for (var option of node.specification.options) { |
744 var input = document.createElement('input'); | 748 var tr = document.createElement("tr"); |
745 input.id = option.name; | 749 table.appendChild(tr); |
750 var td = document.createElement("td"); | |
751 tr.appendChild(td); | |
752 var input = document.createElement('input'); | |
753 input.id = option.name; | |
746 input.type = 'radio'; | 754 input.type = 'radio'; |
747 input.name = node.specification.id; | 755 input.name = node.specification.id; |
756 td.appendChild(input); | |
757 | |
758 td = document.createElement("td"); | |
759 tr.appendChild(td); | |
748 var span = document.createElement('span'); | 760 var span = document.createElement('span'); |
749 span.textContent = option.text; | 761 span.textContent = option.text; |
750 var hold = document.createElement('div'); | 762 td.appendChild(span); |
751 hold.setAttribute('name','option'); | 763 var tr = document.createElement('div'); |
752 hold.className = "popup-option-checbox"; | 764 tr.setAttribute('name','option'); |
753 hold.appendChild(input); | 765 tr.className = "popup-option-checbox"; |
754 hold.appendChild(span); | 766 if (node.response[index] != undefined){ |
755 this.popupResponse.appendChild(hold); | 767 if (node.response[index].checked == true) { |
756 if (input.id == node.response.name) { | 768 input.checked = "true"; |
757 input.checked = "true"; | 769 } |
758 } | 770 } |
759 var w = $(hold).width(); | 771 } |
760 if (w > max_w) | 772 this.popupResponse.appendChild(table); |
761 max_w = w; | |
762 } | |
763 this.popupResponse.style.textAlign=""; | |
764 var leftP = 50-(((max_w/$('#popupContent').width())/2)*100); | |
765 this.popupResponse.style.left=leftP+"%"; | |
766 } else if (node.specification.type == 'number') { | 773 } else if (node.specification.type == 'number') { |
767 var input = document.createElement('input'); | 774 var input = document.createElement('input'); |
768 input.type = 'textarea'; | 775 input.type = 'textarea'; |
769 if (node.min != null) {input.min = node.specification.min;} | 776 if (node.min != null) {input.min = node.specification.min;} |
770 if (node.max != null) {input.max = node.specification.max;} | 777 if (node.max != null) {input.max = node.specification.max;} |