diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/html-document.js | 4 | ||||
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 43 |
2 files changed, 21 insertions, 26 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index d4db6e2f..be1f89e2 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -905,7 +905,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
905 | } | 905 | } |
906 | } | 906 | } |
907 | } | 907 | } |
908 | return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; | 908 | return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; |
909 | } else if (this.currentView === "code"){ | 909 | } else if (this.currentView === "code"){ |
910 | //TODO: Would this get call when we are in code of HTML? | 910 | //TODO: Would this get call when we are in code of HTML? |
911 | } else { | 911 | } else { |
@@ -928,7 +928,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
928 | } | 928 | } |
929 | } | 929 | } |
930 | } | 930 | } |
931 | return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; | 931 | return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; |
932 | } else if (this.currentView === "code"){ | 932 | } else if (this.currentView === "code"){ |
933 | //TODO: Would this get call when we are in code of HTML? | 933 | //TODO: Would this get call when we are in code of HTML? |
934 | } else { | 934 | } else { |
diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 567f481c..6c141108 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js | |||
@@ -17,7 +17,25 @@ exports.Main = Montage.create(Component, { | |||
17 | */ | 17 | */ |
18 | templateDidLoad: { | 18 | templateDidLoad: { |
19 | value: function(){ | 19 | value: function(){ |
20 | window.addComponent = this.addComponentToUserDocument; | 20 | var self = this; |
21 | window.addComponent = function(element, data, callback) { | ||
22 | var component; | ||
23 | |||
24 | component = require.async(data.path) | ||
25 | .then(function(component) { | ||
26 | var componentRequire = component[data.name]; | ||
27 | var componentInstance = componentRequire.create(); | ||
28 | |||
29 | componentInstance.element = element; | ||
30 | //componentInstance.deserializedFromTemplate(); | ||
31 | componentInstance.needsDraw = true; | ||
32 | componentInstance.ownerComponent = self; | ||
33 | |||
34 | callback(componentInstance, element); | ||
35 | }) | ||
36 | .end(); | ||
37 | |||
38 | }; | ||
21 | // window.addBinding = this.addBindingToUserDocument; | 39 | // window.addBinding = this.addBindingToUserDocument; |
22 | 40 | ||
23 | // Dispatch event when this template has loaded. | 41 | // Dispatch event when this template has loaded. |
@@ -27,28 +45,5 @@ exports.Main = Montage.create(Component, { | |||
27 | document.body.dispatchEvent( newEvent ); | 45 | document.body.dispatchEvent( newEvent ); |
28 | 46 | ||
29 | } | 47 | } |
30 | }, | ||
31 | |||
32 | // Adding components to the user document by using a async require. | ||
33 | addComponentToUserDocument:{ | ||
34 | value:function(element, data, callback){ | ||
35 | |||
36 | var component; | ||
37 | |||
38 | component = require.async(data.path) | ||
39 | .then(function(component) { | ||
40 | var componentRequire = component[data.name]; | ||
41 | var componentInstance = componentRequire.create(); | ||
42 | |||
43 | componentInstance.element = element; | ||
44 | //componentInstance.deserializedFromTemplate(); | ||
45 | componentInstance.needsDraw = true; | ||
46 | |||
47 | callback(componentInstance, element); | ||
48 | }) | ||
49 | .end(); | ||
50 | |||
51 | } | ||
52 | } | 48 | } |
53 | |||
54 | }); \ No newline at end of file | 49 | }); \ No newline at end of file |