diff options
author | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
commit | 89b5e793ea88ef235b54b6e1d1c379698d3e612b (patch) | |
tree | 4d29118f35df77ca6b423119a4ff61694a442cbf /user-document-templates/montage-application-cloud/main.reel | |
parent | 9d2c2a80483415d7560b00cda5519153db23e241 (diff) | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-89b5e793ea88ef235b54b6e1d1c379698d3e612b.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
Diffstat (limited to 'user-document-templates/montage-application-cloud/main.reel')
-rw-r--r-- | user-document-templates/montage-application-cloud/main.reel/main.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/user-document-templates/montage-application-cloud/main.reel/main.js b/user-document-templates/montage-application-cloud/main.reel/main.js new file mode 100644 index 00000000..86871fd3 --- /dev/null +++ b/user-document-templates/montage-application-cloud/main.reel/main.js | |||
@@ -0,0 +1,55 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | var Montage = require("montage/core/core").Montage, | ||
7 | Component = require("montage/ui/component").Component; | ||
8 | |||
9 | //var Button = ("montage/ui/button.reel").Button; | ||
10 | |||
11 | exports.Main = Montage.create(Component, { | ||
12 | |||
13 | hasTemplate: { | ||
14 | value: false | ||
15 | }, | ||
16 | |||
17 | /** | ||
18 | * Adding window hooks to callback into this object from Ninja. | ||
19 | */ | ||
20 | templateDidLoad: { | ||
21 | value: function(){ | ||
22 | window.addComponent = this.addComponentToUserDocument; | ||
23 | // window.addBinding = this.addBindingToUserDocument; | ||
24 | |||
25 | // Dispatch event when this template has loaded. | ||
26 | var newEvent = document.createEvent( "CustomEvent" ); | ||
27 | newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); | ||
28 | |||
29 | document.body.dispatchEvent( newEvent ); | ||
30 | |||
31 | } | ||
32 | }, | ||
33 | |||
34 | addComponentToUserDocument:{ | ||
35 | value:function(element, data, callback){ | ||
36 | |||
37 | var component; | ||
38 | |||
39 | component = require.async(data.path) | ||
40 | .then(function(component) { | ||
41 | var componentRequire = component[data.name]; | ||
42 | var componentInstance = componentRequire.create(); | ||
43 | |||
44 | componentInstance.element = element; | ||
45 | componentInstance.deserializedFromTemplate(); | ||
46 | componentInstance.needsDraw = true; | ||
47 | |||
48 | callback(componentInstance, element); | ||
49 | }) | ||
50 | .end(); | ||
51 | |||
52 | } | ||
53 | } | ||
54 | |||
55 | }); \ No newline at end of file | ||