diff options
author | Jose Antonio Marquez | 2012-05-16 15:42:09 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-16 15:42:09 -0700 |
commit | 5cc5d29736d8bf253e3a168cdd6443e839ffb23c (patch) | |
tree | c858889251ea37c82a261f81ace337778c0870fc /js/mediators | |
parent | a2afa558aba65b81f8b1b58687629def14ea471d (diff) | |
download | ninja-5cc5d29736d8bf253e3a168cdd6443e839ffb23c.tar.gz |
Fixing serialization referencing (new object per save)
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/io-mediator.js | 60 |
1 files changed, 6 insertions, 54 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 7f7bd72a..b1916446 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -222,8 +222,11 @@ exports.IoMediator = Montage.create(Component, { | |||
222 | //TODO: Improve reference for rootUrl | 222 | //TODO: Improve reference for rootUrl |
223 | var regexRootUrl, | 223 | var regexRootUrl, |
224 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), | 224 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), |
225 | montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document), | 225 | mjsCreator = template.mjsTemplateCreator.create(), |
226 | mJsSerialization; | 226 | mJsSerialization, |
227 | montageTemplate; | ||
228 | // | ||
229 | montageTemplate = mjsCreator.initWithDocument(template.document); | ||
227 | //Setting up expression for parsing URLs | 230 | //Setting up expression for parsing URLs |
228 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); | 231 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); |
229 | //Injecting head and body into old document | 232 | //Injecting head and body into old document |
@@ -567,58 +570,8 @@ function loadWebGL (e) {\n\ | |||
567 | } | 570 | } |
568 | // | 571 | // |
569 | mjstag.innerHTML = mJsSerialization; | 572 | mjstag.innerHTML = mJsSerialization; |
573 | mjsCreator = null; | ||
570 | } | 574 | } |
571 | |||
572 | |||
573 | // | ||
574 | |||
575 | /* | ||
576 | for (var m in template.mjs) { | ||
577 | mjsComponents.push(template.mjs[m]); | ||
578 | mjsCounter++; | ||
579 | } | ||
580 | // | ||
581 | if (template.mjs && mjsCounter > 0) { | ||
582 | var mjsDirName, mjsVersion, | ||
583 | mjscode = temp.initWithHeadAndBodyElements(template.file.content.document.documentElement.head, template.file.content.document.documentElement.body, mjsComponents)._ownerSerialization; | ||
584 | //Copy Montage library if needed | ||
585 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | ||
586 | //Checking for Montage library to be available | ||
587 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { | ||
588 | mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase(); | ||
589 | mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; | ||
590 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); | ||
591 | //TODO: Fix to allow no overwrite and nested locations | ||
592 | var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' }); | ||
593 | } else { | ||
594 | //TODO: Error handle no available library to copy | ||
595 | } | ||
596 | } | ||
597 | // | ||
598 | if (!mjslibtag) { | ||
599 | mjslibtag = template.file.content.document.createElement('script'); | ||
600 | mjslibtag.setAttribute('type', 'text/javascript'); | ||
601 | mjslibtag.setAttribute('src', mjsDirName + '/montage.js'); | ||
602 | mjslibtag.setAttribute('data-mjs-lib', 'true'); | ||
603 | template.file.content.document.head.appendChild(mjslibtag); | ||
604 | } | ||
605 | // | ||
606 | if (!mjstag) { | ||
607 | mjstag = template.file.content.document.createElement('script'); | ||
608 | mjstag.setAttribute('type', 'text/montage-serialization'); | ||
609 | template.file.content.document.head.appendChild(mjstag); | ||
610 | } | ||
611 | // | ||
612 | mjstag.innerHTML = mjscode; | ||
613 | } | ||
614 | */ | ||
615 | |||
616 | |||
617 | |||
618 | |||
619 | |||
620 | |||
621 | |||
622 | //Cleaning URLs from HTML | 575 | //Cleaning URLs from HTML |
623 | var cleanHTML; | 576 | var cleanHTML; |
624 | if (ninjaWrapper) { | 577 | if (ninjaWrapper) { |
@@ -639,7 +592,6 @@ for (var m in template.mjs) { | |||
639 | cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); | 592 | cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); |
640 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); | 593 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); |
641 | } | 594 | } |
642 | |||
643 | // | 595 | // |
644 | return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); | 596 | return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); |
645 | } | 597 | } |