aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tools/template
diff options
context:
space:
mode:
authorKruti Shah2012-07-17 12:40:00 -0700
committerKruti Shah2012-07-17 12:40:00 -0700
commitbf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /node_modules/tools/template
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'node_modules/tools/template')
-rwxr-xr-xnode_modules/tools/template/template-creator.js43
1 files changed, 22 insertions, 21 deletions
diff --git a/node_modules/tools/template/template-creator.js b/node_modules/tools/template/template-creator.js
index 9951fb02..92633343 100755
--- a/node_modules/tools/template/template-creator.js
+++ b/node_modules/tools/template/template-creator.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -47,13 +48,13 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
47 return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); 48 return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath);
48 } 49 }
49 }, 50 },
50 51
51 initWithBodyElement: { 52 initWithBodyElement: {
52 value: function(body, montageJsPath) { 53 value: function(body, montageJsPath) {
53 return this.initWithHeadAndBodyElements(null, body, montageJsPath); 54 return this.initWithHeadAndBodyElements(null, body, montageJsPath);
54 } 55 }
55 }, 56 },
56 57
57 initWithHeadAndBodyElements: { 58 initWithHeadAndBodyElements: {
58 value: function(head, body, montageJsPath) { 59 value: function(head, body, montageJsPath) {
59 var serializer = this.serializer, 60 var serializer = this.serializer,
@@ -64,11 +65,11 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
64 doc, 65 doc,
65 script, 66 script,
66 self = this; 67 self = this;
67 68
68 this._componentNamesIndex = {}; 69 this._componentNamesIndex = {};
69 this._objectNamesIndex = {}; 70 this._objectNamesIndex = {};
70 doc = this._document = document.implementation.createHTMLDocument(""); 71 doc = this._document = document.implementation.createHTMLDocument("");
71 72
72 function copyNode(sourceNode, targetNode, isRootNode) { 73 function copyNode(sourceNode, targetNode, isRootNode) {
73 var childNodes = sourceNode.childNodes, 74 var childNodes = sourceNode.childNodes,
74 childNode, 75 childNode,
@@ -76,7 +77,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
76 label, 77 label,
77 script, 78 script,
78 component = isRootNode ? null : sourceNode.controller; 79 component = isRootNode ? null : sourceNode.controller;
79 80
80 if (component) { 81 if (component) {
81 label = self._generateLabelForComponent(component, Object.keys(components)); 82 label = self._generateLabelForComponent(component, Object.keys(components));
82 componentsElements[label] = component._element; 83 componentsElements[label] = component._element;
@@ -92,7 +93,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
92 } 93 }
93 } 94 }
94 } 95 }
95 96
96 if (head) { 97 if (head) {
97 doc.head.innerHTML = head.innerHTML; 98 doc.head.innerHTML = head.innerHTML;
98 } 99 }
@@ -102,7 +103,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
102 doc.head.appendChild(script); 103 doc.head.appendChild(script);
103 doc.head.insertBefore(doc.createTextNode("\n "), script); 104 doc.head.insertBefore(doc.createTextNode("\n "), script);
104 } 105 }
105 106
106 // try to make things look nice... 107 // try to make things look nice...
107 var html = doc.documentElement; 108 var html = doc.documentElement;
108 html.insertBefore(doc.createTextNode("\n"), doc.head); 109 html.insertBefore(doc.createTextNode("\n"), doc.head);
@@ -112,7 +113,7 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
112 // the first child is the title 113 // the first child is the title
113 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild); 114 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild);
114 } 115 }
115 116
116 copyNode(body, this._document.body, true); 117 copyNode(body, this._document.body, true);
117 this._ownerSerialization = serializer.serialize(components); 118 this._ownerSerialization = serializer.serialize(components);
118 for (var label in components) { 119 for (var label in components) {
@@ -121,11 +122,11 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le
121 } 122 }
122 components = componentsChildComponents = null; 123 components = componentsChildComponents = null;
123 this._externalObjects = serializer.getExternalObjects(); 124 this._externalObjects = serializer.getExternalObjects();
124 125
125 return this; 126 return this;
126 } 127 }
127 }, 128 },
128 129
129 _componentNamesIndex: { 130 _componentNamesIndex: {
130 value: null 131 value: null
131 }, 132 },