diff options
author | Valerio Virgillito | 2012-06-01 15:27:30 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-01 15:27:30 -0700 |
commit | 8433fa5ed0d4cc91e10b7080aa8edb8d94ccc1a4 (patch) | |
tree | 72d0501e670d5a6c6d14d29645452870b0b3f0f8 /js/mediators | |
parent | ef48a58da2c7d173605fd43e8f48dac5055c3fa1 (diff) | |
parent | 4bb571a9551bba8a37bf3afd639412173d58bc71 (diff) | |
download | ninja-8433fa5ed0d4cc91e10b7080aa8edb8d94ccc1a4.tar.gz |
Merge branch 'refs/heads/master' into document-bindings-fix
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index e9ed86d7..4dbf32d5 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -277,6 +277,8 @@ exports.IoMediator = Montage.create(Component, { | |||
277 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), | 277 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), |
278 | mjsCreator = template.mjsTemplateCreator.create(), | 278 | mjsCreator = template.mjsTemplateCreator.create(), |
279 | mJsSerialization, | 279 | mJsSerialization, |
280 | toremovetags = [], | ||
281 | presentNodes, | ||
280 | montageTemplate; | 282 | montageTemplate; |
281 | //Creating instance of template creator | 283 | //Creating instance of template creator |
282 | montageTemplate = mjsCreator.initWithDocument(template.document); | 284 | montageTemplate = mjsCreator.initWithDocument(template.document); |
@@ -299,23 +301,34 @@ exports.IoMediator = Montage.create(Component, { | |||
299 | template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); | 301 | template.file.content.document.body.setAttribute(template.body.attributes[n].name, template.body.attributes[n].value); |
300 | } | 302 | } |
301 | } | 303 | } |
302 | //TODO: Add attribute copying for <HEAD> and <HTML> | ||
303 | 304 | ||
304 | 305 | ||
305 | //console.log(template.file.content.document.getElementsByTagName('html')[0].innerHTML); | 306 | |
307 | //TODO: Add attribute copying for <HEAD> and <HTML> | ||
306 | 308 | ||
307 | 309 | ||
310 | |||
311 | //Getting list of current nodes (Ninja DOM) | ||
312 | presentNodes = template.file.content.document.getElementsByTagName('*'); | ||
313 | //Looping through nodes to determine origin and removing if not inserted by Ninja | ||
314 | for (var n in presentNodes) { | ||
315 | if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') === null) { | ||
316 | toremovetags.push(presentNodes[n]); | ||
317 | } else if (presentNodes[n].getAttribute && presentNodes[n].getAttribute('data-ninja-node') !== null) { | ||
318 | //Removing attribute | ||
319 | presentNodes[n].removeAttribute('data-ninja-node'); | ||
320 | } | ||
321 | } | ||
308 | //Getting all CSS (style or link) tags | 322 | //Getting all CSS (style or link) tags |
309 | var styletags = template.file.content.document.getElementsByTagName('style'), | 323 | var styletags = template.file.content.document.getElementsByTagName('style'), |
310 | linktags = template.file.content.document.getElementsByTagName('link'), | 324 | linktags = template.file.content.document.getElementsByTagName('link'), |
311 | toremovetags = [], | ||
312 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); | 325 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); |
313 | 326 | ||
314 | ////////////////////////////////////////////////// | 327 | ////////////////////////////////////////////////// |
315 | //TODO: Remove, temp hack, this is to be fixed by Montage | 328 | //TODO: Remove, temp hack, this is to be fixed by Montage |
316 | var basetags = template.file.content.document.getElementsByTagName('base'); | 329 | var basetags = template.file.content.document.getElementsByTagName('base'); |
317 | for (var g in basetags) { | 330 | for (var g in basetags) { |
318 | if (basetags[g].getAttribute) toremovetags.push(basetags[g]); | 331 | if (basetags[g].getAttribute && basetags[g].href && basetags[g].href.indexOf('chrome-extension://') !== -1) toremovetags.push(basetags[g]); |
319 | } | 332 | } |
320 | ////////////////////////////////////////////////// | 333 | ////////////////////////////////////////////////// |
321 | 334 | ||
@@ -392,7 +405,7 @@ exports.IoMediator = Montage.create(Component, { | |||
392 | for (var n in docLinks) { | 405 | for (var n in docLinks) { |
393 | if (docLinks[n].attributes) { | 406 | if (docLinks[n].attributes) { |
394 | for (var m in docLinks[n].attributes) { | 407 | for (var m in docLinks[n].attributes) { |
395 | if (docLinks[n].attributes[m].name && docLinks[n].attributes[m].name.indexOf('data-ninja') != -1) { | 408 | if (docLinks[n].attributes[m].name && docLinks[n].attributes[m].name.indexOf('data-ninja') !== -1) { |
396 | docLinks[n].removeAttribute(docLinks[n].attributes[m].name); | 409 | docLinks[n].removeAttribute(docLinks[n].attributes[m].name); |
397 | } | 410 | } |
398 | } | 411 | } |
@@ -404,7 +417,7 @@ exports.IoMediator = Montage.create(Component, { | |||
404 | if (template.css[i].ownerNode.getAttribute) { | 417 | if (template.css[i].ownerNode.getAttribute) { |
405 | if (template.css[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.css[i].ownerNode.getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll | 418 | if (template.css[i].ownerNode.getAttribute('data-ninja-uri') === null && !template.css[i].ownerNode.getAttribute('data-ninja-template')) {//TODO: Use querySelectorAll |
406 | //Inseting data from rules array into <style> as string | 419 | //Inseting data from rules array into <style> as string |
407 | if (docStyles[styleCounter] && !template.css[i].ownerNode.getAttribute('data-ninja-external-url')) { | 420 | if (docStyles[styleCounter] && !template.css[i].ownerNode.getAttribute('data-ninja-external-url') && template.css[i].ownerNode.getAttribute('data-ninja-node')) { |
408 | docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); | 421 | docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); |
409 | styleCounter++; | 422 | styleCounter++; |
410 | } | 423 | } |