diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/document/models/base.js | 6 | ||||
-rw-r--r-- | js/document/templates/html/main.js | 4 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 84 | ||||
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 6 |
4 files changed, 50 insertions, 50 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..ffa3fab2 100644 --- a/js/document/templates/html/main.js +++ b/js/document/templates/html/main.js | |||
@@ -40,9 +40,9 @@ exports.Main = Montage.create(Component, { | |||
40 | 40 | ||
41 | }; | 41 | }; |
42 | // | 42 | // |
43 | window.mjsTemplateCreator = TemplateCreator.create(); | 43 | window.mjsTemplateCreator = TemplateCreator; |
44 | // | 44 | // |
45 | window.mjsTemplate = Template.create(); | 45 | window.mjsTemplate = Template; |
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..b1916446 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -219,11 +219,27 @@ 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 | mjsCreator = template.mjsTemplateCreator.create(), | ||
226 | mJsSerialization, | ||
227 | montageTemplate; | ||
228 | // | ||
229 | montageTemplate = mjsCreator.initWithDocument(template.document); | ||
230 | //Setting up expression for parsing URLs | ||
223 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); | 231 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); |
224 | //Injecting head and body into old document | 232 | //Injecting head and body into old document |
225 | template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); | 233 | if (montageTemplate._ownerSerialization.length > 0) { |
226 | template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); | 234 | template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, ''); |
235 | template.file.content.document.body.innerHTML = montageTemplate._document.body.innerHTML.replace(regexRootUrl, ''); | ||
236 | // | ||
237 | mJsSerialization = montageTemplate._ownerSerialization; | ||
238 | } else { | ||
239 | template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); | ||
240 | template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); | ||
241 | } | ||
242 | |||
227 | //Copying attributes to maintain same properties as the <body> | 243 | //Copying attributes to maintain same properties as the <body> |
228 | for (var n in template.body.attributes) { | 244 | for (var n in template.body.attributes) { |
229 | if (template.body.attributes[n].value) { | 245 | if (template.body.attributes[n].value) { |
@@ -233,15 +249,6 @@ exports.IoMediator = Montage.create(Component, { | |||
233 | } | 249 | } |
234 | //TODO: Add attribute copying for <HEAD> and <HTML> | 250 | //TODO: Add attribute copying for <HEAD> and <HTML> |
235 | 251 | ||
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 | 252 | ||
246 | 253 | ||
247 | 254 | ||
@@ -429,7 +436,7 @@ exports.IoMediator = Montage.create(Component, { | |||
429 | if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) { | 436 | if (scripts[i].getAttribute('data-ninja-webgl-rdge') !== null) { |
430 | webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags | 437 | webglrdgetag = scripts[i]; // TODO: Add logic to delete unneccesary tags |
431 | } | 438 | } |
432 | if (scripts[i].getAttribute('type') !== 'text/montage-serialization') { | 439 | if (scripts[i].getAttribute('type') === 'text/montage-serialization') { |
433 | mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags | 440 | mjstag = scripts[i]; // TODO: Add logic to delete unneccesary tags |
434 | } | 441 | } |
435 | if (scripts[i].getAttribute('data-mjs-lib') !== null) { | 442 | if (scripts[i].getAttribute('data-mjs-lib') !== null) { |
@@ -521,21 +528,10 @@ function loadWebGL (e) {\n\ | |||
521 | 528 | ||
522 | 529 | ||
523 | 530 | ||
524 | 531 | ||
525 | 532 | //Checking for Montage | |
526 | 533 | if (mJsSerialization) { | |
527 | // | 534 | //Copy Montage library if needed |
528 | |||
529 | /* | ||
530 | for (var m in template.mjs) { | ||
531 | mjsComponents.push(template.mjs[m]); | ||
532 | mjsCounter++; | ||
533 | } | ||
534 | // | ||
535 | if (template.mjs && mjsCounter > 0) { | ||
536 | var mjsDirName, mjsVersion, | ||
537 | mjscode = temp.initWithHeadAndBodyElements(template.file.content.document.documentElement.head, template.file.content.document.documentElement.body, mjsComponents)._ownerSerialization; | ||
538 | //Copy Montage library if needed | ||
539 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { | 535 | for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { |
540 | //Checking for Montage library to be available | 536 | //Checking for Montage library to be available |
541 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { | 537 | if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Montage') { |
@@ -543,7 +539,7 @@ for (var m in template.mjs) { | |||
543 | mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; | 539 | mjsVersion = this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version; |
544 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); | 540 | this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.file.root, mjsDirName); |
545 | //TODO: Fix to allow no overwrite and nested locations | 541 | //TODO: Fix to allow no overwrite and nested locations |
546 | var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/"}}' }); | 542 | var packjson = this.application.ninja.coreIoApi.createFile({ uri: template.file.root + 'package.json', contents: '{"mappings": {"montage": "' + mjsDirName + '/montage/"}}' }); |
547 | } else { | 543 | } else { |
548 | //TODO: Error handle no available library to copy | 544 | //TODO: Error handle no available library to copy |
549 | } | 545 | } |
@@ -552,27 +548,30 @@ for (var m in template.mjs) { | |||
552 | if (!mjslibtag) { | 548 | if (!mjslibtag) { |
553 | mjslibtag = template.file.content.document.createElement('script'); | 549 | mjslibtag = template.file.content.document.createElement('script'); |
554 | mjslibtag.setAttribute('type', 'text/javascript'); | 550 | mjslibtag.setAttribute('type', 'text/javascript'); |
555 | mjslibtag.setAttribute('src', mjsDirName + '/montage.js'); | 551 | mjslibtag.setAttribute('src', mjsDirName + '/montage/montage.js'); |
556 | mjslibtag.setAttribute('data-mjs-lib', 'true'); | 552 | mjslibtag.setAttribute('data-mjs-lib', 'true'); |
557 | template.file.content.document.head.appendChild(mjslibtag); | 553 | if (ninjaWrapper) { |
554 | template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjslibtag); | ||
555 | } else { | ||
556 | template.file.content.document.head.appendChild(mjslibtag); | ||
557 | } | ||
558 | |||
558 | } | 559 | } |
559 | // | 560 | // |
560 | if (!mjstag) { | 561 | if (!mjstag) { |
561 | mjstag = template.file.content.document.createElement('script'); | 562 | mjstag = template.file.content.document.createElement('script'); |
562 | mjstag.setAttribute('type', 'text/montage-serialization'); | 563 | mjstag.setAttribute('type', 'text/montage-serialization'); |
563 | template.file.content.document.head.appendChild(mjstag); | 564 | if (ninjaWrapper) { |
565 | template.file.content.document.body.getElementsByTagName('ninja-content')[0].appendChild(mjstag); | ||
566 | } else { | ||
567 | template.file.content.document.head.appendChild(mjstag); | ||
568 | } | ||
569 | |||
564 | } | 570 | } |
565 | // | 571 | // |
566 | mjstag.innerHTML = mjscode; | 572 | mjstag.innerHTML = mJsSerialization; |
567 | } | 573 | mjsCreator = null; |
568 | */ | 574 | } |
569 | |||
570 | |||
571 | |||
572 | |||
573 | |||
574 | |||
575 | |||
576 | //Cleaning URLs from HTML | 575 | //Cleaning URLs from HTML |
577 | var cleanHTML; | 576 | var cleanHTML; |
578 | if (ninjaWrapper) { | 577 | if (ninjaWrapper) { |
@@ -593,7 +592,6 @@ for (var m in template.mjs) { | |||
593 | cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); | 592 | cleanHTML = cleanHTML.replace(/ninja-viewport/gi, 'div'); |
594 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); | 593 | cleanHTML = cleanHTML.replace(/ninja-content/gi, 'div'); |
595 | } | 594 | } |
596 | |||
597 | // | 595 | // |
598 | return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); | 596 | return this.getPrettyHtml(cleanHTML.replace(this.getAppTemplatesUrlRegEx(), '')); |
599 | } | 597 | } |
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 37fd9b44..e028d1db 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 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var 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; |