diff options
Diffstat (limited to 'node_modules/tools/template-creator.js')
-rw-r--r-- | node_modules/tools/template-creator.js | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template-creator.js deleted file mode 100644 index e312cd32..00000000 --- a/node_modules/tools/template-creator.js +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/tools/template/template-creator | ||
8 | @requires montage/ui/template | ||
9 | */ | ||
10 | |||
11 | exports = typeof exports !== "undefined" ? exports : {}; | ||
12 | |||
13 | var Montage = require("montage/core/core").Montage; | ||
14 | var Template = require("montage/ui/template").Template; | ||
15 | |||
16 | /** | ||
17 | @class module:montage/tools/template/template-creator.TemplateCreator | ||
18 | @extends module:montage/ui/template.Template | ||
19 | */ | ||
20 | var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @lends module:montage/tools/template/template-creator.TemplateCreator# */ { | ||
21 | initWithDocument: { | ||
22 | value: function(doc, montageJsPath) { | ||
23 | return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); | ||
24 | } | ||
25 | }, | ||
26 | |||
27 | initWithBodyElement: { | ||
28 | value: function(body, montageJsPath) { | ||
29 | return this.initWithHeadAndBodyElements(null, body, montageJsPath); | ||
30 | } | ||
31 | }, | ||
32 | |||
33 | initWithHeadAndBodyElements: { | ||
34 | value: function(head, body, components, montageJsPath) { | ||
35 | var serializer = this.serializer, | ||
36 | objects = {}, | ||
37 | //components = {}, | ||
38 | doc, | ||
39 | script, | ||
40 | self = this; | ||
41 | |||
42 | this._objectNamesIndex = {}; | ||
43 | //doc = this._document = document.implementation.createHTMLDocument(""); | ||
44 | |||
45 | /* | ||
46 | function copyNode(sourceNode, targetNode, isRootNode) { | ||
47 | var childNodes = sourceNode.childNodes, | ||
48 | childNode, | ||
49 | targetChildNode, | ||
50 | label, | ||
51 | script, | ||
52 | component = isRootNode ? null : sourceNode.controller; | ||
53 | |||
54 | if (component) { | ||
55 | label = self._generateLabelForComponent(component); | ||
56 | targetNode.setAttribute("id", label); | ||
57 | component._element = targetNode; | ||
58 | //components[label] = component; | ||
59 | } else { | ||
60 | for (var i = 0; (childNode = childNodes[i]); i++) { | ||
61 | targetChildNode = targetNode.appendChild(childNode.cloneNode(false)); | ||
62 | copyNode(childNode, targetChildNode); | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | */ | ||
67 | |||
68 | /* | ||
69 | if (head) { | ||
70 | doc.head.innerHTML = head.innerHTML; | ||
71 | } | ||
72 | if (montageJsPath) { | ||
73 | script = doc.createElement("script"); | ||
74 | script.setAttribute("src", montageJsPath); | ||
75 | doc.head.appendChild(script); | ||
76 | doc.head.insertBefore(doc.createTextNode("\n "), script); | ||
77 | } | ||
78 | |||
79 | // try to make things look nice... | ||
80 | var html = doc.documentElement; | ||
81 | html.insertBefore(doc.createTextNode("\n"), doc.head); | ||
82 | html.insertBefore(doc.createTextNode("\n"), doc.body); | ||
83 | html.appendChild(doc.createTextNode("\n")); | ||
84 | if (!head) { | ||
85 | // the first child is the title | ||
86 | doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild); | ||
87 | } | ||
88 | */ | ||
89 | |||
90 | //copyNode(body, this._document.body, true); | ||
91 | this._ownerSerialization = serializer.serialize(components); | ||
92 | this._externalObjects = serializer.getExternalObjects(); | ||
93 | |||
94 | return this; | ||
95 | } | ||
96 | }, | ||
97 | |||
98 | _componentNamesIndex: { | ||
99 | value: null | ||
100 | }, | ||
101 | |||
102 | _generateLabelForComponent: {value: function(component) { | ||
103 | var componentInfo = Montage.getInfoForObject(component), | ||
104 | componentLabel = componentInfo.label, | ||
105 | componentName, | ||
106 | index; | ||
107 | |||
108 | if (componentLabel) { | ||
109 | return componentLabel; | ||
110 | } else { | ||
111 | componentName = componentInfo.objectName.toLowerCase(); | ||
112 | index = this._componentNamesIndex[componentName] || 1; | ||
113 | this._componentNamesIndex[componentName] = index + 1; | ||
114 | return componentName + index; | ||
115 | } | ||
116 | }}, | ||
117 | }); \ No newline at end of file | ||