aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/document-controller.js6
-rwxr-xr-xjs/panels/Resizer.js5
-rw-r--r--node_modules/tools/template-creator.js113
3 files changed, 122 insertions, 2 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 02031922..64ff2c7e 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -195,7 +195,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
195 value:function(doc){ 195 value:function(doc){
196 var response = doc || null;//default just for testing 196 var response = doc || null;//default just for testing
197 if(!!response && response.success && (response.status!== 500) && !!response.uri){ 197 if(!!response && response.success && (response.status!== 500) && !!response.uri){
198
199 this.isNewFilePath = true;//path identifier flag
198 this.creatingNewFile = true;//flag for timeline to identify new file flow 200 this.creatingNewFile = true;//flag for timeline to identify new file flow
201
199 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this)); 202 this.application.ninja.ioMediator.fileOpen(response.uri, this.openFileCallback.bind(this));
200 }else if(!!response && !response.success){ 203 }else if(!!response && !response.success){
201 //Todo: restrict directory path to the sandbox, in the dialog itself 204 //Todo: restrict directory path to the sandbox, in the dialog itself
@@ -224,9 +227,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
224 //TODO: Add UI to handle error codes, shouldn't be alert windows 227 //TODO: Add UI to handle error codes, shouldn't be alert windows
225 if(!!response && (response.status === 204)) { 228 if(!!response && (response.status === 204)) {
226 229
227 if((typeof this.creatingNewFile === 'undefined') || (this.creatingNewFile !== true)){//not from new file flow 230 if((typeof this.isNewFilePath === 'undefined') || (this.isNewFilePath !== true)){//not from new file flow
228 this.creatingNewFile = false; 231 this.creatingNewFile = false;
229 } 232 }
233 this.isNewFilePath = false;//reset path identifier flag
230 234
231 //Sending full response object 235 //Sending full response object
232 this.openDocument(response); 236 this.openDocument(response);
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