From 1b8586c07951accbc3c0f3951966e4e258b0c5d9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 4 Jun 2012 15:34:57 -0700 Subject: Adding saving blocking screen This is for chrome preview, also fixed other preview bug with plain files not opening in preview. --- js/document/mediators/template.js | 14 +++++++++----- js/document/models/base.js | 13 +++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'js/document') 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, { var webgltag, webgllibtag, webglrdgetag, mjstag, mjslibtag, matchingtags = [], scripts = template.file.content.document.getElementsByTagName('script'), libsobserver = {montage: false, canvas: false, montageCopied: null, canvasCopied: null, callback: libCopyCallback, dispatched: false}; - + //TODO: Clean up, this is messy + if (mJsSerialization) libsobserver.montage = true; + if (template.webgl && template.webgl.length > 1) libsobserver.canvas = true; // for (var i in scripts) { if (scripts[i].getAttribute) { @@ -378,7 +380,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { rdgeDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); rdgeVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; - libsobserver.canvas = true; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, rdgeDirName, function(result) {libsobserver.canvasCopied = result; this.libCopied(libsobserver);}.bind(this)); } else { //TODO: Error handle no available library to copy @@ -505,7 +506,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; - libsobserver.montage = true; this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName, function(result) {libsobserver.montageCopied = result; this.libCopied(libsobserver);}.bind(this)); @@ -589,7 +589,11 @@ exports.TemplateDocumentMediator = Montage.create(Component, { cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); } // - return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); + if (libsobserver.montage || libsobserver.canvas) { + return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: true}; + } else { + return {content: this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')), libs: false}; + } } }, //////////////////////////////////////////////////////////////////// @@ -614,7 +618,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { if (observer.callback && !observer.dispatched) observer.callback(false); observer.dispatched = true; } - } else if (observer.canvas && observer.canvasCopied) { + } else if (observer.canvas) { // if (observer.canvasCopied) { 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, { //////////////////////////////////////////////////////////////////// //TODO: Add API to allow other browser support browserPreview: { - value: function (browser) { + value: function (browser, screen, context) { + //Making call to show feedback screen + if (screen) screen.show(context); //Generating URL for document var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; //TODO: Add logic to prompt user to save (all) before preview - this.saveAll(null,function (result) { + this.saveAll(null,function (success) { + //Making call to show feedback screen + if (screen) screen.hide(context); + //TODO: Add error handling logic + if (!success) { + console.log('Error!'); + return; + } //Currently only supporting current browser (Chrome, obviously) switch (this.browser) { case 'chrome': -- cgit v1.2.3