aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/models/base.js6
-rw-r--r--js/document/templates/html/main.js2
-rw-r--r--js/mediators/io-mediator.js72
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js6
4 files changed, 67 insertions, 19 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 033e16f6..649539ea 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -149,7 +149,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
149 template: this.fileTemplate, 149 template: this.fileTemplate,
150 document: this.views.design.iframe.contentWindow.document, 150 document: this.views.design.iframe.contentWindow.document,
151 head: this.views.design.iframe.contentWindow.document.head, 151 head: this.views.design.iframe.contentWindow.document.head,
152 body: this.views.design.iframe.contentWindow.document.body 152 body: this.views.design.iframe.contentWindow.document.body,
153 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
153 }, callback.bind(this)); 154 }, callback.bind(this));
154 } else { 155 } else {
155 //TODO: Add logic to save code view data 156 //TODO: Add logic to save code view data
@@ -177,7 +178,8 @@ exports.BaseDocumentModel = Montage.create(Component, {
177 template: this.fileTemplate, 178 template: this.fileTemplate,
178 document: this.views.design.iframe.contentWindow.document, 179 document: this.views.design.iframe.contentWindow.document,
179 head: this.views.design.iframe.contentWindow.document.head, 180 head: this.views.design.iframe.contentWindow.document.head,
180 body: this.views.design.iframe.contentWindow.document.body 181 body: this.views.design.iframe.contentWindow.document.body,
182 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
181 }, callback.bind(this)); 183 }, callback.bind(this));
182 } else { 184 } else {
183 //TODO: Add logic to save code view data 185 //TODO: Add logic to save code view data
diff --git a/js/document/templates/html/main.js b/js/document/templates/html/main.js
index f45657bb..2696dfa0 100644
--- a/js/document/templates/html/main.js
+++ b/js/document/templates/html/main.js
@@ -42,7 +42,7 @@ exports.Main = Montage.create(Component, {
42 // 42 //
43 window.mjsTemplateCreator = TemplateCreator.create(); 43 window.mjsTemplateCreator = TemplateCreator.create();
44 // 44 //
45 window.mjsTemplate = Template.create(); 45 window.mjsTemplate = Template.create();
46 46
47 47
48 // Dispatch event when this template has loaded. 48 // Dispatch event when this template has loaded.
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index e6f2cc2d..6cdf70fe 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -219,11 +219,24 @@ exports.IoMediator = Montage.create(Component, {
219 parseNinjaTemplateToHtml: { 219 parseNinjaTemplateToHtml: {
220 enumerable: false, 220 enumerable: false,
221 value: function (template, ninjaWrapper) { 221 value: function (template, ninjaWrapper) {
222 var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); 222 //TODO: Improve reference for rootUrl
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])),
225 montageTemplate = template.mjsTemplateCreator.initWithDocument(template.document),
226 mJsSerialization;
227 //Setting up expression for parsing URLs
223 regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); 228 regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi');
224 //Injecting head and body into old document 229 //Injecting head and body into old document
225 template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); 230 if (montageTemplate._ownerSerialization.length > 0) {
226 template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); 231 template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, '');
232 template.file.content.document.body.innerHTML = montageTemplate._document.body.innerHTML.replace(regexRootUrl, '');
233 //
234 mJsSerialization = montageTemplate._ownerSerialization;
235 } else {
236 template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, '');
237 template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, '');
238 }
239
227 //Copying attributes to maintain same properties as the <body> 240 //Copying attributes to maintain same properties as the <body>
228 for (var n in template.body.attributes) { 241 for (var n in template.body.attributes) {
229 if (template.body.attributes[n].value) { 242 if (template.body.attributes[n].value) {
@@ -233,15 +246,6 @@ exports.IoMediator = Montage.create(Component, {
233 } 246 }
234 //TODO: Add attribute copying for <HEAD> and <HTML> 247 //TODO: Add attribute copying for <HEAD> and <HTML>
235 248
236 /*
237 var tc = this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.mjsTemplateCreator, code;
238 code = tc.initWithDocument(this.application.ninja.documentController.activeDocument.model.views.design.iframe.contentWindow.document);
239 console.log(code._ownerSerialization, code._document.getElementsByTagName('html')[0].innerHTML);
240
241 template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, '');
242 template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, '');
243 */
244
245 249
246 250
247 251
@@ -521,7 +525,49 @@ function loadWebGL (e) {\n\
521 525
522 526
523 527
524 528
529 //Checking for Montage
530 if (mJsSerialization) {
531 //Copy Montage library if needed
532 for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) {
533 //Checking for Montage library to be available
534 if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') {
535 mjsDirName = (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name + this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase();
536 mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version;
537 this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName);
538 //TODO: Fix to allow no overwrite and nested locations
539 var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' });
540 } else {
541 //TODO: Error handle no available library to copy
542 }
543 }
544 //
545 if (!mjslibtag) {
546 mjslibtag = template.file.content.document.createElement('script');
547 mjslibtag.setAttribute('type', 'text/javascript');
548 mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js');
549 mjslibtag.setAttribute('data-mjs-lib', 'true');
550 if (ninjaWrapper) {
551 template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag);
552 } else {
553 template.file.content.document.head.appendChild(mjslibtag);
554 }
555
556 }
557 //
558 if (!mjstag) {
559 mjstag = template.file.content.document.createElement('script');
560 mjstag.setAttribute('type', 'text/montage-serialization');
561 if (ninjaWrapper) {
562 template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjstag);
563 } else {
564 template.file.content.document.head.appendChild(mjstag);
565 }
566
567 }
568 //
569 mjstag.innerHTML = mJsSerialization;
570 }
525 571
526 572
527 // 573 //
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js
index 53049cad..fdf744d2 100755
--- a/js/panels/components-panel.reel/components-panel.js
+++ b/js/panels/components-panel.reel/components-panel.js
@@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component,
9 ClassUUID = require("js/components/core/class-uuid").ClassUuid; 9 NJUtils = require("js/lib/NJUtils").NJUtils;
10 10 ClassUUID = require("js/components/core/class-uuid").ClassUuid,
11var PIData = require("js/data/pi/pi-data").PiData; 11 PIData = require("js/data/pi/pi-data").PiData;
12 12
13String.prototype.capitalizeFirstChar = function() { 13String.prototype.capitalizeFirstChar = function() {
14 return this.charAt(0).toUpperCase() + this.slice(1); 14 return this.charAt(0).toUpperCase() + this.slice(1);