aboutsummaryrefslogtreecommitdiff
path: root/js/document/html-document.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/html-document.js')
-rwxr-xr-xjs/document/html-document.js39
1 files changed, 37 insertions, 2 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index ba5eea79..564daef3 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -388,6 +388,11 @@ exports.HTMLDocument = Montage.create(TextDocument, {
388 this._document = this.iframe.contentWindow.document; 388 this._document = this.iframe.contentWindow.document;
389 this._window = this.iframe.contentWindow; 389 this._window = this.iframe.contentWindow;
390 // 390 //
391 for (var k in this._document.styleSheets) {
392 this._document.styleSheets[k].ninjatemplate = true;
393 //TODO: Add as attribute
394 }
395 //
391 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; 396 if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {};
392 //Inserting user's document into template 397 //Inserting user's document into template
393 this._templateDocument.head.innerHTML = this._userDocument.content.head; 398 this._templateDocument.head.innerHTML = this._userDocument.content.head;
@@ -423,6 +428,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
423 cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri}); 428 cssData = this.application.ninja.coreIoApi.readFile({uri: fileUri});
424 //Creating tag with file content 429 //Creating tag with file content
425 tag = this.iframe.contentWindow.document.createElement('style'); 430 tag = this.iframe.contentWindow.document.createElement('style');
431 tag.setAttribute('type', 'text/css');
426 tag.setAttribute('ninjauri', fileUri); 432 tag.setAttribute('ninjauri', fileUri);
427 tag.setAttribute('ninjafileurl', cssUrl); 433 tag.setAttribute('ninjafileurl', cssUrl);
428 tag.setAttribute('ninjafilename', cssUrl.split('/')[cssUrl.split('/').length-1]); 434 tag.setAttribute('ninjafilename', cssUrl.split('/')[cssUrl.split('/').length-1]);
@@ -440,9 +446,11 @@ exports.HTMLDocument = Montage.create(TextDocument, {
440 } 446 }
441 } 447 }
442 } 448 }
449 ////////////////////////////////////////////////////////////////////////////
450 ////////////////////////////////////////////////////////////////////////////
443 451
444 //TODO: Revisit this logic 452 //TODO: Revisit this logic
445 this._styles = this._document.styleSheets[1]; 453 /* this._styles = this._document.styleSheets[1]; */
446 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array 454 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
447 455
448 console.log(this._document.styleSheets); 456 console.log(this._document.styleSheets);
@@ -564,7 +572,34 @@ exports.HTMLDocument = Montage.create(TextDocument, {
564 value: function () { 572 value: function () {
565 //TODO: Add code view logic and also styles for HTML 573 //TODO: Add code view logic and also styles for HTML
566 if (this.currentView === 'design') { 574 if (this.currentView === 'design') {
567 return {mode: 'html', document: this._userDocument, webgl: this.glData, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; 575 var styles = [];
576 for (var k in this._document.styleSheets) {
577 if (!this._document.styleSheets[k].ninjatemplate) {
578 styles.push(this._document.styleSheets[k]);
579 }
580 }
581 return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
582 } else if (this.currentView === "code"){
583 //TODO: Would this get call when we are in code of HTML?
584 } else {
585 //Error
586 }
587 }
588 },
589 ////////////////////////////////////////////////////////////////////
590 //
591 saveAll: {
592 enumerable: false,
593 value: function () {
594 //TODO: Add code view logic and also styles for HTML
595 if (this.currentView === 'design') {
596 var css = [];
597 for (var k in this._document.styleSheets) {
598 if (!this._document.styleSheets[k].ninjatemplate) {
599 css.push(this._document.styleSheets[k]);
600 }
601 }
602 return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
568 } else if (this.currentView === "code"){ 603 } else if (this.currentView === "code"){
569 //TODO: Would this get call when we are in code of HTML? 604 //TODO: Would this get call when we are in code of HTML?
570 } else { 605 } else {