aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js35
1 files changed, 26 insertions, 9 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 95e775a0..2008e40f 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -142,12 +142,7 @@ exports.IoMediator = Montage.create(Component, {
142 // 142 //
143 switch (file.mode) { 143 switch (file.mode) {
144 case 'html': 144 case 'html':
145 file.document.content.document.body.innerHTML = file.body; 145 contents = this.parseNinjaTemplateToHtml(file);
146 file.document.content.document.head.innerHTML = file.head;
147 if (file.style) {
148 file.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(file.style.cssRules);
149 }
150 contents = file.document.content.document.documentElement.outerHTML;
151 break; 146 break;
152 default: 147 default:
153 contents = file.content; 148 contents = file.content;
@@ -155,9 +150,8 @@ exports.IoMediator = Montage.create(Component, {
155 } 150 }
156 // 151 //
157 save = this.fio.saveFile({uri: file.document.uri, contents: contents}); 152 save = this.fio.saveFile({uri: file.document.uri, contents: contents});
158 if(save.status === 204){ 153 //
159 callback(); 154 if (callback) callback(save);
160 }
161 } 155 }
162 }, 156 },
163 //////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////
@@ -170,6 +164,14 @@ exports.IoMediator = Montage.create(Component, {
170 }, 164 },
171 //////////////////////////////////////////////////////////////////// 165 ////////////////////////////////////////////////////////////////////
172 // 166 //
167 fileDelete: {
168 enumerable: false,
169 value: function (file, callback) {
170 //
171 }
172 },
173 ////////////////////////////////////////////////////////////////////
174 //
173 parseHtmlToNinjaTemplate: { 175 parseHtmlToNinjaTemplate: {
174 enumerable: false, 176 enumerable: false,
175 value: function (html) { 177 value: function (html) {
@@ -182,6 +184,21 @@ exports.IoMediator = Montage.create(Component, {
182 } 184 }
183 }, 185 },
184 //////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////
187 //TODO: Expand to allow more templates
188 parseNinjaTemplateToHtml: {
189 enumerable: false,
190 value: function (template) {
191 //
192 template.document.content.document.body.innerHTML = template.body;
193 template.document.content.document.head.innerHTML = template.head;
194 //TODO: Remove temp fix for styles
195 if (template.style) {
196 template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules);
197 }
198 return template.document.content.document.documentElement.outerHTML;
199 }
200 },
201 ////////////////////////////////////////////////////////////////////
185 //Method to return a string from CSS rules (to be saved to a file) 202 //Method to return a string from CSS rules (to be saved to a file)
186 getCssFromRules: { 203 getCssFromRules: {
187 enumerable: false, 204 enumerable: false,