aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Duran2012-02-28 13:36:34 -0800
committerJonathan Duran2012-02-28 13:36:34 -0800
commit538db48f38ad3d5d22e99c2881745fc916e7e8a2 (patch)
tree7698cff63feb319fab8b10c5dfb12288a9013bb2
parent1f1e6265c982f09a97271788b138e4c8f805fc7a (diff)
parent7c9291a5bab4abd849547f8878f6fb962fc88250 (diff)
downloadninja-538db48f38ad3d5d22e99c2881745fc916e7e8a2.tar.gz
Merge branch 'refs/heads/NINJAmaster' into Timeline
-rwxr-xr-xjs/panels/Resizer.js5
-rw-r--r--node_modules/tools/template-creator.js113
2 files changed, 117 insertions, 1 deletions
diff --git a/js/panels/Resizer.js b/js/panels/Resizer.js
index 60fdde4f..ca6ed062 100755
--- a/js/panels/Resizer.js
+++ b/js/panels/Resizer.js
@@ -135,10 +135,13 @@ exports.Resizer = Montage.create(Component, {
135 135
136 handleWebkitTransitionEnd: { 136 handleWebkitTransitionEnd: {
137 value: function() { 137 value: function() {
138
138 if(this.redrawStage) { 139 if(this.redrawStage) {
139 this.application.ninja.stage.resizeCanvases = true; 140 this.application.ninja.stage.resizeCanvases = true;
140 } 141 }
141 this.panel.removeEventListener("webkitTransitionEnd"); 142
143 this.panel.removeEventListener("webkitTransitionEnd", this, false);
144
142 } 145 }
143 }, 146 },
144 147
diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template-creator.js
new file mode 100644
index 00000000..6b50cc1e
--- /dev/null
+++ b/node_modules/tools/template-creator.js
@@ -0,0 +1,113 @@
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
11exports = typeof exports !== "undefined" ? exports : {};
12
13var Montage = require("montage/core/core").Montage;
14var 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*/
20var 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, 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 function copyNode(sourceNode, targetNode, isRootNode) {
46 var childNodes = sourceNode.childNodes,
47 childNode,
48 targetChildNode,
49 label,
50 script,
51 component = isRootNode ? null : sourceNode.controller;
52
53 if (component) {
54 label = self._generateLabelForComponent(component);
55 targetNode.setAttribute("id", label);
56 component._element = targetNode;
57 components[label] = component;
58 } else {
59 for (var i = 0; (childNode = childNodes[i]); i++) {
60 targetChildNode = targetNode.appendChild(childNode.cloneNode(false));
61 copyNode(childNode, targetChildNode);
62 }
63 }
64 }
65
66 if (head) {
67 doc.head.innerHTML = head.innerHTML;
68 }
69 if (montageJsPath) {
70 script = doc.createElement("script");
71 script.setAttribute("src", montageJsPath);
72 doc.head.appendChild(script);
73 doc.head.insertBefore(doc.createTextNode("\n "), script);
74 }
75
76 // try to make things look nice...
77 var html = doc.documentElement;
78 html.insertBefore(doc.createTextNode("\n"), doc.head);
79 html.insertBefore(doc.createTextNode("\n"), doc.body);
80 html.appendChild(doc.createTextNode("\n"));
81 if (!head) {
82 // the first child is the title
83 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild);
84 }
85
86 copyNode(body, this._document.body, true);
87 this._ownerSerialization = serializer.serialize(components);
88 this._externalObjects = serializer.getExternalObjects();
89
90 return this;
91 }
92 },
93
94 _componentNamesIndex: {
95 value: null
96 },
97
98 _generateLabelForComponent: {value: function(component) {
99 var componentInfo = Montage.getInfoForObject(component),
100 componentLabel = componentInfo.label,
101 componentName,
102 index;
103
104 if (componentLabel) {
105 return componentLabel;
106 } else {
107 componentName = componentInfo.objectName.toLowerCase();
108 index = this._componentNamesIndex[componentName] || 1;
109 this._componentNamesIndex[componentName] = index + 1;
110 return componentName + index;
111 }
112 }},
113}); \ No newline at end of file