diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index 544c0ad5..e40656a3 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -430,6 +430,33 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
430 | } | 430 | } |
431 | 431 | ||
432 | 432 | ||
433 | |||
434 | |||
435 | //Temporarily checking for disabled special case | ||
436 | var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), | ||
437 | ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); | ||
438 | // | ||
439 | for (var m = 0; m < ltags.length; m++) { | ||
440 | if (ltags[m].getAttribute('data-ninja-template') === null) { | ||
441 | if (ltags[m].getAttribute('disabled')) { | ||
442 | ltags[m].removeAttribute('disabled'); | ||
443 | ltags[m].setAttribute('data-ninja-disabled', 'true'); | ||
444 | } | ||
445 | } | ||
446 | } | ||
447 | // | ||
448 | for (var n = 0; n < stags.length; n++) { | ||
449 | if (stags[n].getAttribute('data-ninja-template') === null) { | ||
450 | if (stags[n].getAttribute('disabled')) { | ||
451 | stags[n].removeAttribute('disabled'); | ||
452 | stags[n].setAttribute('data-ninja-disabled', 'true'); | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | |||
457 | |||
458 | |||
459 | |||
433 | //Adding a handler for the main user document reel to finish loading | 460 | //Adding a handler for the main user document reel to finish loading |
434 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); | 461 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); |
435 | 462 | ||
@@ -449,7 +476,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
449 | setTimeout(function () { | 476 | setTimeout(function () { |
450 | 477 | ||
451 | 478 | ||
452 | |||
453 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 479 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
454 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 480 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
455 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 481 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
@@ -474,6 +500,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
474 | tag.setAttribute('data-ninja-file-url', cssUrl); | 500 | tag.setAttribute('data-ninja-file-url', cssUrl); |
475 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); | 501 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); |
476 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); | 502 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); |
503 | //Copying attributes to maintain same properties as the <link> | ||
504 | for (var n in this._document.styleSheets[i].ownerNode.attributes) { | ||
505 | if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { | ||
506 | tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); | ||
507 | } | ||
508 | } | ||
477 | tag.innerHTML = cssData.content; | 509 | tag.innerHTML = cssData.content; |
478 | //Looping through DOM to insert style tag at location of link element | 510 | //Looping through DOM to insert style tag at location of link element |
479 | query = this._templateDocument.html.querySelectorAll(['link']); | 511 | query = this._templateDocument.html.querySelectorAll(['link']); |
@@ -486,6 +518,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
486 | } | 518 | } |
487 | } | 519 | } |
488 | } else { | 520 | } else { |
521 | console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); | ||
489 | /* | 522 | /* |
490 | //None local stylesheet, probably on a CDN (locked) | 523 | //None local stylesheet, probably on a CDN (locked) |
491 | tag = this.iframe.contentWindow.document.createElement('style'); | 524 | tag = this.iframe.contentWindow.document.createElement('style'); |
@@ -635,9 +668,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
635 | enumerable: false, | 668 | enumerable: false, |
636 | value: function () { | 669 | value: function () { |
637 | //TODO: Add logic to handle save before preview | 670 | //TODO: Add logic to handle save before preview |
638 | this.saveAll(); | 671 | this.application.ninja.documentController.handleExecuteSaveAll(null); |
639 | //Launching 'blank' tab for testing movie | 672 | //Launching 'blank' tab for testing movie |
640 | chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | 673 | window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); |
674 | //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | ||
641 | } | 675 | } |
642 | }, | 676 | }, |
643 | //////////////////////////////////////////////////////////////////// | 677 | //////////////////////////////////////////////////////////////////// |
@@ -716,9 +750,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
716 | value: function () { | 750 | value: function () { |
717 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | 751 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; |
718 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | 752 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; |
719 | 753 | ||
720 | |||
721 | |||
722 | if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ | 754 | if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ |
723 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; | 755 | this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; |
724 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; | 756 | this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; |