aboutsummaryrefslogtreecommitdiff
path: root/user-document-templates
diff options
context:
space:
mode:
Diffstat (limited to 'user-document-templates')
-rw-r--r--user-document-templates/montage-application-cloud/index.html4
-rw-r--r--user-document-templates/montage-application-cloud/main.reel/main.js (renamed from user-document-templates/montage-application-cloud/appdelegate.js)72
2 files changed, 38 insertions, 38 deletions
diff --git a/user-document-templates/montage-application-cloud/index.html b/user-document-templates/montage-application-cloud/index.html
index d1f9634d..0db684cc 100644
--- a/user-document-templates/montage-application-cloud/index.html
+++ b/user-document-templates/montage-application-cloud/index.html
@@ -24,8 +24,8 @@
24 <script type="text/montage-serialization"> 24 <script type="text/montage-serialization">
25 { 25 {
26 "owner": { 26 "owner": {
27 "module": "./appdelegate", 27 "module": "main.reel",
28 "name": "MyAppDelegate" 28 "name": "Main"
29 } 29 }
30 } 30 }
31 </script> 31 </script>
diff --git a/user-document-templates/montage-application-cloud/appdelegate.js b/user-document-templates/montage-application-cloud/main.reel/main.js
index 3c21b46e..b4ed049f 100644
--- a/user-document-templates/montage-application-cloud/appdelegate.js
+++ b/user-document-templates/montage-application-cloud/main.reel/main.js
@@ -1,18 +1,28 @@
1/* <copyright> 1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<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. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5 </copyright> */
6
7var Montage = require("montage/core/core").Montage, 6var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 7 Component = require("montage/ui/component").Component;
9 8
10exports.MyAppDelegate = Montage.create(Component, { 9//var Button = ("montage/ui/button.reel").Button;
10
11exports.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 */
11 templateDidLoad: { 20 templateDidLoad: {
12 value: function(){ 21 value: function(){
13 window.addComponent = this.addComponentToUserDocument; 22 window.addComponent = this.addComponentToUserDocument;
14 window.addBinding = this.addBindingToUserDocument; 23// window.addBinding = this.addBindingToUserDocument;
15 24
25 // Dispatch event when this template has loaded.
16 var newEvent = document.createEvent( "CustomEvent" ); 26 var newEvent = document.createEvent( "CustomEvent" );
17 newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); 27 newEvent.initCustomEvent( "userTemplateDidLoad", false, true );
18 28
@@ -22,15 +32,25 @@ exports.MyAppDelegate = Montage.create(Component, {
22 }, 32 },
23 33
24 addComponentToUserDocument:{ 34 addComponentToUserDocument:{
25 value:function(containerElement, componentType){ 35 value:function(containerElement, componentType, callback){
26 var component = null; 36 var component = null;
27 switch(componentType){ 37 switch(componentType.type){
28 case "Button": 38 case "Button":
29 component = Button.create(); 39
30 component.element = containerElement; 40 var button = require.async(componentType.path)
31 component.element.classList.add("text"); 41 .then(function (button) {
32 component.value = "Button"; 42 var buttonObj = button["Button"];
33 component.needsDraw = true; 43 var btIns = buttonObj.create();
44
45 btIns.element = containerElement;
46 btIns.deserializedFromTemplate();
47
48 btIns.needsDraw = true;
49 btIns.label = "Button";
50 callback(btIns, containerElement);
51 })
52 .end();
53
34 break; 54 break;
35 case "Checkbox": 55 case "Checkbox":
36 component = Checkbox.create(); 56 component = Checkbox.create();
@@ -137,26 +157,6 @@ exports.MyAppDelegate = Montage.create(Component, {
137 //console.log(component); 157 //console.log(component);
138 return component; 158 return component;
139 } 159 }
140 },
141 addBindingToUserDocument:{
142 value:function(boundComponent, boundValue, targetComponent, targetValue){
143 if(targetComponent[targetValue] != undefined && boundComponent[boundValue] != undefined){
144 Object.defineBinding(boundComponent, boundValue, {
145 boundObject: targetComponent,
146 boundObjectPropertyPath: targetValue,
147 boundValueMutator: function(value) {
148 return(value);
149 }
150 });
151 } else {
152 if(targetComponent[targetValue] == undefined){
153 console.log("Binding Fail - Component Property Not Found: " + targetValue);
154 alert("Binding Failed - Component Property Not Found: " + targetValue)
155 } else if(boundComponent[boundValue] == undefined){
156 console.log("Binding Fail - Component Property Not Found: " + boundValue);
157 alert("Binding Failed - Component Property Not Found: " + boundValue);
158 }
159 }
160 }
161 } 160 }
161
162}); \ No newline at end of file 162}); \ No newline at end of file