diff options
author | Pushkar Joshi | 2012-06-04 10:37:29 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-06-04 10:37:29 -0700 |
commit | f1d75e5b29661abc4e173adc1f9de2e0cd91df83 (patch) | |
tree | 796931014054ad6b0647854183f632ffd72ed9ee /js/mediators/io-mediator.js | |
parent | 06b609df1ff7833592faddbd8d7abb5b9f15a74d (diff) | |
parent | c1ec69879028220b0c3f11ad6e24035bf527802c (diff) | |
download | ninja-f1d75e5b29661abc4e173adc1f9de2e0cd91df83.tar.gz |
Merge branch 'master' into pentool
Conflicts:
js/tools/PenTool.js
Diffstat (limited to 'js/mediators/io-mediator.js')
-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 | } |