aboutsummaryrefslogtreecommitdiff
path: root/js/document/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/mediators')
-rwxr-xr-xjs/document/mediators/template.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 17fa553c..c3e8033b 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -334,7 +334,9 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
334 var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [], 334 var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [],
335 scripts = template.file.content.document.getElementsByTagName('script'), 335 scripts = template.file.content.document.getElementsByTagName('script'),
336 libsobserver = {montage: false, canvas: false, montageCopied: null, canvasCopied: null, callback: libCopyCallback, dispatched: false}; 336 libsobserver = {montage: false, canvas: false, montageCopied: null, canvasCopied: null, callback: libCopyCallback, dispatched: false};
337 337 //TODO: Clean up, this is messy
338 if (mJsSerialization) libsobserver.montage = true;
339 if (template.webgl && template.webgl.length > 1) libsobserver.canvas = true;
338 // 340 //
339 for (var i in scripts) { 341 for (var i in scripts) {
340 if (scripts[i].getAttribute) { 342 if (scripts[i].getAttribute) {
@@ -378,7 +380,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
378 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { 380 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') {
379 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 381 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
380 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 382 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
381 libsobserver.canvas = true;
382 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); 383 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this));
383 } else { 384 } else {
384 //TODO: Error handle no available library to copy 385 //TODO: Error handle no available library to copy
@@ -505,7 +506,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
505 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { 506 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') {
506 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 507 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
507 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 508 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
508 libsobserver.montage = true;
509 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); 509 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this));
510 510
511 511
@@ -589,7 +589,11 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
589 cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); 589 cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div');
590 } 590 }
591 // 591 //
592 return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); 592 if (libsobserver.montage || libsobserver.canvas) {
593 return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: true};
594 } else {
595 return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: false};
596 }
593 } 597 }
594 }, 598 },
595 //////////////////////////////////////////////////////////////////// 599 ////////////////////////////////////////////////////////////////////
@@ -614,7 +618,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
614 if (observer.callback && !observer.dispatched) observer.callback(false); 618 if (observer.callback && !observer.dispatched) observer.callback(false);
615 observer.dispatched = true; 619 observer.dispatched = true;
616 } 620 }
617 } else if (observer.canvas && observer.canvasCopied) { 621 } else if (observer.canvas) {
618 // 622 //
619 if (observer.canvasCopied) { 623 if (observer.canvasCopied) {
620 if (observer.callback && !observer.dispatched) observer.callback(true); 624 if (observer.callback && !observer.dispatched) observer.callback(true);