aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tools
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-03-18 12:34:29 -0700
committerJose Antonio Marquez2012-03-18 12:34:29 -0700
commitfda7b595c96d99177fdd93de8da9030348a3f8fb (patch)
treeee4c787e3ab4312835e95a83bdf94f52fadee52f /node_modules/tools
parent954f5a13e371febcb1c0fb8015c577ee51c23130 (diff)
downloadninja-fda7b595c96d99177fdd93de8da9030348a3f8fb.tar.gz
Temp I/O functionality for M-JS components
Added the ability to save montages component serialization from Ninja. Very rough, but functional.
Diffstat (limited to 'node_modules/tools')
-rw-r--r--node_modules/tools/template-creator.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template-creator.js
index 6b50cc1e..ba4cdc7a 100644
--- a/node_modules/tools/template-creator.js
+++ b/node_modules/tools/template-creator.js
@@ -31,10 +31,10 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
31 }, 31 },
32 32
33 initWithHeadAndBodyElements: { 33 initWithHeadAndBodyElements: {
34 value: function(head, body, montageJsPath) { 34 value: function(head, body, components, montageJsPath) {
35 var serializer = this.serializer, 35 var serializer = this.serializer,
36 objects = {}, 36 objects = {},
37 components = {}, 37 //components = {},
38 doc, 38 doc,
39 script, 39 script,
40 self = this; 40 self = this;
@@ -42,7 +42,8 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
42 this._objectNamesIndex = {}; 42 this._objectNamesIndex = {};
43 doc = this._document = document.implementation.createHTMLDocument(""); 43 doc = this._document = document.implementation.createHTMLDocument("");
44 44
45 function copyNode(sourceNode, targetNode, isRootNode) { 45 /*
46function copyNode(sourceNode, targetNode, isRootNode) {
46 var childNodes = sourceNode.childNodes, 47 var childNodes = sourceNode.childNodes,
47 childNode, 48 childNode,
48 targetChildNode, 49 targetChildNode,
@@ -54,7 +55,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
54 label = self._generateLabelForComponent(component); 55 label = self._generateLabelForComponent(component);
55 targetNode.setAttribute("id", label); 56 targetNode.setAttribute("id", label);
56 component._element = targetNode; 57 component._element = targetNode;
57 components[label] = component; 58 //components[label] = component;
58 } else { 59 } else {
59 for (var i = 0; (childNode = childNodes[i]); i++) { 60 for (var i = 0; (childNode = childNodes[i]); i++) {
60 targetChildNode = targetNode.appendChild(childNode.cloneNode(false)); 61 targetChildNode = targetNode.appendChild(childNode.cloneNode(false));
@@ -62,6 +63,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
62 } 63 }
63 } 64 }
64 } 65 }
66*/
65 67
66 if (head) { 68 if (head) {
67 doc.head.innerHTML = head.innerHTML; 69 doc.head.innerHTML = head.innerHTML;
@@ -83,7 +85,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
83 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild); 85 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild);
84 } 86 }
85 87
86 copyNode(body, this._document.body, true); 88 //copyNode(body, this._document.body, true);
87 this._ownerSerialization = serializer.serialize(components); 89 this._ownerSerialization = serializer.serialize(components);
88 this._externalObjects = serializer.getExternalObjects(); 90 this._externalObjects = serializer.getExternalObjects();
89 91