From f3dc624fa464a79fd8e8cec1ddd16ed2109bda23 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 10 Feb 2012 16:05:27 -0800 Subject: Revert "Merge from /joseeight/ninja-internal/tree/FileIO" This reverts commit c48eeb01bd726895dc577d8b843b2a75883eee07. Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 84 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 46 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index fbb34a1d..d51cd279 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, var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.BaseDocument, { // PRIVATE MEMBERS _selectionExclude: { value: null, enumerable: false }, - _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, + _cloudTemplateUri: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, _iframe: { value: null, enumerable: false }, _server: { value: null, enumerable: false }, _selectionModel: { value: [], enumerable: false }, @@ -24,7 +24,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base _styles: { value: null, enumerable: false }, _stylesheets: { value: null, enumerable: false }, _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, - _userDocument: { value: null, enumerable: false }, + _initialUserDocument: { value: null, enumerable: false }, _htmlSource: {value: "", enumerable: false}, _glData: {value: null, enumerable: false }, @@ -218,27 +218,30 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base //****************************************// // PUBLIC METHODS - - - //////////////////////////////////////////////////////////////////// - // - initialize: { - value: function(file, uuid, iframe, callback) { - // - this._userDocument = file; - // - this.init(file.name, file.uri, file.extension, iframe, uuid, callback); - // - this.iframe = iframe; - this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; - this.currentView = "design"; - // - this.iframe.src = this._htmlTemplateUrl; - this.iframe.addEventListener("load", this, true); + initialize: { + value: function(doc, uuid, iframe, callback) { + // Shell mode is not used anymore + //if(!window.IsInShellMode()) { + if(!doc.name){doc.name = "index-cloud"}; + if(!doc.uri){doc.uri = this._cloudTemplateUri}; + this.init(doc.name, doc.uri, doc.type, iframe, uuid, callback); + /* + } else { + var tmpurl = doc.uri.split('\\'); + var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html"; + this.init(name, fileUrl, doc.type, iframe, uuid, callback); + this.server = doc.server; + this._initialUserDocument = doc; + } + */ + this.iframe = iframe; + this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; + this.currentView = "design"; + + this._loadDocument(this.uri); + } }, - //////////////////////////////////////////////////////////////////// - collectGLData: { value: function( elt, dataArray ) @@ -342,8 +345,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } }, - /* -// Private + // Private _loadDocument: { value: function(uri) { // Load the document into the Iframe @@ -351,32 +353,23 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base this.iframe.addEventListener("load", this, true); } }, -*/ - - - - //////////////////////////////////////////////////////////////////// - // + handleEvent: { value: function(event){ - // - this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); + this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); this.stageBG.onclick = null; this._document = this.iframe.contentWindow.document; this._window = this.iframe.contentWindow; - // - if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; - // - - this.documentRoot.innerHTML = this._userDocument.content.body; - this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; - - - - - - + if(!this.documentRoot.Ninja) + { + this.documentRoot.Ninja = {}; + } + + if(this._initialUserDocument) { + // Now load the user content + this.documentRoot.innerHTML = this._initialUserDocument.body; + this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; this.cssLoadInterval = setInterval(function() { if(this._document.styleSheets.length > 1) { @@ -390,8 +383,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base // TODO - Not sure where this goes this._userComponentSet = {}; - - + } else { this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; this._stylesheets = this._document.styleSheets; // Entire stlyesheets array @@ -437,7 +429,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } this.callback(this); - + } } }, -- cgit v1.2.3