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.html6
-rw-r--r--user-document-templates/montage-application-cloud/main.reel/main.js162
-rw-r--r--user-document-templates/montage-application-cloud/package.json2
3 files changed, 166 insertions, 4 deletions
diff --git a/user-document-templates/montage-application-cloud/index.html b/user-document-templates/montage-application-cloud/index.html
index d1f9634d..ac0405ca 100644
--- a/user-document-templates/montage-application-cloud/index.html
+++ b/user-document-templates/montage-application-cloud/index.html
@@ -13,7 +13,7 @@
13 <link href="default_html.css" id="nj-stage-stylesheet" rel="stylesheet" type="text/css" media="screen"/> 13 <link href="default_html.css" id="nj-stage-stylesheet" rel="stylesheet" type="text/css" media="screen"/>
14 <link href="styles.css" id="nj-default-stylesheet" rel="stylesheet" type="text/css" media="screen"/> 14 <link href="styles.css" id="nj-default-stylesheet" rel="stylesheet" type="text/css" media="screen"/>
15 15
16 <script type="text/javascript" data-package="." src="../../node_modules/montage/montage.js"></script> 16 <script type="text/javascript" data-package="." src="../../node_modules/montage-user/montage.js"></script>
17 17
18 <script type="text/javascript"> 18 <script type="text/javascript">
19 function getElement(x,y) { 19 function getElement(x,y) {
@@ -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/main.reel/main.js b/user-document-templates/montage-application-cloud/main.reel/main.js
new file mode 100644
index 00000000..b4ed049f
--- /dev/null
+++ b/user-document-templates/montage-application-cloud/main.reel/main.js
@@ -0,0 +1,162 @@
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> */
6var Montage = require("montage/core/core").Montage,
7 Component = require("montage/ui/component").Component;
8
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 */
20 templateDidLoad: {
21 value: function(){
22 window.addComponent = this.addComponentToUserDocument;
23// window.addBinding = this.addBindingToUserDocument;
24
25 // Dispatch event when this template has loaded.
26 var newEvent = document.createEvent( "CustomEvent" );
27 newEvent.initCustomEvent( "userTemplateDidLoad", false, true );
28
29 document.body.dispatchEvent( newEvent );
30
31 }
32 },
33
34 addComponentToUserDocument:{
35 value:function(containerElement, componentType, callback){
36 var component = null;
37 switch(componentType.type){
38 case "Button":
39
40 var button = require.async(componentType.path)
41 .then(function (button) {
42 var buttonObj = button["Button"];
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
54 break;
55 case "Checkbox":
56 component = Checkbox.create();
57 component.element = containerElement;
58 component.needsDraw = true;
59 break;
60 case "Condition":
61 component = Condition.create();
62 component.element = containerElement;
63 component.needsDraw = true;
64 break;
65 case "DynamicText":
66 component = DynamicText.create();
67 component.element = containerElement;
68 component.value = "Label";
69 component.needsDraw = true;
70 break;
71 case "HotText":
72 component = HotText.create();
73 component.element = containerElement;
74 component.needsDraw = true;
75 break;
76 case "HotTextUnit":
77 component = HotTextUnit.create();
78 component.element = containerElement;
79 component.needsDraw = true;
80 break;
81 case "FlowController":
82 component = FlowController.create();
83 component.element = containerElement;
84 component.needsDraw = true;
85 break;
86 case "ImageContainer":
87 component = ImageContainer.create();
88 component.element = containerElement;
89 component.element.style.width = "285px";
90 component.element.style.height = "235px";
91 component.src = "placeholder.jpg";
92 component.needsDraw = true;
93 break;
94 case "Progress":
95 component = Progress.create();
96 component.element = containerElement;
97 component.loading = true;
98 component.needsDraw = true;
99 break;
100 case "Repetition":
101 component = Repetition.create();
102 component.element = containerElement;
103 component.needsDraw = true;
104 break;
105 case "Scrollview":
106 component = Scrollview.create();
107 component.element = containerElement;
108 component.element.style.width = "200px";
109 component.element.style.height = "200px";
110 var dummyContent = document.createElement("div");
111 dummyContent.innerHTML = "<img src='image3.jpg'/>";
112 component.element.appendChild(dummyContent);
113 component.needsDraw = true;
114 break;
115 case "Slider":
116 component = Slider.create();
117 component.element = containerElement;
118// component.value = 0;
119// component._minValue = 0;
120// component._maxValue = 100;
121 component.needsDraw = true;
122 break;
123 case "Slot":
124 component = Slot.create();
125 component.element = containerElement;
126 component.needsDraw = true;
127 break;
128 case "Substitution":
129 component = Substitution.create();
130 component.element = containerElement;
131 component.needsDraw = true;
132 break;
133 case "TextArea":
134 component = TextArea.create();
135 component.element = containerElement;
136 component.needsDraw = true;
137 break;
138 case "Textfield":
139 component = Textfield.create();
140 component.element = containerElement;
141 component.needsDraw = true;
142 break;
143 case "Toggle":
144 component = Toggle.create();
145 component.element = containerElement;
146 component.needsDraw = true;
147 break;
148 case "ToggleButton":
149 component = ToggleButton.create();
150 component.element = containerElement;
151 component.element.classList.add("text");
152 component.needsDraw = true;
153 break;
154 default:
155 console.log("Unrecognized component type");
156 }
157 //console.log(component);
158 return component;
159 }
160 }
161
162}); \ No newline at end of file
diff --git a/user-document-templates/montage-application-cloud/package.json b/user-document-templates/montage-application-cloud/package.json
index 5466b3d7..4be312d5 100644
--- a/user-document-templates/montage-application-cloud/package.json
+++ b/user-document-templates/montage-application-cloud/package.json
@@ -3,6 +3,6 @@
3 "lib": "" 3 "lib": ""
4 }, 4 },
5 "mappings": { 5 "mappings": {
6 "montage": "../../node_modules/montage/" 6 "montage": "../../node_modules/montage-user/"
7 } 7 }