diff options
Diffstat (limited to 'js/document/templates/montage-html/main.reel/main.js')
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js new file mode 100644 index 00000000..567f481c --- /dev/null +++ b/js/document/templates/montage-html/main.reel/main.js | |||
@@ -0,0 +1,54 @@ | |||
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 | exports.Main = Montage.create(Component, { | ||
10 | |||
11 | hasTemplate: { | ||
12 | value: false | ||
13 | }, | ||
14 | |||
15 | /** | ||
16 | * Adding window hooks to callback into this object from Ninja. | ||
17 | */ | ||
18 | templateDidLoad: { | ||
19 | value: function(){ | ||
20 | window.addComponent = this.addComponentToUserDocument; | ||
21 | // window.addBinding = this.addBindingToUserDocument; | ||
22 | |||
23 | // Dispatch event when this template has loaded. | ||
24 | var newEvent = document.createEvent( "CustomEvent" ); | ||
25 | newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); | ||
26 | |||
27 | document.body.dispatchEvent( newEvent ); | ||
28 | |||
29 | } | ||
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 | } | ||
53 | |||
54 | }); \ No newline at end of file | ||