diff options
author | Ananya Sen | 2012-02-10 16:03:52 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-10 16:03:52 -0800 |
commit | c48eeb01bd726895dc577d8b843b2a75883eee07 (patch) | |
tree | 5945556f80723285396059aaecb523e27b1cbb0d /js/io/document/html-document.js | |
parent | c627ebb5735d55218813b073c655dae6cded6040 (diff) | |
download | ninja-c48eeb01bd726895dc577d8b843b2a75883eee07.tar.gz |
Merge from /joseeight/ninja-internal/tree/FileIO
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/document/html-document.js')
-rwxr-xr-x | js/io/document/html-document.js | 84 |
1 files changed, 46 insertions, 38 deletions
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 ) | 244 | value: function( elt, dataArray ) |
@@ -345,7 +342,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
345 | } | 342 | } |
346 | }, | 343 | }, |
347 | 344 | ||
348 | // Private | 345 | /* |
346 | // Private | ||
349 | _loadDocument: { | 347 | _loadDocument: { |
350 | value: function(uri) { | 348 | value: function(uri) { |
351 | // Load the document into the Iframe | 349 | // Load the document into the Iframe |
@@ -353,23 +351,32 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
353 | this.iframe.addEventListener("load", this, true); | 351 | this.iframe.addEventListener("load", this, true); |
354 | } | 352 | } |
355 | }, | 353 | }, |
356 | 354 | */ | |
355 | |||
356 | |||
357 | |||
358 | //////////////////////////////////////////////////////////////////// | ||
359 | // | ||
357 | handleEvent: { | 360 | handleEvent: { |
358 | value: function(event){ | 361 | value: function(event){ |
359 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | 362 | // |
363 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | ||
360 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); | 364 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); |
361 | this.stageBG.onclick = null; | 365 | this.stageBG.onclick = null; |
362 | this._document = this.iframe.contentWindow.document; | 366 | this._document = this.iframe.contentWindow.document; |
363 | this._window = this.iframe.contentWindow; | 367 | this._window = this.iframe.contentWindow; |
364 | if(!this.documentRoot.Ninja) | 368 | // |
365 | { | 369 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
366 | this.documentRoot.Ninja = {}; | 370 | // |
367 | } | 371 | |
368 | 372 | this.documentRoot.innerHTML = this._userDocument.content.body; | |
369 | if(this._initialUserDocument) { | 373 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; |
370 | // Now load the user content | 374 | |
371 | this.documentRoot.innerHTML = this._initialUserDocument.body; | 375 | |
372 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; | 376 | |
377 | |||
378 | |||
379 | |||
373 | 380 | ||
374 | this.cssLoadInterval = setInterval(function() { | 381 | this.cssLoadInterval = setInterval(function() { |
375 | if(this._document.styleSheets.length > 1) { | 382 | if(this._document.styleSheets.length > 1) { |
@@ -383,7 +390,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
383 | 390 | ||
384 | // TODO - Not sure where this goes | 391 | // TODO - Not sure where this goes |
385 | this._userComponentSet = {}; | 392 | this._userComponentSet = {}; |
386 | } else { | 393 | |
394 | |||
387 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; | 395 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; |
388 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array | 396 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array |
389 | 397 | ||
@@ -429,7 +437,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
429 | } | 437 | } |
430 | 438 | ||
431 | this.callback(this); | 439 | this.callback(this); |
432 | } | 440 | |
433 | } | 441 | } |
434 | }, | 442 | }, |
435 | 443 | ||