aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/html-document.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document/html-document.js')
-rwxr-xr-x[-rw-r--r--]js/io/document/html-document.js126
1 files changed, 95 insertions, 31 deletions
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index 393d29fe..88cfec67 100644..100755
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -4,16 +4,20 @@ 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////////////////////////////////////////////////////////////////////////
8//
7var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
8 baseDocumentModule = require("js/io/document/base-document"), 10 BaseDocument = require("js/io/document/base-document").BaseDocument,
9 NJUtils = require("js/lib/NJUtils").NJUtils; 11 NJUtils = require("js/lib/NJUtils").NJUtils;
10 12////////////////////////////////////////////////////////////////////////
11var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.BaseDocument, { 13//
14exports.HTMLDocument = Montage.create(BaseDocument, {
12 // PRIVATE MEMBERS 15 // PRIVATE MEMBERS
13 _selectionExclude: { value: null, enumerable: false }, 16 _selectionExclude: { value: null, enumerable: false },
14 _cloudTemplateUri: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, 17 _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false},
15 _iframe: { value: null, enumerable: false }, 18 _iframe: { value: null, enumerable: false },
16 _server: { value: null, enumerable: false }, 19 _server: { value: null, enumerable: false },
20 _templateDocument: { value: null, enumerable: false },
17 _selectionModel: { value: [], enumerable: false }, 21 _selectionModel: { value: [], enumerable: false },
18 _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, 22 _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false},
19 23
@@ -24,7 +28,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
24 _styles: { value: null, enumerable: false }, 28 _styles: { value: null, enumerable: false },
25 _stylesheets: { value: null, enumerable: false }, 29 _stylesheets: { value: null, enumerable: false },
26 _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, 30 _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false },
27 _initialUserDocument: { value: null, enumerable: false }, 31 _userDocument: { value: null, enumerable: false },
28 _htmlSource: {value: "<html></html>", enumerable: false}, 32 _htmlSource: {value: "<html></html>", enumerable: false},
29 _glData: {value: null, enumerable: false }, 33 _glData: {value: null, enumerable: false },
30 _userComponents: { value: {}, enumarable: false}, 34 _userComponents: { value: {}, enumarable: false},
@@ -40,11 +44,36 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
40 // PUBLIC MEMBERS 44 // PUBLIC MEMBERS
41 cssLoadInterval: { value: null, enumerable: false }, 45 cssLoadInterval: { value: null, enumerable: false },
42 46
47 _savedLeftScroll: {value:null},
48 _savedTopScroll: {value:null},
49
50 _codeViewDocument:{
51 writable: true,
52 enumerable: true,
53 value:null
54 },
55
43 /* 56 /*
44 * PUBLIC API 57 * PUBLIC API
45 */ 58 */
46 59
47 // GETTERS / SETTERS 60 // GETTERS / SETTERS
61
62 codeViewDocument:{
63 get: function() { return this._codeViewDocument; },
64 set: function(value) { this._codeViewDocument = value}
65 },
66
67 savedLeftScroll:{
68 get: function() { return this._savedLeftScroll; },
69 set: function(value) { this._savedLeftScroll = value}
70 },
71
72 savedTopScroll:{
73 get: function() { return this._savedTopScroll; },
74 set: function(value) { this._savedTopScroll = value}
75 },
76
48 selectionExclude: { 77 selectionExclude: {
49 get: function() { return this._selectionExclude; }, 78 get: function() { return this._selectionExclude; },
50 set: function(value) { this._selectionExclude = value; } 79 set: function(value) { this._selectionExclude = value; }
@@ -205,28 +234,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
205 234
206 //****************************************// 235 //****************************************//
207 // PUBLIC METHODS 236 // PUBLIC METHODS
237
238
239 ////////////////////////////////////////////////////////////////////
240 //
208 initialize: { 241 initialize: {
209 value: function(doc, uuid, iframe, callback) { 242 value: function(file, uuid, iframe, callback) {
210 // Shell mode is not used anymore 243 //
211 //if(!window.IsInShellMode()) { 244 this._userDocument = file;
212 245 //
213 this.init("index-cloud", this._cloudTemplateUri, doc.type, iframe, uuid, callback); 246 this.init(file.name, file.uri, file.extension, iframe, uuid, callback);
214 /* 247 //
215 } else {
216 var tmpurl = doc.uri.split('\\');
217 var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html";
218 this.init(name, fileUrl, doc.type, iframe, uuid, callback);
219 this.server = doc.server;
220 this._initialUserDocument = doc;
221 }
222 */
223 this.iframe = iframe; 248 this.iframe = iframe;
224 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; 249 this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"];
225 this.currentView = "design"; 250 this.currentView = "design";
226 251 //
227 this._loadDocument(this.uri); 252 this.iframe.src = this._htmlTemplateUrl;
253 this.iframe.addEventListener("load", this, true);
228 } 254 }
229 }, 255 },
256 ////////////////////////////////////////////////////////////////////
257
230 258
231 collectGLData: { 259 collectGLData: {
232 value: function( elt, dataArray ) 260 value: function( elt, dataArray )
@@ -330,6 +358,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
330 } 358 }
331 }, 359 },
332 360
361 /*
333 // Private 362 // Private
334 _loadDocument: { 363 _loadDocument: {
335 value: function(uri) { 364 value: function(uri) {
@@ -338,23 +367,36 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
338 this.iframe.addEventListener("load", this, true); 367 this.iframe.addEventListener("load", this, true);
339 } 368 }
340 }, 369 },
370*/
341 371
372
373
374 ////////////////////////////////////////////////////////////////////
375 //
342 handleEvent: { 376 handleEvent: {
343 value: function(event){ 377 value: function(event){
378 //TODO: Clean up, using for prototyping save
379 this._templateDocument = {};
380 this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");;
381 this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");;
382 //
344 this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); 383 this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent");
345 this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); 384 this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG");
346 this.stageBG.onclick = null; 385 this.stageBG.onclick = null;
347 this._document = this.iframe.contentWindow.document; 386 this._document = this.iframe.contentWindow.document;
348 this._window = this.iframe.contentWindow; 387 this._window = this.iframe.contentWindow;
349 if(!this.documentRoot.Ninja) 388 //
350 { 389 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
351 this.documentRoot.Ninja = {}; 390 //
352 }
353 391
354 if(this._initialUserDocument) { 392 this.documentRoot.innerHTML = this._userDocument.content.body;
355 // Now load the user content 393 this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head;
356 this.documentRoot.innerHTML = this._initialUserDocument.body; 394
357 this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; 395
396 //TODO: Look at code below and clean up
397
398
399
358 400
359 this.cssLoadInterval = setInterval(function() { 401 this.cssLoadInterval = setInterval(function() {
360 if(this._document.styleSheets.length > 1) { 402 if(this._document.styleSheets.length > 1) {
@@ -365,7 +407,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
365 this.callback(this); 407 this.callback(this);
366 } 408 }
367 }.bind(this), 50); 409 }.bind(this), 50);
368 } else { 410
369 this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; 411 this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
370 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array 412 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
371 413
@@ -414,8 +456,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
414 } 456 }
415 457
416 this.callback(this); 458 this.callback(this);
459
417 } 460 }
418 }
419 }, 461 },
420 462
421 _setSWFObjectScript: { 463 _setSWFObjectScript: {
@@ -432,5 +474,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
432 */ 474 */
433 } 475 }
434 } 476 }
477 },
478
479 /**
480 * public method
481 *
482 */
483 ////////////////////////////////////////////////////////////////////
484 //
485 save: {
486 enumerable: false,
487 value: function () {
488 //TODO: Add code view logic and also styles for HTML
489 if (this.currentView === 'design') {