aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 3f39c4df..1c5cec91 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -437,8 +437,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
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 var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); 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); 440 prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl);
441 function test (s) { 441 function cssUrlToNinjaUrl (s) {
442 if (s !== 'url') { 442 if (s !== 'url') {
443 s = docRootUrl + s; 443 s = docRootUrl + s;
444 } 444 }
@@ -570,8 +570,22 @@ exports.HTMLDocument = Montage.create(TextDocument, {
570 } 570 }
571 // 571 //
572 fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; 572 fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0];
573 prefixUrl = 'url('+fileCouldDirUrl; //This should be re-written with better RegEx 573
574 tag.innerHTML = cssData.content.replace(/url\(/gi, prefixUrl); 574 tag.innerHTML = cssData.content.replace(/url\(()(.+?)\1\)/g, detectUrl);
575
576 function detectUrl (prop) {
577 return prop.replace(/[^()\\""\\'']+/g, prefixUrl);;
578 }
579
580 function prefixUrl (url) {
581 if (url !== 'url') {
582 if (!url.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) {
583 url = fileCouldDirUrl+url;
584 }
585 }
586 return url;
587 }
588
575 //Looping through DOM to insert style tag at location of link element 589 //Looping through DOM to insert style tag at location of link element
576 query = this._templateDocument.html.querySelectorAll(['link']); 590 query = this._templateDocument.html.querySelectorAll(['link']);
577 for (var j in query) { 591 for (var j in query) {
@@ -770,7 +784,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
770 } 784 }
771 } 785 }
772 } 786 }
773 return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; 787 //return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
788 return {mode: 'html', document: this._userDocument, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
774 } else if (this.currentView === "code"){ 789 } else if (this.currentView === "code"){
775 //TODO: Would this get call when we are in code of HTML? 790 //TODO: Would this get call when we are in code of HTML?
776 } else { 791 } else {
@@ -793,7 +808,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
793 } 808 }
794 } 809 }
795 } 810 }
796 return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; 811 //return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
812 return {mode: 'html', document: this._userDocument, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML};
797 } else if (this.currentView === "code"){ 813 } else if (this.currentView === "code"){
798 //TODO: Would this get call when we are in code of HTML? 814 //TODO: Would this get call when we are in code of HTML?
799 } else { 815 } else {