aboutsummaryrefslogtreecommitdiff
path: root/js/document/html-document.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-03-05 20:06:32 -0800
committerJose Antonio Marquez2012-03-05 20:06:32 -0800
commit4c4d49ae7958e2c87764f9319665189cf69c5c0a (patch)
tree4502367b07f3c938cb617bf59a4f7d2d459ded93 /js/document/html-document.js
parent56efed8b1ed9974aade615fce2d96bc214d21540 (diff)
downloadninja-4c4d49ae7958e2c87764f9319665189cf69c5c0a.tar.gz
Fixed URL parsing issue on actual opened document
Still need to implement CSS loaded from a CDN, currently this would break Ninja.
Diffstat (limited to 'js/document/html-document.js')
-rwxr-xr-xjs/document/html-document.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index ace1390f..a3424259 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -436,7 +436,14 @@ exports.HTMLDocument = Montage.create(TextDocument, {
436 prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this)); 436 prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this));
437 } else if (prop.indexOf('url') !== -1) { //From CSS property 437 } else if (prop.indexOf('url') !== -1) { //From CSS property
438 //TODO: Add functionality 438 //TODO: Add functionality
439 console.log('CSS: '+prop); 439 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
440 prop = prop.replace(/[^()\\""\\'']+/g, test);
441 function test (s) {
442 if (s !== 'url') {
443 s = docRootUrl + s;
444 }
445 return s;
446 }
440 } 447 }
441 } 448 }
442 return prop; 449 return prop;
@@ -643,11 +650,24 @@ exports.HTMLDocument = Montage.create(TextDocument, {
643 console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja'); 650 console.log('ERROR: Cross-Domain-Stylesheet detected, unable to load in Ninja');
644 //None local stylesheet, probably on a CDN (locked) 651 //None local stylesheet, probably on a CDN (locked)
645 /* 652 /*
646tag = this.iframe.contentWindow.document.createElement('style'); 653var tag = this.iframe.contentWindow.document.createElement('style');
647 tag.setAttribute('type', 'text/css'); 654 tag.setAttribute('type', 'text/css');
648 tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href); 655 tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href);
649 tag.setAttribute('data-ninja-file-read-only', "true"); 656 tag.setAttribute('data-ninja-file-read-only', "true");
650 tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]); 657 tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]);
658 //Copying attributes to maintain same properties as the <link>
659 for (var n in this._document.styleSheets[i].ownerNode.attributes) {
660 if (this._document.styleSheets[i].ownerNode.attributes[n].value && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled' && this._document.styleSheets[i].ownerNode.attributes[n].name !== 'disabled') {
661 if (this._document.styleSheets[i].ownerNode.attributes[n].value.indexOf(docRootUrl) !== -1) {
662 tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value.split(docRootUrl)[1]);
663 } else {
664 tag.setAttribute(this._document.styleSheets[i].ownerNode.attributes[n].name, this._document.styleSheets[i].ownerNode.attributes[n].value);
665 }
666 }
667 }
668
669
670
651 671
652 //TODO: Figure out cross-domain XHR issue, might need cloud to handle 672 //TODO: Figure out cross-domain XHR issue, might need cloud to handle
653 var xhr = new XMLHttpRequest(); 673 var xhr = new XMLHttpRequest();
@@ -658,7 +678,6 @@ tag = this.iframe.contentWindow.document.createElement('style');
658 console.log(xhr); 678 console.log(xhr);
659 } 679 }
660 //tag.innerHTML = xhr.responseText //xhr.response; 680 //tag.innerHTML = xhr.responseText //xhr.response;
661
662 //Currently no external styles will load if unable to load via XHR request 681 //Currently no external styles will load if unable to load via XHR request
663 682
664 //Disabling external style sheets 683 //Disabling external style sheets