diff options
author | Valerio Virgillito | 2012-03-23 13:29:08 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-03-23 13:29:08 -0700 |
commit | bc8b0c17023ddea6d77150694a777e104ef99cbc (patch) | |
tree | 1524c53d027d1f2f8cbb759f61e4d73b52b00481 /js/mediators | |
parent | a2f206ee9fe7477bd3343e10c56149d5edf6232a (diff) | |
parent | 67aaba2e752ea1964356f487269cafc686abb9a7 (diff) | |
download | ninja-bc8b0c17023ddea6d77150694a777e104ef99cbc.tar.gz |
Merge pull request #138 from joseeight/FileIO-Montage-Components
I/O Fixes
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 18a517a5..1efbb8bb 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -348,7 +348,7 @@ exports.IoMediator = Montage.create(Component, { | |||
348 | } | 348 | } |
349 | } | 349 | } |
350 | //Checking for webGL elements in document | 350 | //Checking for webGL elements in document |
351 | if (template.webgl && template.webgl.length > 0) { | 351 | if (template.webgl && template.webgl.length > 1) {//TODO: Should be length 0, hack for a temp fix |
352 | var rdgeDirName, rdgeVersion; | 352 | var rdgeDirName, rdgeVersion; |
353 | //Copy webGL library if needed | 353 | //Copy webGL library if needed |
354 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | 354 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { |
@@ -532,8 +532,6 @@ function loadWebGL (e) {\n\ | |||
532 | getUrlfromNinjaUrl: { | 532 | getUrlfromNinjaUrl: { |
533 | enumerable: false, | 533 | enumerable: false, |
534 | value: function (url, fileRootUrl, fileUrl) { | 534 | value: function (url, fileRootUrl, fileUrl) { |
535 | //console.log("Params: ", url, fileRootUrl, fileUrl); | ||
536 | //console.log("Getting: " + url); | ||
537 | // | 535 | // |
538 | if (url.indexOf(fileRootUrl) !== -1) { | 536 | if (url.indexOf(fileRootUrl) !== -1) { |
539 | url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); | 537 | url = url.replace(new RegExp(fileRootUrl.replace(/\//gi, '\\\/'), 'gi'), ''); |
@@ -561,13 +559,63 @@ function loadWebGL (e) {\n\ | |||
561 | // | 559 | // |
562 | url = (path+newURL).replace(/\/\//gi, '/'); | 560 | url = (path+newURL).replace(/\/\//gi, '/'); |
563 | } | 561 | } |
564 | //console.log("Returning: " + url); | ||
565 | //console.log("-----"); | ||
566 | // | 562 | // |
567 | return url; | 563 | return url; |
568 | } | 564 | } |
569 | }, | 565 | }, |
570 | //////////////////////////////////////////////////////////////////// | 566 | //////////////////////////////////////////////////////////////////// |
567 | // | ||
568 | getDocRootUrl: { | ||
569 | value: function () { | ||
570 | return this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
571 | } | ||
572 | }, | ||
573 | //////////////////////////////////////////////////////////////////// | ||
574 | // | ||
575 | getNinjaPropUrlRedirect: { | ||
576 | enumerable: false, | ||
577 | value: function (prop/* , root */) { | ||
578 | //Checking for property value to not contain a full direct URL | ||
579 | if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { | ||
580 | //Checking for attributes and type of source | ||
581 | if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { | ||
582 | //From HTML attribute | ||
583 | //if (root) { | ||
584 | //prop = (root+prop).replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); | ||
585 | //} else { | ||
586 | prop = prop.replace(/"([^"]*)"/gi, this.getNinjaUrlPrepend.bind(this)); | ||
587 | //} | ||
588 | } else if (prop.indexOf('url') !== -1) { | ||
589 | //From CSS property | ||
590 | //if (root) { | ||
591 | //prop = (root+prop).replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); | ||
592 | //} else { | ||
593 | prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl.bind(this)); | ||
594 | //} | ||
595 | function cssUrlToNinjaUrl (s) { | ||
596 | if (s !== 'url') { | ||
597 | s = this.getDocRootUrl() + s; | ||
598 | } | ||
599 | return s; | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | return prop; | ||
604 | } | ||
605 | }, | ||
606 | //////////////////////////////////////////////////////////////////// | ||
607 | // | ||
608 | getNinjaUrlPrepend: { | ||
609 | enumerable: false, | ||
610 | value: function (url) { | ||
611 | if (url.indexOf('data:') !== -1) { | ||
612 | return url; | ||
613 | } else { | ||
614 | return '"'+this.getDocRootUrl()+url.replace(/\"/gi, '')+'"'; | ||
615 | } | ||
616 | } | ||
617 | }, | ||
618 | //////////////////////////////////////////////////////////////////// | ||
571 | //Method to return a string from CSS rules (to be saved to a file) | 619 | //Method to return a string from CSS rules (to be saved to a file) |
572 | getCssFromRules: { | 620 | getCssFromRules: { |
573 | enumerable: false, | 621 | enumerable: false, |