diff options
Diffstat (limited to 'js/io/document/html-document.js')
-rwxr-xr-x[-rw-r--r--] | js/io/document/html-document.js | 153 |
1 files changed, 117 insertions, 36 deletions
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..dfd8566a 100644..100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js | |||
@@ -11,9 +11,10 @@ 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 | _templateDocument: { value: null, enumerable: false }, | ||
17 | _selectionModel: { value: [], enumerable: false }, | 18 | _selectionModel: { value: [], enumerable: false }, |
18 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, | 19 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, |
19 | 20 | ||
@@ -24,7 +25,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
24 | _styles: { value: null, enumerable: false }, | 25 | _styles: { value: null, enumerable: false }, |
25 | _stylesheets: { value: null, enumerable: false }, | 26 | _stylesheets: { value: null, enumerable: false }, |
26 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, | 27 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, |
27 | _initialUserDocument: { value: null, enumerable: false }, | 28 | _userDocument: { value: null, enumerable: false }, |
28 | _htmlSource: {value: "<html></html>", enumerable: false}, | 29 | _htmlSource: {value: "<html></html>", enumerable: false}, |
29 | _glData: {value: null, enumerable: false }, | 30 | _glData: {value: null, enumerable: false }, |
30 | 31 | ||
@@ -39,11 +40,36 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
39 | // PUBLIC MEMBERS | 40 | // PUBLIC MEMBERS |
40 | cssLoadInterval: { value: null, enumerable: false }, | 41 | cssLoadInterval: { value: null, enumerable: false }, |
41 | 42 | ||
43 | _savedLeftScroll: {value:null}, | ||
44 | _savedTopScroll: {value:null}, | ||
45 | |||
46 | _codeViewDocument:{ | ||
47 | writable: true, | ||
48 | enumerable: true, | ||
49 | value:null | ||
50 | }, | ||
51 | |||
42 | /* | 52 | /* |
43 | * PUBLIC API | 53 | * PUBLIC API |
44 | */ | 54 | */ |
45 | 55 | ||
46 | // GETTERS / SETTERS | 56 | // GETTERS / SETTERS |
57 | |||
58 | codeViewDocument:{ | ||
59 | get: function() { return this._codeViewDocument; }, | ||
60 | set: function(value) { this._codeViewDocument = value} | ||
61 | }, | ||
62 | |||
63 | savedLeftScroll:{ | ||
64 | get: function() { return this._savedLeftScroll; }, | ||
65 | set: function(value) { this._savedLeftScroll = value} | ||
66 | }, | ||
67 | |||
68 | savedTopScroll:{ | ||
69 | get: function() { return this._savedTopScroll; }, | ||
70 | set: function(value) { this._savedTopScroll = value} | ||
71 | }, | ||
72 | |||
47 | selectionExclude: { | 73 | selectionExclude: { |
48 | get: function() { return this._selectionExclude; }, | 74 | get: function() { return this._selectionExclude; }, |
49 | set: function(value) { this._selectionExclude = value; } | 75 | set: function(value) { this._selectionExclude = value; } |
@@ -193,28 +219,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
193 | 219 | ||
194 | //****************************************// | 220 | //****************************************// |
195 | // PUBLIC METHODS | 221 | // PUBLIC METHODS |
196 | initialize: { | 222 | |
197 | value: function(doc, uuid, iframe, callback) { | 223 | |
198 | // Shell mode is not used anymore | 224 | //////////////////////////////////////////////////////////////////// |
199 | //if(!window.IsInShellMode()) { | 225 | // |
200 | 226 | initialize: { | |
201 | this.init("index-cloud", this._cloudTemplateUri, doc.type, iframe, uuid, callback); | 227 | value: function(file, uuid, iframe, callback) { |
202 | /* | 228 | // |
203 | } else { | 229 | this._userDocument = file; |
204 | var tmpurl = doc.uri.split('\\'); | 230 | // |
205 | var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html"; | 231 | this.init(file.name, file.uri, file.extension, iframe, uuid, callback); |
206 | this.init(name, fileUrl, doc.type, iframe, uuid, callback); | 232 | // |
207 | this.server = doc.server; | 233 | this.iframe = iframe; |
208 | this._initialUserDocument = doc; | 234 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; |
209 | } | 235 | this.currentView = "design"; |
210 | */ | 236 | // |
211 | this.iframe = iframe; | 237 | this.iframe.src = this._htmlTemplateUrl; |
212 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; | 238 | this.iframe.addEventListener("load", this, true); |
213 | this.currentView = "design"; | ||
214 | |||
215 | this._loadDocument(this.uri); | ||
216 | } | 239 | } |
217 | }, | 240 | }, |
241 | //////////////////////////////////////////////////////////////////// | ||
242 | |||
218 | 243 | ||
219 | collectGLData: { | 244 | collectGLData: { |
220 | value: function( elt, dataArray ) | 245 | value: function( elt, dataArray ) |
@@ -318,7 +343,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
318 | } | 343 | } |
319 | }, | 344 | }, |
320 | 345 | ||
321 | // Private | 346 | /* |
347 | // Private | ||
322 | _loadDocument: { | 348 | _loadDocument: { |
323 | value: function(uri) { | 349 | value: function(uri) { |
324 | // Load the document into the Iframe | 350 | // Load the document into the Iframe |
@@ -326,23 +352,36 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
326 | this.iframe.addEventListener("load", this, true); | 352 | this.iframe.addEventListener("load", this, true); |
327 | } | 353 | } |
328 | }, | 354 | }, |
329 | 355 | */ | |
356 | |||
357 | |||
358 | |||
359 | //////////////////////////////////////////////////////////////////// | ||
360 | // | ||
330 | handleEvent: { | 361 | handleEvent: { |
331 | value: function(event){ | 362 | value: function(event){ |
332 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | 363 | //TODO: Clean up, using for prototyping save |
364 | this._templateDocument = {}; | ||
365 | this._templateDocument.head = this.iframe.contentWindow.document.getElementById("userHead");; | ||
366 | this._templateDocument.body = this.iframe.contentWindow.document.getElementById("UserContent");; | ||
367 | // | ||
368 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | ||
333 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); | 369 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); |
334 | this.stageBG.onclick = null; | 370 | this.stageBG.onclick = null; |
335 | this._document = this.iframe.contentWindow.document; | 371 | this._document = this.iframe.contentWindow.document; |
336 | this._window = this.iframe.contentWindow; | 372 | this._window = this.iframe.contentWindow; |
337 | if(!this.documentRoot.Ninja) | 373 | // |
338 | { | 374 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
339 | this.documentRoot.Ninja = {}; | 375 | // |
340 | } | 376 | |
341 | 377 | this.documentRoot.innerHTML = this._userDocument.content.body; | |
342 | if(this._initialUserDocument) { | 378 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; |
343 | // Now load the user content | 379 | |
344 | this.documentRoot.innerHTML = this._initialUserDocument.body; | 380 | |
345 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; | 381 | //TODO: Look at code below and clean up |
382 | |||
383 | |||
384 | |||
346 | 385 | ||
347 | this.cssLoadInterval = setInterval(function() { | 386 | this.cssLoadInterval = setInterval(function() { |
348 | if(this._document.styleSheets.length > 1) { | 387 | if(this._document.styleSheets.length > 1) { |
@@ -356,7 +395,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
356 | 395 | ||
357 | // TODO - Not sure where this goes | 396 | // TODO - Not sure where this goes |
358 | this._userComponentSet = {}; | 397 | this._userComponentSet = {}; |
359 | } else { | 398 | |
399 | |||
360 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; | 400 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; |
361 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array | 401 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array |
362 | 402 | ||
@@ -402,7 +442,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
402 | } | 442 | } |
403 | 443 | ||
404 | this.callback(this); | 444 | this.callback(this); |
405 | } | 445 | |
406 | } | 446 | } |
407 | }, | 447 | }, |
408 | 448 | ||
@@ -420,5 +460,46 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
420 | */ | 460 | */ |
421 | } | 461 | } |
422 | } | 462 | } |
463 | }, | ||
464 | |||
465 | /** | ||
466 | * public method | ||
467 | * | ||
468 | */ | ||
469 | //////////////////////////////////////////////////////////////////// | ||
470 | // | ||
471 | save: { | ||
472 | enumerable: false, | ||
473 | value: function () { | ||
474 | //TODO: Add code view logic and also styles for HTML | ||
475 | if (this.currentView === 'design') { | ||
476 | return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; | ||
477 | } else if(this.currentView === "code"){ | ||
478 | //TODO: Would this get call when we are in code of HTML? | ||
479 | } | ||
480 | } | ||
481 | } | ||
482 | //////////////////////////////////////////////////////////////////// | ||
483 | //////////////////////////////////////////////////////////////////// | ||
484 | |||
485 | |||
486 | /* | ||
487 | save:{ | ||
488 | value:function(){ | ||
489 | try{ | ||
490 | if(this.currentView === "design"){ | ||
491 | //generate html and sav |