aboutsummaryrefslogtreecommitdiff
path: root/js/document/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/mediators')
-rwxr-xr-xjs/document/mediators/template.js50
1 files changed, 46 insertions, 4 deletions
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index 1aac7e15..17fa553c 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -93,7 +93,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
93 //////////////////////////////////////////////////////////////////// 93 ////////////////////////////////////////////////////////////////////
94 //TODO: Expand to allow more templates, clean up variables 94 //TODO: Expand to allow more templates, clean up variables
95 parseNinjaTemplateToHtml: { 95 parseNinjaTemplateToHtml: {
96 value: function (template, ninjaWrapper) { 96 value: function (template, ninjaWrapper, libCopyCallback) {
97 //TODO: Improve reference for rootUrl 97 //TODO: Improve reference for rootUrl
98 var regexRootUrl, 98 var regexRootUrl,
99 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), 99 rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])),
@@ -332,7 +332,9 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
332 332
333 // 333 //
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};
337
336 // 338 //
337 for (var i in scripts) { 339 for (var i in scripts) {
338 if (scripts[i].getAttribute) { 340 if (scripts[i].getAttribute) {
@@ -376,7 +378,8 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
376 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { 378 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') {
377 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 379 rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
378 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 380 rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
379 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {console.log(result)}); 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));
380 } else { 383 } else {
381 //TODO: Error handle no available library to copy 384 //TODO: Error handle no available library to copy
382 } 385 }
@@ -502,7 +505,8 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
502 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { 505 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') {
503 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); 506 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
504 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; 507 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
505 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {console.log(result)}); 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));
506 510
507 511
508 512
@@ -590,6 +594,44 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
590 }, 594 },
591 //////////////////////////////////////////////////////////////////// 595 ////////////////////////////////////////////////////////////////////
592 // 596 //
597 libCopied: {
598 value: function (observer) {
599 if (observer.montage && observer.canvas) {
600 //
601 if (observer.montageCopied && observer.canvasCopied) {
602 if (observer.callback && !observer.dispatched) observer.callback(true);
603 observer.dispatched = true;
604 } else if (observer.montageCopied === false || observer.canvasCopied === false) {
605 if (observer.callback && !observer.dispatched) observer.callback(false);
606 observer.dispatched = true;
607 }
608 } else if (observer.montage) {
609 //
610 if (observer.montageCopied) {
611 if (observer.callback && !observer.dispatched) observer.callback(true);
612 observer.dispatched = true;
613 } else {
614 if (observer.callback && !observer.dispatched) observer.callback(false);
615 observer.dispatched = true;
616 }
617 } else if (observer.canvas && observer.canvasCopied) {
618 //
619 if (observer.canvasCopied) {
620 if (observer.callback && !observer.dispatched) observer.callback(true);
621 observer.dispatched = true;
622 } else {
623 if (observer.callback && !observer.dispatched) observer.callback(false);
624 observer.dispatched = true;
625 }
626 } else {
627 //Error
628 if (observer.callback && !observer.dispatched) observer.callback(false);
629 observer.dispatched = true;
630 }
631 }
632 },
633 ////////////////////////////////////////////////////////////////////
634 //
593 getUrlfromNinjaUrl: { 635 getUrlfromNinjaUrl: {
594 enumerable: false, 636 enumerable: false,
595 value: function (url, fileRootUrl, fileUrl) { 637 value: function (url, fileRootUrl, fileUrl) {