comparison test_create/test_core.js @ 1385:bc75c4180b4d

Test create has scale manipulation
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 17 Feb 2016 11:11:50 +0000
parents 320724a2389b
children 0f758a5efa95 a4ad9e55b5b8
comparison
equal deleted inserted replaced
1384:7cd2a8dcdc51 1385:bc75c4180b4d
805 this.parent.build(); 805 this.parent.build();
806 } 806 }
807 popupObject.hide(); 807 popupObject.hide();
808 } 808 }
809 } 809 }
810 this.state[6] = new function() {
811 this.title = "Edit Scale Markers";
812 this.content = document.createElement("div");
813 this.content.id = "state-6";
814 var spnH = document.createElement('div');
815 var span = document.createElement("span");
816 span.textContent = "You can edit your scale markers here for the selected interface.";
817 spnH.appendChild(span);
818 this.scaleRoot;
819 this.parent;
820 this.markerNodes =[];
821 this.preset = {
822 input: document.createElement("select"),
823 parent: this,
824 handleEvent: function(event) {
825 this.parent.scaleRoot.scales = [];
826 var protoScale = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getAllElementsByName(event.currentTarget.value)[0];
827 var protoMarkers = protoScale.children;
828 for (var i=0; i<protoMarkers.length; i++)
829 {
830 var marker = {
831 position: protoMarkers[i].getAttribute("position"),
832 text: protoMarkers[i].textContent
833 }
834 this.parent.scaleRoot.scales.push(marker);
835 }
836 this.parent.buildMarkerList();
837 }
838 }
839 this.preset.input.addEventListener("change",this.preset);
840 this.content.appendChild(this.preset.input);
841 var optionHolder = document.createElement("div");
842 optionHolder.className = 'node';
843 optionHolder.id = 'popup-option-holder';
844 this.content.appendChild(optionHolder);
845 this.generate = function(scaleRoot,parent)
846 {
847 this.scaleRoot = scaleRoot;
848 this.parent = parent;
849
850 // Generate Pre-Set dropdown
851 var protoScales = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].children;
852 this.preset.input.innerHTML = "";
853
854 for (var i=0; i<protoScales.length; i++)
855 {
856 var selectOption = document.createElement("option");
857 var scaleName = protoScales[i].getAttribute("name");
858 selectOption.setAttribute("name",scaleName);
859 selectOption.textContent = scaleName;
860 this.preset.input.appendChild(selectOption);
861 }
862
863 // Create Marker List
864 this.buildMarkerList();
865 }
866 this.buildMarkerList = function() {
867 var markerInject = document.getElementById("popup-option-holder");
868 markerInject.innerHTML = "";
869 this.markerNodes = [];
870 for (var i=0; i<this.scaleRoot.scales.length; i++)
871 {
872 var markerNode = {};
873 markerNode.root = document.createElement("div");
874 markerNode.root.className = "popup-option-entry";
875 markerNode.positionInput = document.createElement("input");
876 markerNode.positionInput.min = 0;
877 markerNode.positionInput.max = 100;
878 markerNode.positionInput.value = this.scaleRoot.scales[i].position;
879 markerNode.positionInput.setAttribute("name","position");
880 markerNode.textInput = document.createElement("input");
881 markerNode.textInput.setAttribute("name","text");
882 markerNode.textInput.value = this.scaleRoot.scales[i].text;
883 markerNode.specification = this.scaleRoot.scales[i];
884 markerNode.parent = this;
885 markerNode.handleEvent = function(event) {
886 switch(event.currentTarget.getAttribute("name"))
887 {
888 case "position":
889 this.specification.position = Number(event.currentTarget.value);
890 break;
891 case "text":
892 this.specification.text = event.currentTarget.value;
893 break;
894 }
895 }
896 markerNode.positionInput.addEventListener("change",markerNode,false);
897 markerNode.textInput.addEventListener("change",markerNode,false);
898
899 var posText = document.createElement("span");
900 posText.textContent = "Position: ";
901 var textText = document.createElement("span");
902 textText.textContent = "Text: ";
903 markerNode.root.appendChild(posText);
904 markerNode.root.appendChild(markerNode.positionInput);
905 markerNode.root.appendChild(textText);
906 markerNode.root.appendChild(markerNode.textInput);
907 markerInject.appendChild(markerNode.root);
908 this.markerNodes.push(markerNode);
909
910 }
911 }
912 this.continue = function()
913 {
914 popupObject.hide();
915 }
916 }
810 } 917 }
811 } 918 }
812 919
813 function SpecificationToHTML() 920 function SpecificationToHTML()
814 { 921 {
1321 { 1428 {
1322 } else { 1429 } else {
1323 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]); 1430 var nameAttr = this.parent.convertAttributeToDOM(this,specification.schema.getAllElementsByName("name")[0]);
1324 this.attributeDOM.appendChild(nameAttr.holder); 1431 this.attributeDOM.appendChild(nameAttr.holder);
1325 this.attributes.push(nameAttr); 1432 this.attributes.push(nameAttr);
1433 var scales = new this.scalesNode(this,this.specification);
1434 this.children.push(scales);
1435 this.childrenDOM.appendChild(scales.rootDOM);
1326 } 1436 }
1327 if (parent != undefined) 1437 if (parent != undefined)
1328 { 1438 {
1329 parent.appendChild(this.rootDOM); 1439 parent.appendChild(this.rootDOM);
1330 } 1440 }
1441 }
1442
1443 this.scalesNode = function(parent,rootObject)
1444 {
1445 this.type = "scalesNode";
1446 this.rootDOM = document.createElement("div");
1447 this.titleDOM = document.createElement("span");
1448 this.attributeDOM = document.createElement("div");
1449 this.attributes = [];
1450 this.childrenDOM = document.createElement("div");
1451 this.children = [];
1452 this.buttonDOM = document.createElement("div");
1453 this.parent = parent;
1454 this.specification = rootObject;
1455 this.schema = specification.schema.getAllElementsByName("page")[0];
1456 this.rootDOM.className = "node";
1457
1458 var titleDiv = document.createElement('div');
1459 titleDiv.className = "node-title";
1460 this.titleDOM.className = "node-title";
1461 this.titleDOM.textContent = "Interface Scales";
1462 titleDiv.appendChild(this.titleDOM);
1463
1464 this.attributeDOM.className = "node-attributes";
1465 this.childrenDOM.className = "node-children";
1466 this.buttonDOM.className = "node-buttons";
1467
1468 this.rootDOM.appendChild(titleDiv);
1469 this.rootDOM.appendChild(this.attributeDOM);
1470 this.rootDOM.appendChild(this.childrenDOM);
1471 this.rootDOM.appendChild(this.buttonDOM);
1472
1473 this.editButton = {
1474 button: document.createElement("button"),
1475 parent: this,
1476 handleEvent: function(event) {
1477 popupObject.show();
1478 popupObject.postNode(popupStateNodes.state[6]);
1479 popupStateNodes.state[6].generate(this.parent.specification,this.parent);
1480 }
1481 };
1482 this.editButton.button.textContent = "Edit Scales/Markers";
1483 this.editButton.button.addEventListener("click",this.editButton,false);
1484 this.buttonDOM.appendChild(this.editButton.button);
1331 } 1485 }
1332 } 1486 }
1333 1487
1334 this.surveyNode = function(parent,rootObject,location) 1488 this.surveyNode = function(parent,rootObject,location)
1335 { 1489 {