diff options
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 56869839..de50f387 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -202,10 +202,54 @@ exports.IoMediator = Montage.create(Component, { | |||
202 | // | 202 | // |
203 | template.document.content.document.body.innerHTML = template.body; | 203 | template.document.content.document.body.innerHTML = template.body; |
204 | template.document.content.document.head.innerHTML = template.head; | 204 | template.document.content.document.head.innerHTML = template.head; |
205 | //TODO: Remove temp fix for styles | 205 | // |
206 | if (template.style) { | 206 | var styletags = template.document.content.document.getElementsByTagName('style'), |
207 | template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); | 207 | linktags = template.document.content.document.getElementsByTagName('link'); |
208 | // | ||
209 | for (var j in styletags) { | ||
210 | if (styletags[j].getAttribute) { | ||
211 | if(styletags[j].getAttribute('ninjauri') !== null) { | ||
212 | try { | ||
213 | template.document.content.document.head.removeChild(styletags[j]); | ||
214 | } catch (e) { | ||
215 | try { | ||
216 | template.document.content.document.body.removeChild(styletags[j]); | ||
217 | } catch (e) { | ||
218 | // | ||
219 | } | ||
220 | } | ||
221 | |||
222 | } | ||
223 | } | ||
224 | } | ||
225 | // | ||
226 | for (var l in linktags) { | ||
227 | if (linktags[l].getAttribute && linktags[l].getAttribute('disabled')) { | ||
228 | linktags[l].removeAttribute('disabled'); | ||
229 | } | ||
230 | } | ||
231 | // | ||
232 | if (template.styles) { | ||
233 | // | ||
234 | var styleCounter = 0, | ||
235 | docStyles = template.document.content.document.getElementsByTagName('style'); | ||
236 | for(var i in template.styles) { | ||
237 | if (template.styles[i].ownerNode) { | ||
238 | if (template.styles[i].ownerNode.getAttribute) { | ||
239 | if (template.styles[i].ownerNode.getAttribute('ninjauri') === null) { | ||
240 | //console.log(docStyles[styleCounter], template.styles[i].cssRules); | ||
241 | docStyles[styleCounter].innerHTML = this.getCssFromRules(template.styles[i].cssRules); | ||
242 | styleCounter++; | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | //template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); | ||
249 | } else if (template.css) { | ||
250 | console.log('Save all css and style'); | ||
208 | } | 251 | } |
252 | // | ||
209 | return template.document.content.document.documentElement.outerHTML; | 253 | return template.document.content.document.documentElement.outerHTML; |
210 | } | 254 | } |
211 | }, | 255 | }, |