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/mediators/io-mediator.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'js/mediators/io-mediator.js') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index c5ec951e..c9e10896 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -152,29 +152,38 @@ exports.IoMediator = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - // + //TODO: Optimize fileSave: { value: function (doc, callback, libCopyCallback) { // - var contents, save; + var content, parsedDoc, save; // switch (doc.mode) { case 'html': //Getting content from function to properly handle saving assets (as in external if flagged) if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { - contents = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); + parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); } else { - contents = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); + parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); } break; default: - contents = doc.content; + content = doc.content; break; } - //Making call to save file - save = this.fio.saveFile({ uri: doc.file.uri, contents: contents }); - //Checking for callback - if (callback) callback(save); + if (parsedDoc) { + //Making call to save file + save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content}); + //Checking for callback + if (callback) callback(save); + // + if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true); + } else { + //Making call to save file + save = this.fio.saveFile({uri: doc.file.uri, contents: content}); + //Checking for callback + if (callback) callback(save); + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3