diff options
author | Jose Antonio Marquez | 2012-03-02 14:11:08 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-02 14:11:08 -0800 |
commit | e24631ecac0772fc51756fe4aff9638de3b95faf (patch) | |
tree | b70d2273e41670615aafd32477f2f83146ab5bbb /js/mediators | |
parent | c4bfc8b79820b55cc86d755fe590ee649813232a (diff) | |
download | ninja-e24631ecac0772fc51756fe4aff9638de3b95faf.tar.gz |
Fixing CSS URL issues
Only partially, supporting unquoted files under same root.
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index cc97db5e..64210a02 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -313,7 +313,7 @@ exports.IoMediator = Montage.create(Component, { | |||
313 | docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); | 313 | docStyles[styleCounter].innerHTML = this.getCssFromRules(template.css[i].cssRules); |
314 | styleCounter++; | 314 | styleCounter++; |
315 | } | 315 | } |
316 | } else { | 316 | } else if (!template.css[i].ownerNode.getAttribute('data-ninja-template')){ |
317 | //Checking for attributes to be added to tag upon saving | 317 | //Checking for attributes to be added to tag upon saving |
318 | for (var k in docLinks) { | 318 | for (var k in docLinks) { |
319 | if (docLinks[k].getAttribute) { | 319 | if (docLinks[k].getAttribute) { |
@@ -330,8 +330,27 @@ exports.IoMediator = Montage.create(Component, { | |||
330 | } | 330 | } |
331 | } | 331 | } |
332 | } | 332 | } |
333 | var adjCss = this.getCssFromRules(template.css[i].cssRules), cssUrl = template.css[i].ownerNode.getAttribute('data-ninja-uri'); | 333 | var local, regex, fileCouldDirUrl, adjCss = this.getCssFromRules(template.css[i].cssRules), cssUrl = template.css[i].ownerNode.getAttribute('data-ninja-file-url'); |
334 | //console.log((template.css[i].ownerNode.getAttribute('data-ninja-uri')));//cssUrl.split(cssUrl.split('/')[cssUrl.split('/').length-1])[0] | 334 | //TODO: Assure logic for local directory |
335 | local = cssUrl.split(cssUrl.split('/')[cssUrl.split('/').length-2])[0] || cssUrl.split(cssUrl.split('/')[cssUrl.split('/').length-1])[0] || cssUrl.split(cssUrl.split('/')[0])[0]; | ||
336 | // | ||
337 | fileCouldDirUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+local).replace(/\/\//gi, '/')); | ||
338 | // | ||
339 | regex = new RegExp(fileCouldDirUrl.replace(/\//gi, '\\\/'), 'gi'); | ||
340 | // | ||
341 | if (local.split('/').length > 1) { | ||
342 | adjCss = adjCss.replace(regex, '../'); | ||
343 | } else { | ||
344 | adjCss = adjCss.replace(regex, ''); | ||
345 | } | ||
346 | |||
347 | |||
348 | //console.log(adjCss); | ||
349 | //console.log(fileCouldDirUrl); | ||
350 | //return; | ||
351 | |||
352 | |||
353 | |||
335 | //Saving data from rules array converted to string into <link> file | 354 | //Saving data from rules array converted to string into <link> file |
336 | var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: adjCss}); | 355 | var save = this.fio.saveFile({uri: template.css[i].ownerNode.getAttribute('data-ninja-uri'), contents: adjCss}); |
337 | } | 356 | } |