diff options
author | Jose Antonio Marquez | 2012-02-29 15:15:51 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-29 15:15:51 -0800 |
commit | b0b4a1ee6792d98f06cbd8ecf5291e66db8a4eef (patch) | |
tree | 5978eb8742df65de0e0b98454bfc04c2b4cac6e7 /js/document | |
parent | 3a25881b3a463e4f695be2f663f141710ba1d1c1 (diff) | |
parent | b09956e4a9a35c5588cc7cd1f01efb617cbe0884 (diff) | |
download | ninja-b0b4a1ee6792d98f06cbd8ecf5291e66db8a4eef.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Color
Conflicts:
js/controllers/elements/shapes-controller.js
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 76436732..5d507476 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -409,6 +409,33 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
409 | } | 409 | } |
410 | 410 | ||
411 | 411 | ||
412 | |||
413 | |||
414 | //Temporarily checking for disabled special case | ||
415 | var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), | ||
416 | ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); | ||
417 | // | ||
418 | for (var m = 0; m < ltags.length; m++) { | ||
419 | if (ltags[m].getAttribute('data-ninja-template') === null) { | ||
420 | if (ltags[m].getAttribute('disabled')) { | ||
421 | ltags[m].removeAttribute('disabled'); | ||
422 | ltags[m].setAttribute('data-ninja-disabled', 'true'); | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | // | ||
427 | for (var n = 0; n < stags.length; n++) { | ||
428 | if (stags[n].getAttribute('data-ninja-template') === null) { | ||
429 | if (stags[n].getAttribute('disabled')) { | ||
430 | stags[n].removeAttribute('disabled'); | ||
431 | stags[n].setAttribute('data-ninja-disabled', 'true'); | ||
432 | } | ||
433 | } | ||
434 | } | ||
435 | |||
436 | |||
437 | |||
438 | |||
412 | //Adding a handler for the main user document reel to finish loading | 439 | //Adding a handler for the main user document reel to finish loading |
413 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); | 440 | this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); |
414 | 441 | ||
@@ -428,7 +455,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
428 | setTimeout(function () { | 455 | setTimeout(function () { |
429 | 456 | ||
430 | 457 | ||
431 | |||
432 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 458 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
433 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 459 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
434 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 460 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
@@ -453,6 +479,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
453 | tag.setAttribute('data-ninja-file-url', cssUrl); | 479 | tag.setAttribute('data-ninja-file-url', cssUrl); |
454 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); | 480 | tag.setAttribute('data-ninja-file-read-only', JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: fileUri}).content).readOnly); |
455 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); | 481 | tag.setAttribute('data-ninja-file-name', cssUrl.split('/')[cssUrl.split('/').length-1]); |
482 | //Copying attributes to maintain same properties as the <link> | ||
483 | for (var n in this._document.styleSheets[i].ownerNode.attributes) { | ||
484 | if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') { | ||
485 | tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value); | ||
486 | } | ||
487 | } | ||
456 | tag.innerHTML = cssData.content; | 488 | tag.innerHTML = cssData.content; |
457 | //Looping through DOM to insert style tag at location of link element | 489 | //Looping through DOM to insert style tag at location of link element |
458 | query = this._templateDocument.html.querySelectorAll(['link']); | 490 | query = this._templateDocument.html.querySelectorAll(['link']); |
@@ -465,6 +497,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
465 | } | 497 | } |
466 | } | 498 | } |
467 | } else { | 499 | } else { |
500 | console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); | ||
468 | /* | 501 | /* |
469 | //None local stylesheet, probably on a CDN (locked) | 502 | //None local stylesheet, probably on a CDN (locked) |
470 | tag = this.iframe.contentWindow.document.createElement('style'); | 503 | tag = this.iframe.contentWindow.document.createElement('style'); |
@@ -614,9 +647,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
614 | enumerable: false, | 647 | enumerable: false, |
615 | value: function () { | 648 | value: function () { |
616 | //TODO: Add logic to handle save before preview | 649 | //TODO: Add logic to handle save before preview |
617 | this.saveAll(); | 650 | this.application.ninja.documentController.handleExecuteSaveAll(null); |
618 | //Launching 'blank' tab for testing movie | 651 | //Launching 'blank' tab for testing movie |
619 | chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | 652 | window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); |
653 | //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); | ||
620 | } | 654 | } |
621 | }, | 655 | }, |
622 | //////////////////////////////////////////////////////////////////// | 656 | //////////////////////////////////////////////////////////////////// |
@@ -677,8 +711,10 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
677 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | 711 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; |
678 | 712 | ||
679 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ | 713 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ |
680 | this.selectionModel = this.application.ninja.selectedElements; | 714 | this.selectionModel = this.application.ninja.selectedElements.slice(0); |
681 | } | 715 | } |
716 | |||
717 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | ||
682 | } | 718 | } |
683 | }, | 719 | }, |
684 | 720 | ||
@@ -689,8 +725,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
689 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; | 725 | this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; |
690 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; | 726 | this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; |
691 | 727 | ||
692 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ | 728 | if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ |
693 | this.application.ninja.selectionController.initWithDocument(this.selectionModel); | 729 | this.application.ninja.selectedElements = this.selectionModel.slice(0); |
694 | } | 730 | } |
695 | 731 | ||
696 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ | 732 | if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ |
@@ -700,6 +736,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
700 | this.application.ninja.stage._scrollLeft = this.savedTopScroll; | 736 | this.application.ninja.stage._scrollLeft = this.savedTopScroll; |
701 | } | 737 | } |
702 | this.application.ninja.stage.handleScroll(); | 738 | this.application.ninja.stage.handleScroll(); |
739 | |||
740 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | ||
703 | } | 741 | } |
704 | } | 742 | } |
705 | //////////////////////////////////////////////////////////////////// | 743 | //////////////////////////////////////////////////////////////////// |