diff options
author | Valerio Virgillito | 2012-02-17 15:24:49 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-17 15:24:49 -0800 |
commit | 7789a48fab2b1541ef7ac1b94e14b3f8dccbb4ff (patch) | |
tree | 328e6fe964cfcbe6ff47ad6eecf81275da31364f /js/document/templates/montage-html/main.reel/main.js | |
parent | 824927fde259c891a67f18311a8abc470cd48442 (diff) | |
parent | 041abe1f27378f095d3a6d5584559463959e0787 (diff) | |
download | ninja-7789a48fab2b1541ef7ac1b94e14b3f8dccbb4ff.tar.gz |
Merge pull request #53 from joseeight/FileIO
File IO local files webRequest redirect
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 | ||