aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/mediators/template.js14
-rwxr-xr-xjs/document/models/base.js13
2 files changed, 20 insertions, 7 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);
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 27f7d43f..0957145a 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -99,11 +99,20 @@ exports.BaseDocumentModel = Montage.create(Component, {
99 //////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////
100 //TODO: Add API to allow other browser support 100 //TODO: Add API to allow other browser support
101 browserPreview: { 101 browserPreview: {
102 value: function (browser) { 102 value: function (browser, screen, context) {
103 //Making call to show feedback screen
104 if (screen) screen.show(context);
103 //Generating URL for document 105 //Generating URL for document
104 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; 106 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1];
105 //TODO: Add logic to prompt user to save (all) before preview 107 //TODO: Add logic to prompt user to save (all) before preview
106 this.saveAll(null,function (result) { 108 this.saveAll(null,function (success) {
109 //Making call to show feedback screen
110 if (screen) screen.hide(context);
111 //TODO: Add error handling logic
112 if (!success) {
113 console.log('Error!');
114 return;
115 }
107 //Currently only supporting current browser (Chrome, obviously) 116 //Currently only supporting current browser (Chrome, obviously)
108 switch (this.browser) { 117 switch (this.browser) {
109 case 'chrome': 118 case 'chrome':