aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user-document-templates/montage-application-cloud/appdelegate.js162
1 files changed, 0 insertions, 162 deletions
diff --git a/user-document-templates/montage-application-cloud/appdelegate.js b/user-document-templates/montage-application-cloud/appdelegate.js
deleted file mode 100644
index 3c21b46e..00000000
--- a/user-document-templates/montage-application-cloud/appdelegate.js
+++ /dev/null
@@ -1,162 +0,0 @@
1/* <copyright>
2This 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/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.MyAppDelegate = Montage.create(Component, {
11 templateDidLoad: {
12 value: function(){
13 window.addComponent = this.addComponentToUserDocument;
14 window.addBinding = this.addBindingToUserDocument;
15
16 var newEvent = document.createEvent( "CustomEvent" );
17 newEvent.initCustomEvent( "userTemplateDidLoad", false, true );
18
19 document.body.dispatchEvent( newEvent );
20
21 }
22 },
23
24 addComponentToUserDocument:{
25 value:function(containerElement, componentType){
26 var component = null;
27 switch(componentType){
28 case "Button":
29 component = Button.create();
30 component.element = containerElement;
31 component.element.classList.add("text");
32 component.value = "Button";
33 component.needsDraw = true;
34 break;
35 case "Checkbox":
36 component = Checkbox.create();
37 component.element = containerElement;
38 component.needsDraw = true;
39 break;
40 case "Condition":
41 component = Condition.create();
42 component.element = containerElement;
43 component.needsDraw = true;
44 break;
45 case "DynamicText":
46 component = DynamicText.create();
47 component.element = containerElement;
48 component.value = "Label";
49 component.needsDraw = true;
50 break;
51 case "HotText":
52 component = HotText.create();
53 component.element = containerElement;
54 component.needsDraw = true;
55 break;
56 case "HotTextUnit":
57 component = HotTextUnit.create();
58 component.element = containerElement;
59 component.needsDraw = true;
60 break;
61 case "FlowController":
62 component = FlowController.create();
63 component.element = containerElement;
64 component.needsDraw = true;
65 break;
66 case "ImageContainer":
67 component = ImageContainer.create();
68 component.element = containerElement;
69 component.element.style.width = "285px";
70 component.element.style.height = "235px";
71 component.src = "placeholder.jpg";
72 component.needsDraw = true;
73 break;
74 case "Progress":
75 component = Progress.create();
76 component.element = containerElement;
77 component.loading = true;
78 component.needsDraw = true;
79 break;
80 case "Repetition":
81 component = Repetition.create();
82 component.element = containerElement;
83 component.needsDraw = true;
84 break;
85 case "Scrollview":
86 component = Scrollview.create();
87 component.element = containerElement;
88 component.element.style.width = "200px";
89 component.element.style.height = "200px";
90 var dummyContent = document.createElement("div");
91 dummyContent.innerHTML = "<img src='image3.jpg'/>";
92 component.element.appendChild(dummyContent);
93 component.needsDraw = true;
94 break;
95 case "Slider":
96 component = Slider.create();
97 component.element = containerElement;
98// component.value = 0;
99// component._minValue = 0;
100// component._maxValue = 100;
101 component.needsDraw = true;
102 break;
103 case "Slot":
104 component = Slot.create();
105 component.element = containerElement;
106 component.needsDraw = true;
107 break;
108 case "Substitution":
109 component = Substitution.create();
110 component.element = containerElement;
111 component.needsDraw = true;
112 break;
113 case "TextArea":
114 component = TextArea.create();
115 component.element = containerElement;
116 component.needsDraw = true;
117 break;
118 case "Textfield":
119 component = Textfield.create();
120 component.element = containerElement;
121 component.needsDraw = true;
122 break;
123 case "Toggle":
124 component = Toggle.create();
125 component.element = containerElement;
126 component.needsDraw = true;
127 break;
128 case "ToggleButton":
129 component = ToggleButton.create();
130 component.element = containerElement;
131 component.element.classList.add("text");
132 component.needsDraw = true;
133 break;
134 default:
135 console.log("Unrecognized component type");
136 }
137 //console.log(component);
138 return component;
139 }
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 }
162}); \ No newline at end of file