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)92
2 files changed, 53 insertions, 43 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..2e331cdc 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,16 +32,41 @@ 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;
55 case "Textfield":
56 var tf = require.async(componentType.path)
57 .then(function (tf) {
58 var buttonObj = tf["Textfield"];
59 var btIns = buttonObj.create();
60
61 btIns.element = containerElement;
62 btIns.deserializedFromTemplate();
63
64 btIns.needsDraw = true;
65 btIns.value = "Button";
66 callback(btIns, containerElement);
67 })
68 .end();
69 break
35 case "Checkbox": 70 case "Checkbox":
36 component = Checkbox.create(); 71 component = Checkbox.create();
37 component.element = containerElement; 72 component.element = containerElement;
@@ -115,11 +150,6 @@ exports.MyAppDelegate = Montage.create(Component, {
115 component.element = containerElement; 150 component.element = containerElement;
116 component.needsDraw = true; 151 component.needsDraw = true;
117 break; 152 break;
118 case "Textfield":
119 component = Textfield.create();
120 component.element = containerElement;
121 component.needsDraw = true;
122 break;
123 case "Toggle": 153 case "Toggle":
124 component = Toggle.create(); 154 component = Toggle.create();
125 component.element = containerElement; 155 component.element = containerElement;
@@ -137,26 +167,6 @@ exports.MyAppDelegate = Montage.create(Component, {
137 //console.log(component); 167 //console.log(component);
138 return component; 168 return component;
139 } 169 }
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 } 170 }
171
162}); \ No newline at end of file 172}); \ No newline at end of file