aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tools
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tools')
-rwxr-xr-xnode_modules/tools/package.json14
-rwxr-xr-x[-rw-r--r--]node_modules/tools/template/template-creator.js (renamed from node_modules/tools/template-creator.js)58
2 files changed, 46 insertions, 26 deletions
diff --git a/node_modules/tools/package.json b/node_modules/tools/package.json
new file mode 100755
index 00000000..5d830af3
--- /dev/null
+++ b/node_modules/tools/package.json
@@ -0,0 +1,14 @@
1
2{
3 "name": "tools",
4 "version": "0.1.0",
5 "description": "Montage Tools",
6 "main": "tools",
7 "mappings": {
8 "montage" : "../montage/"
9 },
10 "dependency": {
11 "montage" : "0.8"
12 }
13
14} \ No newline at end of file
diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template/template-creator.js
index e312cd32..c5d3cffd 100644..100755
--- a/node_modules/tools/template-creator.js
+++ b/node_modules/tools/template/template-creator.js
@@ -23,39 +23,41 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
23 return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); 23 return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath);
24 } 24 }
25 }, 25 },
26 26
27 initWithBodyElement: { 27 initWithBodyElement: {
28 value: function(body, montageJsPath) { 28 value: function(body, montageJsPath) {
29 return this.initWithHeadAndBodyElements(null, body, montageJsPath); 29 return this.initWithHeadAndBodyElements(null, body, montageJsPath);
30 } 30 }
31 }, 31 },
32 32
33 initWithHeadAndBodyElements: { 33 initWithHeadAndBodyElements: {
34 value: function(head, body, components, montageJsPath) { 34 value: function(head, body, montageJsPath) {
35 var serializer = this.serializer, 35 var serializer = this.serializer,
36 objects = {}, 36 objects = {},
37 //components = {}, 37 components = {},
38 componentsChildComponents = {},
38 doc, 39 doc,
39 script, 40 script,
40 self = this; 41 self = this;
41 42
43 this._componentNamesIndex = {};
42 this._objectNamesIndex = {}; 44 this._objectNamesIndex = {};
43 //doc = this._document = document.implementation.createHTMLDocument(""); 45 doc = this._document = document.implementation.createHTMLDocument("");
44 46
45 /* 47 function copyNode(sourceNode, targetNode, isRootNode) {
46function copyNode(sourceNode, targetNode, isRootNode) {
47 var childNodes = sourceNode.childNodes, 48 var childNodes = sourceNode.childNodes,
48 childNode, 49 childNode,
49 targetChildNode, 50 targetChildNode,
50 label, 51 label,
51 script, 52 script,
52 component = isRootNode ? null : sourceNode.controller; 53 component = isRootNode ? null : sourceNode.controller;
53 54
54 if (component) { 55 if (component) {
55 label = self._generateLabelForComponent(component); 56 label = self._generateLabelForComponent(component, Object.keys(components));
56 targetNode.setAttribute("id", label);
57 component._element = targetNode; 57 component._element = targetNode;
58 //components[label] = component; 58 components[label] = component;
59 componentsChildComponents[label] = component.childComponents;
60 delete component.childComponents;
59 } else { 61 } else {
60 for (var i = 0; (childNode = childNodes[i]); i++) { 62 for (var i = 0; (childNode = childNodes[i]); i++) {
61 targetChildNode = targetNode.appendChild(childNode.cloneNode(false)); 63 targetChildNode = targetNode.appendChild(childNode.cloneNode(false));
@@ -63,10 +65,8 @@ function copyNode(sourceNode, targetNode, isRootNode) {
63 } 65 }
64 } 66 }
65 } 67 }
66*/ 68
67 69 if (head) {
68 /*
69if (head) {
70 doc.head.innerHTML = head.innerHTML; 70 doc.head.innerHTML = head.innerHTML;
71 } 71 }
72 if (montageJsPath) { 72 if (montageJsPath) {
@@ -75,7 +75,7 @@ if (head) {
75 doc.head.appendChild(script); 75 doc.head.appendChild(script);
76 doc.head.insertBefore(doc.createTextNode("\n "), script); 76 doc.head.insertBefore(doc.createTextNode("\n "), script);
77 } 77 }
78 78
79 // try to make things look nice... 79 // try to make things look nice...
80 var html = doc.documentElement; 80 var html = doc.documentElement;
81 html.insertBefore(doc.createTextNode("\n"), doc.head); 81 html.insertBefore(doc.createTextNode("\n"), doc.head);
@@ -85,21 +85,24 @@ if (head) {
85 // the first child is the title 85 // the first child is the title
86 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild); 86 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild);
87 } 87 }
88*/ 88
89 89 copyNode(body, this._document.body, true);
90 //copyNode(body, this._document.body, true);
91 this._ownerSerialization = serializer.serialize(components); 90 this._ownerSerialization = serializer.serialize(components);
91 for (var label in components) {
92 components[label].childComponents = componentsChildComponents[label];
93 }
94 components = componentsChildComponents = null;
92 this._externalObjects = serializer.getExternalObjects(); 95 this._externalObjects = serializer.getExternalObjects();
93 96
94 return this; 97 return this;
95 } 98 }
96 }, 99 },
97 100
98 _componentNamesIndex: { 101 _componentNamesIndex: {
99 value: null 102 value: null
100 }, 103 },
101 104
102 _generateLabelForComponent: {value: function(component) { 105 _generateLabelForComponent: {value: function(component, labels) {
103 var componentInfo = Montage.getInfoForObject(component), 106 var componentInfo = Montage.getInfoForObject(component),
104 componentLabel = componentInfo.label, 107 componentLabel = componentInfo.label,
105 componentName, 108 componentName,
@@ -109,8 +112,11 @@ if (head) {
109 return componentLabel; 112 return componentLabel;
110 } else { 113 } else {
111 componentName = componentInfo.objectName.toLowerCase(); 114 componentName = componentInfo.objectName.toLowerCase();
112 index = this._componentNamesIndex[componentName] || 1; 115 do {
113 this._componentNamesIndex[componentName] = index + 1; 116 index = this._componentNamesIndex[componentName] || 1;
117 this._componentNamesIndex[componentName] = index + 1;
118 } while (labels.indexOf(componentName+index) >= 0);
119
114 return componentName + index; 120 return componentName + index;
115 } 121 }
116 }}, 122 }},