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, 27 insertions, 0 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 733e44b2..6b26668b 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -260,6 +260,17 @@ exports.IoMediator = Montage.create(Component, {
260 var styleCounter = 0, 260 var styleCounter = 0,
261 docStyles = template.document.content.document.getElementsByTagName('style'), 261 docStyles = template.document.content.document.getElementsByTagName('style'),
262 docLinks = template.document.content.document.getElementsByTagName('link'); 262 docLinks = template.document.content.document.getElementsByTagName('link');
263 //Removing Ninja Data Attributes
264 for (var n in docLinks) {
265 if (docLinks[n].attributes) {
266 for (var m in docLinks[n].attributes) {
267 if (docLinks[n].attributes[m].name && docLinks[n].attributes[m].name.indexOf('data-ninja')!=-1) {
268 docLinks[n].removeAttribute(docLinks[n].attributes[m].name);
269 }
270 }
271 }
272 }
273 //
263 for(var i in template.css) { 274 for(var i in template.css) {
264 if (template.css[i].ownerNode) { 275 if (template.css[i].ownerNode) {
265 if (template.css[i].ownerNode.getAttribute) { 276 if (template.css[i].ownerNode.getAttribute) {
@@ -268,6 +279,22 @@ exports.IoMediator = Montage.create(Component, {
268 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); 279 docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules);
269 styleCounter++; 280 styleCounter++;
270 } else { 281 } else {
282 //Checking for attributes to be added to tag upon saving
283 for (var k in docLinks) {
284 if (docLinks[k].getAttribute) {
285 if (docLinks[k].getAttribute('href') && ('/'+docLinks[k].getAttribute('href')) === template.css[i].ownerNode.getAttribute('data-ninja-file-url')) {
286 for (var l in template.css[i].ownerNode.attributes) {
287 if (template.css[i].ownerNode.attributes[l].value) {
288 if (template.css[i].ownerNode.attributes[l].name.indexOf('data-ninja')!=-1) {
289 //Ninja attribute...
290 } else {
291 docLinks[k].setAttribute(template.css[i].ownerNode.attributes[l].name, template.css[i].ownerNode.attributes[l].value);
292 }
293 }
294 }
295 }
296 }
297 }
271 //Saving data from rules array converted to string into <link> file 298 //Saving data from rules array converted to string into <link> file
272 var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: this.getCssFromRules(template.css[i].cssRules)}); 299 var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: this.getCssFromRules(template.css[i].cssRules)});
273 } 300 }