diff options
-rwxr-xr-x | js/document/models/html.js | 25 | ||||
-rwxr-xr-x | js/document/views/design.js | 14 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 37 | ||||
-rwxr-xr-x[-rw-r--r--] | node_modules/tools/template/template-creator.js (renamed from node_modules/tools/template-creator.js) | 40 |
4 files changed, 74 insertions, 42 deletions
diff --git a/js/document/models/html.js b/js/document/models/html.js index 2764a6d6..b57ff832 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -24,28 +24,28 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
24 | }, | 24 | }, |
25 | //////////////////////////////////////////////////////////////////// | 25 | //////////////////////////////////////////////////////////////////// |
26 | // | 26 | // |
27 | baseHref: { | ||
28 | value: null | ||
29 | }, | ||
30 | //////////////////////////////////////////////////////////////////// | ||
31 | // | ||
27 | webGlHelper: { | 32 | webGlHelper: { |
28 | value: webGlDocumentHelper | 33 | value: webGlDocumentHelper |
29 | }, | 34 | }, |
30 | //////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////// |
31 | //////////////////////////////////////////////////////////////////// | 36 | // |
32 | userComponents: { | 37 | userComponents: { |
33 | value: {} | 38 | value: {} |
34 | }, | 39 | }, |
35 | 40 | //////////////////////////////////////////////////////////////////// | |
36 | /** | 41 | //Add a reference to a component instance to the userComponents hash using the element UUID |
37 | * Add a reference to a component instance to the userComponents hash using the | ||
38 | * element UUID | ||
39 | */ | ||
40 | setComponentInstance: { | 42 | setComponentInstance: { |
41 | value: function(instance, el) { | 43 | value: function(instance, el) { |
42 | this.userComponents[el.uuid] = instance; | 44 | this.userComponents[el.uuid] = instance; |
43 | } | 45 | } |
44 | }, | 46 | }, |
45 | 47 | //////////////////////////////////////////////////////////////////// | |
46 | /** | 48 | //Returns the component instance obj from the element |
47 | * Returns the component instance obj from the element | ||
48 | */ | ||
49 | getComponentFromElement: { | 49 | getComponentFromElement: { |
50 | value: function(el) { | 50 | value: function(el) { |
51 | if(el) { | 51 | if(el) { |
@@ -55,7 +55,8 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | //////////////////////////////////////////////////////////////////// | |
59 | //////////////////////////////////////////////////////////////////// | ||
59 | }); | 60 | }); |
60 | //////////////////////////////////////////////////////////////////////// | 61 | //////////////////////////////////////////////////////////////////////// |
61 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 62 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |
diff --git a/js/document/views/design.js b/js/document/views/design.js index 9ad088cb..765099e6 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -42,6 +42,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
42 | value: null | 42 | value: null |
43 | }, | 43 | }, |
44 | //////////////////////////////////////////////////////////////////// | 44 | //////////////////////////////////////////////////////////////////// |
45 | //TODO: Remove usage | ||
46 | model: { | ||
47 | value: null | ||
48 | }, | ||
49 | //////////////////////////////////////////////////////////////////// | ||
45 | // | 50 | // |
46 | document: { | 51 | document: { |
47 | get: function() {return this._document;}, | 52 | get: function() {return this._document;}, |
@@ -78,6 +83,8 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
78 | // | 83 | // |
79 | onTemplateLoad: { | 84 | onTemplateLoad: { |
80 | value: function (e) { | 85 | value: function (e) { |
86 | //TODO: Add support to constructing URL with a base HREF | ||
87 | var basetag = this.content.document.getElementsByTagName('base'); | ||
81 | //Removing event | 88 | //Removing event |
82 | this.iframe.removeEventListener("load", this.onTemplateLoad.bind(this), false); | 89 | this.iframe.removeEventListener("load", this.onTemplateLoad.bind(this), false); |
83 | //TODO: Improve usage of this reference | 90 | //TODO: Improve usage of this reference |
@@ -88,6 +95,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
88 | this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); | 95 | this.document.styleSheets[k].ownerNode.setAttribute('data-ninja-template', 'true'); |
89 | } | 96 | } |
90 | } | 97 | } |
98 | //Checking for a base URL | ||
99 | if (basetag.length) { | ||
100 | if (basetag[basetag.length-1].getAttribute && basetag[basetag.length-1].getAttribute('href')) { | ||
101 | //Setting base HREF in model | ||
102 | this.model.baseHref = basetag[basetag.length-1].getAttribute('href'); | ||
103 | } | ||
104 | } | ||
91 | //Creating temp code fragement to load head | 105 | //Creating temp code fragement to load head |
92 | this._headFragment = this.document.createElement('head'); | 106 | this._headFragment = this.document.createElement('head'); |
93 | //Adding event listener to know when head is ready, event only dispatched once when using innerHTML | 107 | //Adding event listener to know when head is ready, event only dispatched once when using innerHTML |
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 6d146c97..dae0f359 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js | |||
@@ -10,7 +10,7 @@ var Montage = require("montage/core/core").Montage, | |||
10 | Component = require("montage/ui/component").Component, | 10 | Component = require("montage/ui/component").Component, |
11 | FileIo = require("js/io/system/fileio").FileIo, | 11 | FileIo = require("js/io/system/fileio").FileIo, |
12 | ProjectIo = require("js/io/system/projectio").ProjectIo, | 12 | ProjectIo = require("js/io/system/projectio").ProjectIo, |
13 | TemplateCreator = require("node_modules/tools/template-creator").TemplateCreator; | 13 | TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator; |
14 | //////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////// |
15 | // | 15 | // |
16 | exports.IoMediator = Montage.create(Component, { | 16 | exports.IoMediator = Montage.create(Component, { |
@@ -205,15 +205,34 @@ exports.IoMediator = Montage.create(Component, { | |||
205 | //Injecting head and body into old document | 205 | //Injecting head and body into old document |
206 | template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); | 206 | template.file.content.document.head.innerHTML = template.head.innerHTML.replace(regexRootUrl, ''); |
207 | template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); | 207 | template.file.content.document.body.innerHTML = template.body.innerHTML.replace(regexRootUrl, ''); |
208 | |||
209 | |||
210 | |||
211 | /* | ||
212 | //Testing using montage clean up method | ||
213 | var mjscode, mjsTemp = TemplateCreator.create(); | ||
214 | |||
215 | //mjscode = mjsTemp.initWithHeadAndBodyElements(template.head, template.body); | ||
216 | //mjscode = mjsTemp.initWithDocument(template.file.content.document); | ||
217 | mjscode = mjsTemp.initWithDocument(template.document); | ||
218 | |||
219 | console.log(template.head, mjscode._document.head); | ||
220 | template.file.content.document.head.innerHTML = mjscode._document.head.innerHTML.replace(regexRootUrl, ''); | ||
221 | template.file.content.document.body.innerHTML = mjscode._document.body.innerHTML.replace(regexRootUrl, ''); | ||
222 | */ | ||
223 | |||
224 | |||
225 | |||
226 | |||
208 | //Getting all CSS (style or link) tags | 227 | //Getting all CSS (style or link) tags |
209 | var styletags = template.file.content.document.getElementsByTagName('style'), | 228 | var styletags = template.file.content.document.getElementsByTagName('style'), |
210 | linktags = template.file.content.document.getElementsByTagName('link'), | 229 | linktags = template.file.content.document.getElementsByTagName('link'), |
211 | toremovetags = [], | 230 | toremovetags = [], |
212 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'), | 231 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); |
213 | basetags = template.file.content.document.getElementsByTagName('base'); | ||
214 | 232 | ||
215 | ////////////////////////////////////////////////// | 233 | ////////////////////////////////////////////////// |
216 | //TODO: Remove, temp hack to avoid montage | 234 | //TODO: Remove, temp hack, this is to be fixed by Montage |
235 | var basetags = template.file.content.document.getElementsByTagName('base'); | ||
217 | for (var g in basetags) { | 236 | for (var g in basetags) { |
218 | if (basetags[g].getAttribute) toremovetags.push(basetags[g]); | 237 | if (basetags[g].getAttribute) toremovetags.push(basetags[g]); |
219 | } | 238 | } |
@@ -469,9 +488,9 @@ function loadWebGL (e) {\n\ | |||
469 | 488 | ||
470 | 489 | ||
471 | // | 490 | // |
472 | var mjsCounter = 0, mjsComponents = [], temp = TemplateCreator.create(); | 491 | |
473 | // | 492 | /* |
474 | for (var m in template.mjs) { | 493 | for (var m in template.mjs) { |
475 | mjsComponents.push(template.mjs[m]); | 494 | mjsComponents.push(template.mjs[m]); |
476 | mjsCounter++; | 495 | mjsCounter++; |
477 | } | 496 | } |
@@ -509,6 +528,7 @@ function loadWebGL (e) {\n\ | |||
509 | // | 528 | // |
510 | mjstag.innerHTML = mjscode; | 529 | mjstag.innerHTML = mjscode; |
511 | } | 530 | } |
531 | */ | ||
512 | 532 | ||
513 | 533 | ||
514 | 534 | ||
@@ -570,7 +590,8 @@ function loadWebGL (e) {\n\ | |||
570 | // | 590 | // |
571 | getDocRootUrl: { | 591 | getDocRootUrl: { |
572 | value: function () { | 592 | value: function () { |
573 | return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | 593 | //TODO: Add support for model.baseHref (base tag) |
594 | return this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); | ||
574 | } | 595 | } |
575 | }, | 596 | }, |
576 | //////////////////////////////////////////////////////////////////// | 597 | //////////////////////////////////////////////////////////////////// |
diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template/template-creator.js index e312cd32..1cd65ddd 100644..100755 --- a/node_modules/tools/template-creator.js +++ b/node_modules/tools/template/template-creator.js | |||
@@ -23,39 +23,38 @@ var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @le | |||
23 | return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); | 23 | return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); |
24 | } | 24 | } |
25 | }, | 25 | }, |
26 | 26 | ||
27 | initWithBodyElement: { | 27 | initWithBodyElement: { |
28 | value: function(body, montageJsPath) { | 28 | value: function(body, montageJsPath) { |
29 | return this.initWithHeadAndBodyElements(null, body, montageJsPath); | 29 | return this.initWithHeadAndBodyElements(null, body, montageJsPath); |
30 | } | 30 | } |
31 | }, | 31 | }, |
32 | 32 | ||
33 | initWithHeadAndBodyElements: { | 33 | initWithHeadAndBodyElements: { |
34 | value: function(head, body, components, montageJsPath) { | 34 | value: function(head, body, montageJsPath) { |
35 | var serializer = this.serializer, | 35 | var serializer = this.serializer, |
36 | objects = {}, | 36 | objects = {}, |
37 | //components = {}, | 37 | components = {}, |
38 | doc, | 38 | doc, |
39 | script, | 39 | script, |
40 | self = this; | 40 | self = this; |
41 | 41 | ||
42 | this._objectNamesIndex = {}; |