diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index 1f335f79..2d7192b7 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -472,6 +472,33 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | |||
476 | |||
477 | //Temporarily checking for disabled special case | ||
478 | var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), | ||
479 | ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); | ||
480 | // | ||
481 | for (var m = 0; m < ltags.length; m++) { | ||
482 | if (ltags[m].getAttribute('data-ninja-template') === null) { | ||
483 | if (ltags[m].getAttribute('disabled')) { | ||
484 | ltags[m].removeAttribute('disabled'); | ||
485 | ltags[m].setAttribute('data-ninja-disabled', 'true'); | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | // | ||
490 | for (var n = 0; n < stags.length; n++) { | ||
491 | if (stags[n].getAttribute('data-ninja-template') === null) { | ||
492 | if (stags[n].getAttribute('disabled')) { | ||
493 | stags[n].removeAttribute('disabled'); | ||
494 | stags[n].setAttribute('data-ninja-disabled', 'true'); | ||
495 | } | ||
496 | } | ||
497 | } | ||
498 | |||
499 | |||
500 | |||
501 | |||
475 | //Adding a handler for the main user document reel to finish loading | 502 | //Adding a handler for the main user document reel to finish loading |
476 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); | 503 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); |
477 | 504 | ||
@@ -491,7 +518,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
491 | setTimeout(function () { | 518 | setTimeout(function () { |
492 | 519 | ||
493 | 520 | ||
494 | |||
495 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 521 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
496 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 522 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
497 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 523 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
@@ -516,6 +542,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
516 | tag.setAttribute('data-ninja-file-url', cssUrl); | 542 | tag.setAttribute('data-ninja-file-url', cssUrl); |
517 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); | 543 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); |
518 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); | 544 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); |
545 | //Copying attributes to maintain same properties as the <link> | ||
546 | for (var n in this._document.styleSheets[i].ownerNode.attributes) { | ||
547 | if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { | ||
548 | tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); | ||
549 | } | ||
550 | } | ||
519 | tag.innerHTML = cssData.content; | 551 | tag.innerHTML = cssData.content; |
520 | //Looping through DOM to insert style tag at location of link element | 552 | //Looping through DOM to insert style tag at location of link element |
521 | query = this._templateDocument.html.querySelectorAll(['link']); | 553 | query = this._templateDocument.html.querySelectorAll(['link']); |
@@ -528,6 +560,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
528 | } | 560 | } |
529 | } | 561 | } |
530 | } else { | 562 | } else { |
563 | console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); | ||
531 | /* | 564 | /* |
532 | //None local stylesheet, probably on a CDN (locked) | 565 | //None local stylesheet, probably on a CDN (locked) |
533 | tag = this.iframe.contentWindow.document.createElement('style'); | 566 | tag = this.iframe.contentWindow.document.createElement('style'); |
@@ -677,9 +710,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
677 | enumerable: false, | 710 | enumerable: false, |
678 | value: function () { | 711 | value: function () { |
679 | //TODO: Add logic to handle save before preview | 712 | //TODO: Add logic to handle save before preview |
680 | this.saveAll(); | 713 | this.application.ninja.documentController.handleExecuteSaveAll(null); |
681 | //Launching 'blank' tab for testing movie | 714 | //Launching 'blank' tab for testing movie |
682 | chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | 715 | window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); |
716 | //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | ||
683 | } | 717 | } |
684 | }, | 718 | }, |
685 | //////////////////////////////////////////////////////////////////// | 719 | //////////////////////////////////////////////////////////////////// |
@@ -740,8 +774,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
740 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | 774 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; |
741 | 775 | ||
742 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ | 776 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ |
743 | this.selectionModel = this.application.ninja.selectedElements; | 777 | this.selectionModel = this.application.ninja.selectedElements.slice(0); |
744 | } | 778 | } |
779 | |||
780 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | ||
745 | } | 781 | } |
746 | }, | 782 | }, |
747 | 783 | ||
@@ -752,8 +788,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
752 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | 788 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; |
753 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | 789 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; |
754 | 790 | ||
755 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ | 791 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ |
756 | this.application.ninja.selectionController.initWithDocument(this.selectionModel); | 792 | this.application.ninja.selectedElements = this.selectionModel.slice(0); |
757 | } | 793 | } |
758 | 794 | ||
759 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ | 795 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ |
@@ -763,6 +799,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
763 | this.application.ninja.stage._scrollLeft = this.savedTopScroll; | 799 | this.application.ninja.stage._scrollLeft = this.savedTopScroll; |
764 | } | 800 | } |
765 | this.application.ninja.stage.handleScroll(); | 801 | this.application.ninja.stage.handleScroll(); |
802 | |||
803 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | ||
766 | } | 804 | } |
767 | } | 805 | } |
768 | //////////////////////////////////////////////////////////////////// | 806 | //////////////////////////////////////////////////////////////////// |