diff options
author | hwc487 | 2012-06-04 09:15:12 -0700 |
---|---|---|
committer | hwc487 | 2012-06-04 09:15:12 -0700 |
commit | 3f5351c5d75080727953caf5d8d9a312c1c9391b (patch) | |
tree | dcbc2db4e137e115b43a6117331ed1176f85904b /js/mediators | |
parent | 4aacbf5d3c7a42a3621eb3ae2723542a455e7720 (diff) | |
parent | 3abba04025dbc0daadb08184833a2558c442b8e1 (diff) | |
download | ninja-3f5351c5d75080727953caf5d8d9a312c1c9391b.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
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 | } |