aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-06 17:08:28 -0800
committerValerio Virgillito2012-03-06 17:08:28 -0800
commitcef07085443b7c31e878daaad083b7408c57e104 (patch)
tree77c30a958c0283a6aa208b93640c6008eeb943e2 /js
parent2e3943a8f751ec572066f168b58464c24b9f29e5 (diff)
parentfca92904597895675ddd216399cd235f3c5a7cfa (diff)
downloadninja-cef07085443b7c31e878daaad083b7408c57e104.tar.gz
Merge pull request #99 from joseeight/FileIO-Build-Candidate
File IO Updates
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js22
-rw-r--r--js/mediators/io-mediator.js6
2 files changed, 23 insertions, 5 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 80930af2..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) {
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 097f5975..f44c182c 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -335,7 +335,11 @@ exports.IoMediator = Montage.create(Component, {
335 cleanedCss = dirtyCss.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaUrl.bind(this)); 335 cleanedCss = dirtyCss.replace(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi, parseNinjaUrl.bind(this));
336 336
337 function parseNinjaUrl (url) { 337 function parseNinjaUrl (url) {
338 return this.getUrlfromNinjaUrl(url, fileRootUrl, fileUrl); 338 if (url.indexOf(this.application.ninja.coreIoApi.rootUrl) !== -1) {
339 return this.getUrlfromNinjaUrl(url, fileRootUrl, fileUrl);
340 } else {
341 return url;
342 }
339 } 343 }
340 344
341 /////////////////////////////////////////////////////////////////////////////////////////// 345 ///////////////////////////////////////////////////////////////////////////////////////////