From 3638492098a21aef63842366fbfc035fc6414fb0 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 26 Feb 2012 11:32:10 -0800 Subject: Fixed issue with losing track of Ninja template css Also cleaned up URL getter for app in cleaning string code. --- js/document/html-document.js | 8 ++++---- js/mediators/io-mediator.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'js') 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, { } } } else { - //None local stylesheet, probably on a CDN (locked) + /* +//None local stylesheet, probably on a CDN (locked) tag = this.iframe.contentWindow.document.createElement('style'); tag.setAttribute('type', 'text/css'); tag.setAttribute('data-ninja-external-url', this._document.styleSheets[i].href); @@ -473,8 +474,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { tag.setAttribute('data-ninja-file-name', this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1]); //TODO: Figure out cross-domain XHR issue, might need cloud to handle - /* -var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); xhr.open("GET", this._document.styleSheets[i].href, true); xhr.send(); // @@ -482,7 +482,6 @@ var xhr = new XMLHttpRequest(); console.log(xhr); } //tag.innerHTML = xhr.responseText //xhr.response; -*/ //Currently no external styles will load if unable to load via XHR request @@ -496,6 +495,7 @@ var xhr = new XMLHttpRequest(); this._templateDocument.head.insertBefore(tag, query[j]); } } +*/ } } } 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, { //Getting all CSS (style or link) tags var styletags = template.document.content.document.getElementsByTagName('style'), linktags = template.document.content.document.getElementsByTagName('link'), - url = new RegExp(window.location.protocol+'//'+window.location.host+'/js/document/templates/montage-html/', 'gi'); + url = new RegExp(chrome.extension.getURL('js/document/templates/montage-html/'), 'gi'); //Looping through link tags and removing file recreated elements for (var j in styletags) { if (styletags[j].getAttribute) { - if(styletags[j].getAttribute('data-ninja-uri') !== null) {//TODO: Use querySelectorAll + if(styletags[j].getAttribute('data-ninja-uri') !== null && !styletags[j].getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll try { //Checking head first template.document.content.document.head.removeChild(styletags[j]); @@ -241,7 +241,7 @@ exports.IoMediator = Montage.create(Component, { if (template.styles[i].ownerNode) { if (template.styles[i].ownerNode.getAttribute) { //Checking for node not to be loaded from file - if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null) { + if (template.styles[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.styles[i].ownerNode.getAttribute('data-ninja-template')) { //Inseting data from rules array into tag as string docStyles[styleCounter].innerHTML = this.getCssFromRules(template.styles[i].cssRules); //Syncing