Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1182:b7bf91ac6d01
Bug #1562: Checkbox and radios will be center aligned, left justified. Also solves issue #1571. Only tested in OSX Chrome!
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 12 Feb 2016 09:02:41 +0000 |
parents | 3303a667548a |
children | eef2d4ea18fb |
comparison
equal
deleted
inserted
replaced
1181:6a2e904c519f | 1182:b7bf91ac6d01 |
---|---|
513 } else { | 513 } else { |
514 textArea.value = node.response; | 514 textArea.value = node.response; |
515 } | 515 } |
516 this.popupResponse.appendChild(textArea); | 516 this.popupResponse.appendChild(textArea); |
517 textArea.focus(); | 517 textArea.focus(); |
518 this.popupResponse.style.textAlign="center"; | |
519 this.popupResponse.style.left="0%"; | |
518 } else if (node.specification.type == 'checkbox') { | 520 } else if (node.specification.type == 'checkbox') { |
519 if (node.response == undefined) { | 521 if (node.response == undefined) { |
520 node.response = Array(node.specification.options.length); | 522 node.response = Array(node.specification.options.length); |
521 } | 523 } |
522 var index = 0; | 524 var index = 0; |
525 var max_w = 0; | |
523 for (var option of node.specification.options) { | 526 for (var option of node.specification.options) { |
524 var input = document.createElement('input'); | 527 var input = document.createElement('input'); |
525 input.id = option.name; | 528 input.id = option.name; |
526 input.type = 'checkbox'; | 529 input.type = 'checkbox'; |
527 var span = document.createElement('span'); | 530 var span = document.createElement('span'); |
535 if (node.response[index] != undefined){ | 538 if (node.response[index] != undefined){ |
536 if (node.response[index].checked == true) { | 539 if (node.response[index].checked == true) { |
537 input.checked = "true"; | 540 input.checked = "true"; |
538 } | 541 } |
539 } | 542 } |
543 var w = $(span).width(); | |
544 if (w > max_w) | |
545 max_w = w; | |
540 index++; | 546 index++; |
541 } | 547 } |
548 max_w += 12; | |
549 this.popupResponse.style.textAlign=""; | |
550 var leftP = ((max_w/500)/2)*100; | |
551 this.popupResponse.style.left=leftP+"%"; | |
542 } else if (node.specification.type == 'radio') { | 552 } else if (node.specification.type == 'radio') { |
543 if (node.response == undefined) { | 553 if (node.response == undefined) { |
544 node.response = {name: "", text: ""}; | 554 node.response = {name: "", text: ""}; |
545 } | 555 } |
546 var index = 0; | 556 var index = 0; |
557 var max_w = 0; | |
547 for (var option of node.specification.options) { | 558 for (var option of node.specification.options) { |
548 var input = document.createElement('input'); | 559 var input = document.createElement('input'); |
549 input.id = option.name; | 560 input.id = option.name; |
550 input.type = 'radio'; | 561 input.type = 'radio'; |
551 input.name = node.specification.id; | 562 input.name = node.specification.id; |
558 hold.appendChild(span); | 569 hold.appendChild(span); |
559 this.popupResponse.appendChild(hold); | 570 this.popupResponse.appendChild(hold); |
560 if (input.id == node.response.name) { | 571 if (input.id == node.response.name) { |
561 input.checked = "true"; | 572 input.checked = "true"; |
562 } | 573 } |
563 } | 574 var w = $(span).width(); |
575 if (w > max_w) | |
576 max_w = w; | |
577 } | |
578 max_w += 12; | |
579 this.popupResponse.style.textAlign=""; | |
580 var leftP = ((max_w/500)/2)*100; | |
581 this.popupResponse.style.left=leftP+"%"; | |
564 } else if (node.specification.type == 'number') { | 582 } else if (node.specification.type == 'number') { |
565 var input = document.createElement('input'); | 583 var input = document.createElement('input'); |
566 input.type = 'textarea'; | 584 input.type = 'textarea'; |
567 if (node.min != null) {input.min = node.specification.min;} | 585 if (node.min != null) {input.min = node.specification.min;} |
568 if (node.max != null) {input.max = node.specification.max;} | 586 if (node.max != null) {input.max = node.specification.max;} |
569 if (node.step != null) {input.step = node.specification.step;} | 587 if (node.step != null) {input.step = node.specification.step;} |
570 if (node.response != undefined) { | 588 if (node.response != undefined) { |
571 input.value = node.response; | 589 input.value = node.response; |
572 } | 590 } |
573 this.popupResponse.appendChild(input); | 591 this.popupResponse.appendChild(input); |
592 this.popupResponse.style.textAlign="center"; | |
593 this.popupResponse.style.left="0%"; | |
574 } | 594 } |
575 if(this.currentIndex+1 == this.popupOptions.length) { | 595 if(this.currentIndex+1 == this.popupOptions.length) { |
576 if (this.node.location == "pre") { | 596 if (this.node.location == "pre") { |
577 this.buttonProceed.textContent = 'Start'; | 597 this.buttonProceed.textContent = 'Start'; |
578 } else { | 598 } else { |