diff options
author | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
commit | 0175cb67e426a27a3ecfb7b81317caa383c8a5a5 (patch) | |
tree | b4fbfcaabaadff508ad5463e8f71fd643995aacb /js/mediators/io-mediator.js | |
parent | fe71cb9aa1700199c0089166ad54fc56eb760644 (diff) | |
parent | 9f0c4efe2ed9a00f2c5d85c9d88a8040fedb5d8f (diff) | |
download | ninja-0175cb67e426a27a3ecfb7b81317caa383c8a5a5.tar.gz |
Merge branch 'refs/heads/master' into components
Diffstat (limited to 'js/mediators/io-mediator.js')
-rw-r--r-- | js/mediators/io-mediator.js | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 95e775a0..e9958ec3 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -86,6 +86,7 @@ exports.IoMediator = Montage.create(Component, { | |||
86 | case 204: | 86 | case 204: |
87 | //Creating and formatting result object for callbak | 87 | //Creating and formatting result object for callbak |
88 | result = read.file.details; | 88 | result = read.file.details; |
89 | result.root = read.file.details.uri.replace(read.file.details.name, ""); | ||
89 | //Checking for type of content to returns | 90 | //Checking for type of content to returns |
90 | if (result.extension !== 'html' && result.extension !== 'htm') { | 91 | if (result.extension !== 'html' && result.extension !== 'htm') { |
91 | //Simple string | 92 | //Simple string |
@@ -142,12 +143,7 @@ exports.IoMediator = Montage.create(Component, { | |||
142 | // | 143 | // |
143 | switch (file.mode) { | 144 | switch (file.mode) { |
144 | case 'html': | 145 | case 'html': |
145 | file.document.content.document.body.innerHTML = file.body; | 146 | 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; | 147 | break; |
152 | default: | 148 | default: |
153 | contents = file.content; | 149 | contents = file.content; |
@@ -155,9 +151,8 @@ exports.IoMediator = Montage.create(Component, { | |||
155 | } | 151 | } |
156 | // | 152 | // |
157 | save = this.fio.saveFile({uri: file.document.uri, contents: contents}); | 153 | save = this.fio.saveFile({uri: file.document.uri, contents: contents}); |
158 | if(save.status === 204){ | 154 | // |
159 | callback(); | 155 | if (callback) callback(save); |
160 | } | ||
161 | } | 156 | } |
162 | }, | 157 | }, |
163 | //////////////////////////////////////////////////////////////////// | 158 | //////////////////////////////////////////////////////////////////// |
@@ -170,6 +165,14 @@ exports.IoMediator = Montage.create(Component, { | |||
170 | }, | 165 | }, |
171 | //////////////////////////////////////////////////////////////////// | 166 | //////////////////////////////////////////////////////////////////// |
172 | // | 167 | // |
168 | fileDelete: { | ||
169 | enumerable: false, | ||
170 | value: function (file, callback) { | ||
171 | // | ||
172 | } | ||
173 | }, | ||
174 | //////////////////////////////////////////////////////////////////// | ||
175 | // | ||
173 | parseHtmlToNinjaTemplate: { | 176 | parseHtmlToNinjaTemplate: { |
174 | enumerable: false, | 177 | enumerable: false, |
175 | value: function (html) { | 178 | value: function (html) { |
@@ -182,6 +185,32 @@ exports.IoMediator = Montage.create(Component, { | |||
182 | } | 185 | } |
183 | }, | 186 | }, |
184 | //////////////////////////////////////////////////////////////////// | 187 | //////////////////////////////////////////////////////////////////// |
188 | //TODO: Expand to allow more templates | ||
189 | parseNinjaTemplateToHtml: { | ||
190 | enumerable: false, | ||
191 | value: function (template) { | ||
192 | // | ||
193 | template.document.content.document.body.innerHTML = template.body; | ||
194 | template.document.content.document.head.innerHTML = template.head; | ||
195 | // | ||
196 | if (template.webgl.length > 0) { | ||
197 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | ||
198 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { | ||
199 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | //this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(path, libname); | ||
204 | //console.log(this.application.ninja.coreIoApi.ninjaLibrary.libs); | ||
205 | } | ||
206 | //TODO: Remove temp fix for styles | ||
207 | if (template.style) { | ||
208 | template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); | ||
209 | } | ||
210 | return template.document.content.document.documentElement.outerHTML; | ||
211 | } | ||
212 | }, | ||
213 | //////////////////////////////////////////////////////////////////// | ||
185 | //Method to return a string from CSS rules (to be saved to a file) | 214 | //Method to return a string from CSS rules (to be saved to a file) |
186 | getCssFromRules: { | 215 | getCssFromRules: { |
187 | enumerable: false, | 216 | enumerable: false, |