diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js (renamed from js/io/document/document-controller.js) | 112 | ||||
-rwxr-xr-x | js/io/document/html-document.js | 84 | ||||
-rwxr-xr-x | js/io/ui/cloudpopup.reel/cloudpopup.js | 3 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.html | 2 |
4 files changed, 100 insertions, 101 deletions
diff --git a/js/io/document/document-controller.js b/js/controllers/document-controller.js index c2a2dab6..22467b44 100755 --- a/js/io/document/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -4,21 +4,17 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /** | 7 | //////////////////////////////////////////////////////////////////////// |
8 | @module js/document/documentManager | 8 | // |
9 | @requires montage/core/core | 9 | var Montage = require("montage/core/core").Montage, |
10 | @requires montage/ui/component | 10 | Component = require("montage/ui/component").Component, |
11 | @requires js/document/html-document | 11 | Uuid = require("montage/core/uuid").Uuid, |
12 | @requires js/document/text-document | 12 | HTMLDocument = require("js/io/document/html-document").HTMLDocument, |
13 | */ | 13 | TextDocument = require("js/io/document/text-document").TextDocument, |
14 | 14 | DocumentController; | |
15 | var Montage = require("montage/core/core").Montage, | 15 | //////////////////////////////////////////////////////////////////////// |
16 | Component = require("montage/ui/component").Component, | 16 | // |
17 | Uuid = require("montage/core/uuid").Uuid, | 17 | DocumentController = exports.DocumentController = Montage.create(Component, { |
18 | HTMLDocument = require("js/io/document/html-document").HTMLDocument, | ||
19 | TextDocument = require("js/io/document/text-document").TextDocument; | ||
20 | |||
21 | var DocumentController = exports.DocumentController = Montage.create(Component, { | ||
22 | hasTemplate: { | 18 | hasTemplate: { |
23 | value: false | 19 | value: false |
24 | }, | 20 | }, |
@@ -152,67 +148,52 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
152 | } | 148 | } |
153 | }, | 149 | }, |
154 | 150 | ||
155 | /** | 151 | //////////////////////////////////////////////////////////////////// |
156 | * Public method | 152 | // |
157 | */ | ||
158 | openFileCallback:{ | 153 | openFileCallback:{ |
159 | value:function(response){ | 154 | value:function(response){ |
160 | //Return Object Description | 155 | //TODO: Add UI to handle error codes, shouldn't be alert windows |
161 | // Object.status (Always presents for handling) | 156 | if(!!response && (response.status === 204)) { |
162 | // 204: File exists (Success) | 157 | //Sending full response object |
163 | // 404: File does not exists (Failure) | 158 | this.openDocument(response); |
164 | // 500: Unknown (Probably cloud API not running) | 159 | } else if (!!response && (response.status === 404)){ |
165 | // | ||
166 | // (Below only present if succesfull 204) | ||
167 | // | ||
168 | // Object.content | ||
169 | // Object.extension | ||
170 | // Object.name | ||
171 | // Object.uri | ||
172 | // Object.creationDate | ||
173 | // Object.modifiedDate | ||
174 | // Object.readOnly | ||
175 | // Object.size | ||
176 | |||
177 | var fileDetails = {}; | ||
178 | if(!!response && (response.status === 204)){ | ||
179 | /** | ||
180 | * fileDetails format: | ||
181 | * {"type": "js", "name": "test", "source": fileContent, "uri": uri} | ||
182 | */ | ||
183 | fileDetails.type = response.extension; | ||
184 | fileDetails.source = response.content; | ||
185 | fileDetails.name = response.name; | ||
186 | fileDetails.uri = response.uri; | ||
187 | |||
188 | this.openDocument(fileDetails); | ||
189 | }else if(!!response && (response.status === 404)){ | ||
190 | alert("Unable to open file.\n [Error: File does not exist]"); | 160 | alert("Unable to open file.\n [Error: File does not exist]"); |
191 | }else if(!!response && (response.status === 500)){ | 161 | } else if (!!response && (response.status === 500)){ |
192 | alert("Unable to open file.\n Check if Ninja Local Cloud is running."); | 162 | alert("Unable to open file.\n Check if Ninja Local Cloud is running."); |
193 | }else{ | 163 | } else{ |
194 | alert("Unable to open file."); | 164 | alert("Unable to open file."); |
195 | } | 165 | } |
196 | 166 | ||
197 | } | 167 | } |
198 | }, | 168 | }, |
199 | 169 | //////////////////////////////////////////////////////////////////// | |
200 | openProjectWithURI: { | 170 | // |
201 | value: function(uri) { | 171 | openDocument: { |
202 | console.log("URI is: ", uri); | 172 | value: function(doc) { |
203 | 173 | // | |
204 | } | 174 | switch (doc.extension) { |
205 | }, | 175 | case 'html': case 'html': |
206 | 176 | //Open in designer view | |
207 | /** Open a Document **/ | 177 | Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); |
208 | openDocument: { | 178 | break; |
209 | value: function(doc) { | 179 | default: |
180 | //Open in code view | ||
181 | break; | ||
182 | } | ||
183 | |||
184 | return; | ||
185 | |||
186 | |||
187 | |||
188 | |||
189 | |||
210 | var newDoc; | 190 | var newDoc; |
211 | 191 | ||
212 | if(!doc) return false; | 192 | if(!doc) return false; |
213 | 193 | ||
214 | // try { | 194 | // try { |
215 | if (doc.type === 'html' || doc.type === 'htm') { | 195 | if (doc.type === 'html' || doc.type === 'htm') { |
196 | console.log('hello'); | ||
216 | newDoc = Montage.create(HTMLDocument); | 197 | newDoc = Montage.create(HTMLDocument); |
217 | newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); | 198 | newDoc.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); |
218 | } else { | 199 | } else { |
@@ -235,7 +216,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
235 | // } | 216 | // } |
236 | } | 217 | } |
237 | }, | 218 | }, |
238 | 219 | //////////////////////////////////////////////////////////////////// | |
220 | |||
221 | openProjectWithURI: { | ||
222 | value: function(uri) { | ||
223 | console.log("URI is: ", uri); | ||
224 | } | ||
225 | }, | ||
226 | |||
239 | textDocumentOpened: { | 227 | textDocumentOpened: { |
240 | value: function(doc) { | 228 | value: function(doc) { |
241 | 229 | ||
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index d51cd279..fbb34a1d 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -11,7 +11,7 @@ var Montage = require("montage/core/core").Montage, | |||
11 | var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.BaseDocument, { | 11 | var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.BaseDocument, { |
12 | // PRIVATE MEMBERS | 12 | // PRIVATE MEMBERS |
13 | _selectionExclude: { value: null, enumerable: false }, | 13 | _selectionExclude: { value: null, enumerable: false }, |
14 | _cloudTemplateUri: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, | 14 | _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, |
15 | _iframe: { value: null, enumerable: false }, | 15 | _iframe: { value: null, enumerable: false }, |
16 | _server: { value: null, enumerable: false }, | 16 | _server: { value: null, enumerable: false }, |
17 | _selectionModel: { value: [], enumerable: false }, | 17 | _selectionModel: { value: [], enumerable: false }, |
@@ -24,7 +24,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
24 | _styles: { value: null, enumerable: false }, | 24 | _styles: { value: null, enumerable: false }, |
25 | _stylesheets: { value: null, enumerable: false }, | 25 | _stylesheets: { value: null, enumerable: false }, |
26 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, | 26 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, |
27 | _initialUserDocument: { value: null, enumerable: false }, | 27 | _userDocument: { value: null, enumerable: false }, |
28 | _htmlSource: {value: "<html></html>", enumerable: false}, | 28 | _htmlSource: {value: "<html></html>", enumerable: false}, |
29 | _glData: {value: null, enumerable: false }, | 29 | _glData: {value: null, enumerable: false }, |
30 | 30 | ||
@@ -218,30 +218,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
218 | 218 | ||
219 | //****************************************// | 219 | //****************************************// |
220 | // PUBLIC METHODS | 220 | // PUBLIC METHODS |
221 | initialize: { | 221 | |
222 | value: function(doc, uuid, iframe, callback) { | 222 | |
223 | // Shell mode is not used anymore | 223 | //////////////////////////////////////////////////////////////////// |
224 | //if(!window.IsInShellMode()) { | 224 | // |
225 | if(!doc.name){doc.name = "index-cloud"}; | 225 | initialize: { |
226 | if(!doc.uri){doc.uri = this._cloudTemplateUri}; | 226 | value: function(file, uuid, iframe, callback) { |
227 | this.init(doc.name, doc.uri, doc.type, iframe, uuid, callback); | 227 | // |
228 | /* | 228 | this._userDocument = file; |
229 | } else { | 229 | // |
230 | var tmpurl = doc.uri.split('\\'); | 230 | this.init(file.name, file.uri, file.extension, iframe, uuid, callback); |
231 | var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html"; | 231 | // |
232 | this.init(name, fileUrl, doc.type, iframe, uuid, callback); | 232 | this.iframe = iframe; |
233 | this.server = doc.server; | 233 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; |
234 | this._initialUserDocument = doc; | 234 | this.currentView = "design"; |
235 | } | 235 | // |
236 | */ | 236 | this.iframe.src = this._htmlTemplateUrl; |
237 | this.iframe = iframe; | 237 | this.iframe.addEventListener("load", this, true); |
238 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; | ||
239 | this.currentView = "design"; | ||
240 | |||
241 | this._loadDocument(this.uri); | ||
242 | |||
243 | } | 238 | } |
244 | }, | 239 | }, |
240 | //////////////////////////////////////////////////////////////////// | ||
241 | |||
245 | 242 | ||
246 | collectGLData: { | 243 | collectGLData: { |
247 | value: function( elt, dataArray ) |