diff options
author | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-27 09:32:53 -0700 |
commit | 406bbfc63f8ed42d7da105dbd068a49ff8fb5f09 (patch) | |
tree | 3a8b45f4802f002269ff1bcf596f94cee4679a07 /js/document/templates/montage-html/main.reel | |
parent | bda9f8f5829c943486f8850e68c991e83f8fb8c8 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-406bbfc63f8ed42d7da105dbd068a49ff8fb5f09.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/document/templates/montage-html/main.reel')
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 567f481c..019c675e 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js | |||
@@ -17,38 +17,32 @@ 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.addBinding = this.addBindingToUserDocument; | 21 | window.addComponent = function(element, data, callback) { |
22 | var component; | ||
22 | 23 | ||
23 | // Dispatch event when this template has loaded. | 24 | component = require.async(data.path) |
24 | var newEvent = document.createEvent( "CustomEvent" ); | 25 | .then(function(component) { |
25 | newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); | 26 | var componentRequire = component[data.name]; |
27 | var componentInstance = componentRequire.create(); | ||
26 | 28 | ||
27 | document.body.dispatchEvent( newEvent ); | 29 | componentInstance.element = element; |
28 | |||
29 | } | ||
30 | }, | ||
31 | 30 | ||
32 | // Adding components to the user document by using a async require. | 31 | componentInstance.needsDraw = true; |
33 | addComponentToUserDocument:{ | 32 | componentInstance.ownerComponent = self; |
34 | value:function(element, data, callback){ | ||
35 | 33 | ||
36 | var component; | 34 | callback(componentInstance, element); |
35 | }) | ||
36 | .end(); | ||
37 | 37 | ||
38 | component = require.async(data.path) | 38 | }; |
39 | .then(function(component) { | ||
40 | var componentRequire = component[data.name]; | ||
41 | var componentInstance = componentRequire.create(); | ||
42 | 39 | ||
43 | componentInstance.element = element; | 40 | // Dispatch event when this template has loaded. |
44 | //componentInstance.deserializedFromTemplate(); | 41 | var newEvent = document.createEvent( "CustomEvent" ); |
45 | componentInstance.needsDraw = true; | 42 | newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); |
46 | 43 | ||
47 | callback(componentInstance, element); | 44 | document.body.dispatchEvent( newEvent ); |
48 | }) | ||
49 | .end(); | ||
50 | 45 | ||
51 | } | 46 | } |
52 | } | 47 | } |
53 | |||
54 | }); \ No newline at end of file | 48 | }); \ No newline at end of file |