aboutsummaryrefslogtreecommitdiff
path: root/js/mediators/io-mediator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators/io-mediator.js')
-rw-r--r--js/mediators/io-mediator.js27
1 files changed, 18 insertions, 9 deletions
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, {
152 } 152 }
153 }, 153 },
154 //////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////
155 // 155 //TODO: Optimize
156 fileSave: { 156 fileSave: {
157 value: function (doc, callback, libCopyCallback) { 157 value: function (doc, callback, libCopyCallback) {
158 // 158 //
159 var contents, save; 159 var content, parsedDoc, save;
160 // 160 //
161 switch (doc.mode) { 161 switch (doc.mode) {
162 case 'html': 162 case 'html':
163 //Getting content from function to properly handle saving assets (as in external if flagged) 163 //Getting content from function to properly handle saving assets (as in external if flagged)
164 if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) { 164 if (doc.template && (doc.template.type === 'banner' || doc.template.type === 'animation')) {
165 contents = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback); 165 parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, true, libCopyCallback);
166 } else { 166 } else {
167 contents = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback); 167 parsedDoc = this.tmplt.parseNinjaTemplateToHtml(doc, false, libCopyCallback);
168 } 168 }
169 break; 169 break;
170 default: 170 default:
171 contents = doc.content; 171 content = doc.content;
172 break; 172 break;
173 } 173 }
174 //Making call to save file 174 if (parsedDoc) {
175 save = this.fio.saveFile({ uri: doc.file.uri, contents: contents }); 175 //Making call to save file
176 //Checking for callback 176 save = this.fio.saveFile({uri: doc.file.uri, contents: parsedDoc.content});
177 if (callback) callback(save); 177 //Checking for callback
178 if (callback) callback(save);
179 //
180 if (!parsedDoc.libs && libCopyCallback) libCopyCallback(true);
181 } else {
182 //Making call to save file
183 save = this.fio.saveFile({uri: doc.file.uri, contents: content});
184 //Checking for callback
185 if (callback) callback(save);
186 }
178 } 187 }
179 }, 188 },
180 //////////////////////////////////////////////////////////////////// 189 ////////////////////////////////////////////////////////////////////