aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js40
1 files changed, 30 insertions, 10 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 6d146c97..cf44ab9d 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -10,7 +10,7 @@ var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 FileIo = require("js/io/system/fileio").FileIo, 11 FileIo = require("js/io/system/fileio").FileIo,
12 ProjectIo = require("js/io/system/projectio").ProjectIo, 12 ProjectIo = require("js/io/system/projectio").ProjectIo,
13 TemplateCreator = require("node_modules/tools/template-creator").TemplateCreator; 13 TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator;
14//////////////////////////////////////////////////////////////////////// 14////////////////////////////////////////////////////////////////////////
15// 15//
16exports.IoMediator = Montage.create(Component, { 16exports.IoMediator = Montage.create(Component, {
@@ -203,20 +203,38 @@ exports.IoMediator = Montage.create(Component, {
203 var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); 203 var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]));
204 regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); 204 regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi');
205 //Injecting head and body into old document 205 //Injecting head and body into old document
206 template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); 206 //template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, '');
207 template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); 207 //template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, '');
208
209
210
211 //Testing using montage clean up method
212 var mjscode, mjsTemp = TemplateCreator.create();
213
214 //mjscode = mjsTemp.initWithHeadAndBodyElements(template.head, template.body);
215 mjscode = mjsTemp.initWithDocument(template.file.content.document);
216
217 console.log(template.head, mjscode._document.head);
218 template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, '');
219 template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, '');
220
221
222
223
208 //Getting all CSS (style or link) tags 224 //Getting all CSS (style or link) tags
209 var styletags = template.file.content.document.getElementsByTagName('style'), 225 var styletags = template.file.content.document.getElementsByTagName('style'),
210 linktags = template.file.content.document.getElementsByTagName('link'), 226 linktags = template.file.content.document.getElementsByTagName('link'),
211 toremovetags = [], 227 toremovetags = [],
212 njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'), 228 njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]');
213 basetags = template.file.content.document.getElementsByTagName('base');
214 229
215 ////////////////////////////////////////////////// 230 //////////////////////////////////////////////////
216 //TODO: Remove, temp hack to avoid montage 231 //TODO: Remove, temp hack, this is to be fixed by Montage
232 /*
233var basetags = template.file.content.document.getElementsByTagName('base');
217 for (var g in basetags) { 234 for (var g in basetags) {
218 if (basetags[g].getAttribute) toremovetags.push(basetags[g]); 235 if (basetags[g].getAttribute) toremovetags.push(basetags[g]);
219 } 236 }
237*/
220 ////////////////////////////////////////////////// 238 //////////////////////////////////////////////////
221 239
222 // 240 //
@@ -469,9 +487,9 @@ function loadWebGL (e) {\n\
469 487
470 488
471 // 489 //
472 var mjsCounter = 0, mjsComponents = [], temp = TemplateCreator.create(); 490
473 // 491 /*
474 for (var m in template.mjs) { 492for (var m in template.mjs) {
475 mjsComponents.push(template.mjs[m]); 493 mjsComponents.push(template.mjs[m]);
476 mjsCounter++; 494 mjsCounter++;
477 } 495 }
@@ -509,6 +527,7 @@ function loadWebGL (e) {\n\
509 // 527 //
510 mjstag.innerHTML = mjscode; 528 mjstag.innerHTML = mjscode;
511 } 529 }
530*/
512 531
513 532
514 533
@@ -570,7 +589,8 @@ function loadWebGL (e) {\n\
570 // 589 //
571 getDocRootUrl: { 590 getDocRootUrl: {
572 value: function () { 591 value: function () {
573 return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); 592 //TODO: Add support for model.baseHref (base tag)
593 return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/'));
574 } 594 }
575 }, 595 },
576 //////////////////////////////////////////////////////////////////// 596 ////////////////////////////////////////////////////////////////////