aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-26 11:32:10 -0800
committerJose Antonio Marquez2012-02-26 11:32:10 -0800
commit3638492098a21aef63842366fbfc035fc6414fb0 (patch)
tree9270e3e7f2bb638fd1c9a126d6410ac0b30ba680 /js
parentd4ac479796f0341163e02ba50fa892773212a445 (diff)
downloadninja-3638492098a21aef63842366fbfc035fc6414fb0.tar.gz
Fixed issue with losing track of Ninja template css
Also cleaned up URL getter for app in cleaning string code.
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js8
-rw-r--r--js/mediators/io-mediator.js10
2 files changed, 9 insertions, 9 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 472d15de..76436732 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -465,7 +465,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
465 } 465 }
466 } 466 }
467 } else { 467 } else {
468 //None local stylesheet, probably on a CDN (locked) 468 /*
469//None local stylesheet, probably on a CDN (locked)
469 tag = this.iframe.contentWindow.document.createElement('style'); 470 tag = this.iframe.contentWindow.document.createElement('style');
470 tag.setAttribute('type', 'text/css'); 471 tag.setAttribute('type', 'text/css');
471 tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href); 472 tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href);
@@ -473,8 +474,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
473 tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]); 474 tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]);
474 475
475 //TODO: Figure out cross-domain XHR issue, might need cloud to handle 476 //TODO: Figure out cross-domain XHR issue, might need cloud to handle
476 /* 477 var xhr = new XMLHttpRequest();
477var xhr = new XMLHttpRequest();
478 xhr.open("GET", this._document.styleSheets[i].href, true); 478 xhr.open("GET", this._document.styleSheets[i].href, true);
479 xhr.send(); 479 xhr.send();
480 // 480 //
@@ -482,7 +482,6 @@ var xhr = new XMLHttpRequest();
482 console.log(xhr); 482 console.log(xhr);
483 } 483 }
484 //tag.innerHTML = xhr.responseText //xhr.response; 484 //tag.innerHTML = xhr.responseText //xhr.response;
485*/
486 485
487 //Currently no external styles will load if unable to load via XHR request 486 //Currently no external styles will load if unable to load via XHR request
488 487
@@ -496,6 +495,7 @@ var xhr = new XMLHttpRequest();
496 this._templateDocument.head.insertBefore(tag, query[j]); 495 this._templateDocument.head.insertBefore(tag, query[j]);
497 } 496 }
498 } 497 }
498*/
499 } 499 }
500 } 500 }
501 } 501 }
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 315fb6a7..c33ccced 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -205,11 +205,11 @@ exports.IoMediator = Montage.create(Component, {
205 //Getting all CSS (style or link) tags 205 //Getting all CSS (style or link) tags
206 var styletags = template.document.content.document.getElementsByTagName('style'), 206 var styletags = template.document.content.document.getElementsByTagName('style'),
207 linktags = template.document.content.document.getElementsByTagName('link'), 207 linktags = template.document.content.document.getElementsByTagName('link'),
208 url = new RegExp(window.location.protocol+'//'+window.location.host+'/js/document/templates/montage-html/', 'gi'); 208 url = new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi');
209 //Looping through link tags and removing file recreated elements 209 //Looping through link tags and removing file recreated elements
210 for (var j in styletags) { 210 for (var j in styletags) {
211 if (styletags[j].getAttribute) { 211 if (styletags[j].getAttribute) {
212 if(styletags[j].getAttribute('data-ninja-uri') !== null) {//TODO: Use querySelectorAll 212 if(styletags[j].getAttribute('data-ninja-uri') !== null && !styletags[j].getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll
213 try { 213 try {
214 //Checking head first 214 //Checking head first
215 template.document.content.document.head.removeChild(styletags[j]); 215 template.document.content.document.head.removeChild(styletags[j]);
@@ -241,7 +241,7 @@ exports.IoMediator = Montage.create(Component, {
241 if (template.styles[i].ownerNode) { 241 if (template.styles[i].ownerNode) {
242 if (template.styles[i].ownerNode.getAttribute) { 242 if (template.styles[i].ownerNode.getAttribute) {
243 //Checking for node not to be loaded from file 243 //Checking for node not to be loaded from file
244 if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null) { 244 if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.styles[i].ownerNode.getAttribute('data-ninja-template')) {
245 //Inseting data from rules array into tag as string 245 //Inseting data from rules array into tag as string
246 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.styles[i].cssRules); 246 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.styles[i].cssRules);
247 //Syncing <style> tags count since it might be mixed with <link> 247 //Syncing <style> tags count since it might be mixed with <link>
@@ -258,7 +258,7 @@ exports.IoMediator = Montage.create(Component, {
258 for(var i in template.css) { 258 for(var i in template.css) {
259 if (template.css[i].ownerNode) { 259 if (template.css[i].ownerNode) {
260 if (template.css[i].ownerNode.getAttribute) { 260 if (template.css[i].ownerNode.getAttribute) {
261 if (template.css[i].ownerNode.getAttribute('data-ninja-uri') === null) {//TODO: Use querySelectorAll 261 if (template.css[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.css[i].ownerNode.getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll
262 //Inseting data from rules array into <style> as string 262 //Inseting data from rules array into <style> as string
263 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); 263 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules);
264 styleCounter++; 264 styleCounter++;
@@ -327,7 +327,7 @@ exports.IoMediator = Montage.create(Component, {
327 } 327 }
328 } 328 }
329 //TODO: Add better logic for creating this string 329 //TODO: Add better logic for creating this string
330 url = new RegExp(window.location.protocol+'//'+window.location.host+'/js/document/templates/montage-html/', 'gi'); 330 url = new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi');
331 //Returning the CSS string 331 //Returning the CSS string
332 return this.getPretyCss(css.replace(url, '')); 332 return this.getPretyCss(css.replace(url, ''));
333 } 333 }