diff options
Diffstat (limited to 'js/io/document/html-document.js')
-rwxr-xr-x[-rw-r--r--] | js/io/document/html-document.js | 129 |
1 files changed, 93 insertions, 36 deletions
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..fbb34a1d 100644..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 | ||
@@ -39,11 +39,36 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
39 | // PUBLIC MEMBERS | 39 | // PUBLIC MEMBERS |
40 | cssLoadInterval: { value: null, enumerable: false }, | 40 | cssLoadInterval: { value: null, enumerable: false }, |
41 | 41 | ||
42 | _savedLeftScroll: {value:null}, | ||
43 | _savedTopScroll: {value:null}, | ||
44 | |||
45 | _codeViewDocument:{ | ||
46 | writable: true, | ||
47 | enumerable: true, | ||
48 | value:null | ||
49 | }, | ||
50 | |||
42 | /* | 51 | /* |
43 | * PUBLIC API | 52 | * PUBLIC API |
44 | */ | 53 | */ |
45 | 54 | ||
46 | // GETTERS / SETTERS | 55 | // GETTERS / SETTERS |
56 | |||
57 | codeViewDocument:{ | ||
58 | get: function() { return this._codeViewDocument; }, | ||
59 | set: function(value) { this._codeViewDocument = value} | ||
60 | }, | ||
61 | |||
62 | savedLeftScroll:{ | ||
63 | get: function() { return this._savedLeftScroll; }, | ||
64 | set: function(value) { this._savedLeftScroll = value} | ||
65 | }, | ||
66 | |||
67 | savedTopScroll:{ | ||
68 | get: function() { return this._savedTopScroll; }, | ||
69 | set: function(value) { this._savedTopScroll = value} | ||
70 | }, | ||
71 | |||
47 | selectionExclude: { | 72 | selectionExclude: { |
48 | get: function() { return this._selectionExclude; }, | 73 | get: function() { return this._selectionExclude; }, |
49 | set: function(value) { this._selectionExclude = value; } | 74 | set: function(value) { this._selectionExclude = value; } |
@@ -193,28 +218,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
193 | 218 | ||
194 | //****************************************// | 219 | //****************************************// |
195 | // PUBLIC METHODS | 220 | // PUBLIC METHODS |
196 | initialize: { | 221 | |
197 | value: function(doc, uuid, iframe, callback) { | 222 | |
198 | // Shell mode is not used anymore | 223 | //////////////////////////////////////////////////////////////////// |
199 | //if(!window.IsInShellMode()) { | 224 | // |
200 | 225 | initialize: { | |
201 | this.init("index-cloud", this._cloudTemplateUri, doc.type, iframe, uuid, callback); | 226 | value: function(file, uuid, iframe, callback) { |
202 | /* | 227 | // |
203 | } else { | 228 | this._userDocument = file; |
204 | var tmpurl = doc.uri.split('\\'); | 229 | // |
205 | var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html"; | 230 | this.init(file.name, file.uri, file.extension, iframe, uuid, callback); |
206 | this.init(name, fileUrl, doc.type, iframe, uuid, callback); | 231 | // |
207 | this.server = doc.server; | 232 | this.iframe = iframe; |
208 | this._initialUserDocument = doc; | 233 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; |
209 | } | 234 | this.currentView = "design"; |
210 | */ | 235 | // |
211 | this.iframe = iframe; | 236 | this.iframe.src = this._htmlTemplateUrl; |
212 | this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; | 237 | this.iframe.addEventListener("load", this, true); |
213 | this.currentView = "design"; | ||
214 | |||
215 | this._loadDocument(this.uri); | ||
216 | } | 238 | } |
217 | }, | 239 | }, |
240 | //////////////////////////////////////////////////////////////////// | ||
241 | |||
218 | 242 | ||
219 | collectGLData: { | 243 | collectGLData: { |
220 | value: function( elt, dataArray ) | 244 | value: function( elt, dataArray ) |
@@ -318,7 +342,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
318 | } | 342 | } |
319 | }, | 343 | }, |
320 | 344 | ||
321 | // Private | 345 | /* |
346 | // Private | ||
322 | _loadDocument: { | 347 | _loadDocument: { |
323 | value: function(uri) { | 348 | value: function(uri) { |
324 | // Load the document into the Iframe | 349 | // Load the document into the Iframe |
@@ -326,23 +351,32 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
326 | this.iframe.addEventListener("load", this, true); | 351 | this.iframe.addEventListener("load", this, true); |
327 | } | 352 | } |
328 | }, | 353 | }, |
329 | 354 | */ | |
355 | |||
356 | |||
357 | |||
358 | //////////////////////////////////////////////////////////////////// | ||
359 | // | ||
330 | handleEvent: { | 360 | handleEvent: { |
331 | value: function(event){ | 361 | value: function(event){ |
332 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | 362 | // |
363 | this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); | ||
333 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); | 364 | this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); |
334 | this.stageBG.onclick = null; | 365 | this.stageBG.onclick = null; |
335 | this._document = this.iframe.contentWindow.document; | 366 | this._document = this.iframe.contentWindow.document; |
336 | this._window = this.iframe.contentWindow; | 367 | this._window = this.iframe.contentWindow; |
337 | if(!this.documentRoot.Ninja) | 368 | // |
338 | { | 369 | if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; |
339 | this.documentRoot.Ninja = {}; | 370 | // |
340 | } | 371 | |
341 | 372 | this.documentRoot.innerHTML = this._userDocument.content.body; | |
342 | if(this._initialUserDocument) { | 373 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; |
343 | // Now load the user content | 374 | |
344 | this.documentRoot.innerHTML = this._initialUserDocument.body; | 375 | |
345 | this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; | 376 | |
377 | |||
378 | |||
379 | |||
346 | 380 | ||
347 | this.cssLoadInterval = setInterval(function() { | 381 | this.cssLoadInterval = setInterval(function() { |
348 | if(this._document.styleSheets.length > 1) { | 382 | if(this._document.styleSheets.length > 1) { |
@@ -356,7 +390,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
356 | 390 | ||
357 | // TODO - Not sure where this goes | 391 | // TODO - Not sure where this goes |
358 | this._userComponentSet = {}; | 392 | this._userComponentSet = {}; |
359 | } else { | 393 | |
394 | |||
360 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; | 395 | this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; |
361 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array | 396 | this._stylesheets = this._document.styleSheets; // Entire stlyesheets array |
362 | 397 | ||
@@ -402,7 +437,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
402 | } | 437 | } |
403 | 438 | ||
404 | this.callback(this); | 439 | this.callback(this); |
405 | } | 440 | |
406 | } | 441 | } |
407 | }, | 442 | }, |
408 | 443 | ||
@@ -420,5 +455,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base | |||
420 | */ | 455 | */ |
421 | } | 456 | } |
422 | } | 457 | } |
458 | }, | ||
459 | |||
460 | /** | ||
461 | * public method | ||
462 | * | ||
463 | */ | ||
464 | save:{ | ||
465 | value:function(){ | ||
466 | try{ | ||
467 | if(this.currentView === "design"){ | ||
468 | //generate html and save | ||
469 | }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ | ||
470 | this.codeViewDocument.editor.save(); | ||
471 | //persist to filesystem | ||
472 | } | ||
473 | this.dirtyFlag=false; | ||
474 | }catch(e){ | ||
475 | console.log("Error while saving "+this.uri); | ||
476 | console.log(e.stack); | ||
477 | } | ||
478 | } | ||
423 | } | 479 | } |
480 | |||
424 | }); \ No newline at end of file | 481 | }); \ No newline at end of file |