diff options
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 | ||