changeset 1374:efbd764e1d60

Test create drag and drop active. Auto-builds on page HTML from specification.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 11 Feb 2016 12:06:54 +0000
parents 65eecc71c381
children 1350a66ae142
files test_create/style.css test_create/test_core.js
diffstat 2 files changed, 46 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test_create/style.css	Wed Feb 10 16:33:41 2016 +0000
+++ b/test_create/style.css	Thu Feb 11 12:06:54 2016 +0000
@@ -3,7 +3,7 @@
     background-color: rgba(0,0,0,0.5);
     width: 100%;
     height: 100%;
-    position: absolute;
+    position: fixed;
     left: 0px;
     top: 0px;
 }
@@ -13,7 +13,7 @@
     background-color: rgba(255,255,255,1);
     width: 730px;
     height: 480px;
-    position: absolute;
+    position: fixed;
     border-radius: 10px;
 	box-shadow: 0px 0px 50px #000;
     padding: 10px;
@@ -70,7 +70,7 @@
     padding: 10px;
     border: black 2px solid;
     border-radius: 10px;
-    margin: 25px;
+    margin: 10px;
     min-width: 92%;
 }
 div.node-title {
--- a/test_create/test_core.js	Wed Feb 10 16:33:41 2016 +0000
+++ b/test_create/test_core.js	Thu Feb 11 12:06:54 2016 +0000
@@ -199,7 +199,7 @@
             this.dragArea.id = "project-drop";
             this.content.appendChild(this.dragArea);
             
-            this.dragArea.addEventListener('dragenter',function(e){
+            this.dragArea.addEventListener('dragover',function(e){
                 e.stopPropagation();
                 e.preventDefault();
                 e.dataTransfer.dropEffect = 'copy';
@@ -218,7 +218,14 @@
                 e.preventDefault();
                 e.currentTarget.className = "drag-area drag-dropped";
                 var files = e.dataTransfer.files[0];
-                
+                var reader = new FileReader();
+                reader.onload = function(decoded) {
+                    var parse = new DOMParser();
+                    specification.decode(parse.parseFromString(decoded.target.result,'text/xml'));
+                    popupObject.hide();
+                    convert.convert(document.getElementById('content'));
+                }
+                reader.readAsText(files);
             });
             
 
@@ -988,6 +995,14 @@
         this.addPage.root.textContent = "Add Page";
         this.addPage.root.addEventListener("click",this.addPage,false);
         this.injectDOM.appendChild(this.addPage.root);
+        
+        // Build each page
+        for (var page of specification.pages)
+        {
+            var newPage = new this.pageNode(this,page);
+            this.injectDOM.appendChild(newPage.rootDOM);
+            this.pages.push(newPage);
+        }
     }
     
     this.interfaceNode = function(parent,rootObject)
@@ -1278,10 +1293,27 @@
                     this.rootDOM.removeChild(this.attributeDOM);
                     break;
                 case "question":
+                    this.titleDOM.textContent = "Question";
                     var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
-                    var mandatory = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("id")[0]);
+                    var mandatory = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("mandatory")[0]);
                     var boxsize = convert.convertAttributeToDOM(this.specification.mandatory,specification.schema.getAllElementsByName("boxsize")[0]);
+                    this.attributeDOM.appendChild(id.holder);
+                    this.attributes.push(id);
+                    this.attributeDOM.appendChild(mandatory.holder);
+                    this.attributes.push(mandatory);
+                    this.attributeDOM.appendChild(boxsize.holder);
+                    this.attributes.push(boxsize);
                     break;
+                case "checkbox":
+                    this.titleDOM.textContent = "Checkbox";
+                    var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
+                    this.attributeDOM.appendChild(id.holder);
+                    this.attributes.push(id);
+                case "radio":
+                    this.titleDOM.textContent = "Radio";
+                    var id = convert.convertAttributeToDOM(this.specification.id,specification.schema.getAllElementsByName("id")[0]);
+                    this.attributeDOM.appendChild(id.holder);
+                    this.attributes.push(id);
             }
             
             this.editNode = {
@@ -1543,6 +1575,14 @@
             
         }
         
+        // Build the components
+        for (var elements of this.specification.audioElements)
+        {
+            var audioElementDOM = new this.audioElementNode(this,elements);
+            this.children.push(audioElementDOM);
+            this.childrenDOM.appendChild(audioElementDOM.rootDOM);
+        }
+        
         this.addInterface = {
             root: document.createElement("button"),
             parent: this,