aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js')
-rwxr-xr-xjs/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js352
1 files changed, 0 insertions, 352 deletions
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
deleted file mode 100755
index b6bee37d..00000000
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ /dev/null
@@ -1,352 +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 NJUtils = require("js/lib/NJUtils").NJUtils;
10
11var treeControlModule = require("js/components/tree.reel");
12var PIData = require("js/data/pi/pi-data").PiData;
13
14String.prototype.capitalizeFirstChar = function() {
15 return this.charAt(0).toUpperCase() + this.slice(1);
16};
17
18
19var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, {
20
21 components: {
22 value: {
23 "text": "styles",
24 "children": [
25 {
26 "text": "Montage Components",
27 "children": [
28 {
29 "text": "Anchor",
30 "dataFile" : "node_modules/components-data/anchor.json",
31 "component": "anchor"
32 },
33 {
34 "text": "Button",
35 "dataFile" : "node_modules/components-data/button.json",
36 "component": "button"
37 },
38 {
39 "text": "Checkbox",
40 "dataFile" : "node_modules/components-data/checkbox.json",
41 "component": "checkbox"
42 },
43 {
44 "text": "Image Component",
45 "dataFile" : "node_modules/components-data/image.json",
46 "component": "imageComponent"
47 },
48 {
49 "text": "NumberInput",
50 "dataFile" : "node_modules/components-data/number-input.json",
51 "component": "numberInput"
52 },
53 {
54 "text": "Select Input",
55 "dataFile" : "node_modules/components-data/select.json",
56 "component": "select"
57 },
58 {
59 "text": "Radio Button",
60 "dataFile" : "node_modules/components-data/radio-button.json",
61 "component": "radioButton"
62 },
63 {
64 "text": "Range Input",
65 "dataFile" : "node_modules/components-data/range-input.json",
66 "component": "rangeInput"
67 },
68 {
69 "text": "TextArea",
70 "dataFile" : "node_modules/components-data/textarea.json",
71 "component": "textarea"
72 },
73 {
74 "text": "Textfield",
75 "dataFile" : "node_modules/components-data/textfield.json",
76 "component": "textfield"
77 },
78 {
79 "text": "Toogle Button",
80 "dataFile" : "node_modules/components-data/toggle-button.json",
81 "component": "toggleButton"
82 }
83 ]
84 }
85 ]
86 }
87 },
88
89 componentsData: {
90 value: {}
91 },
92
93 componentsToLoad: {
94 value: null
95 },
96
97 componentsLoaded: {
98 value: 0
99 },
100
101 dragComponent: {
102 value: null
103 },
104
105 dragPosition: {
106 value: null
107 },
108
109 centerStage: {
110 value: null
111 },
112
113
114 /*********************************************************************
115 * Components Tree and Model Creation
116 *********************************************************************/
117
118 didCreate: {
119 value: function() {
120 // Setup the drop delegate
121// this.application.ninja.dragDropMediator.dropDelegate = this;
122 // Loop through the component and load the JSON data for them
123 this._loadComponents();
124 }
125 },
126
127 // Load all the data files for each component
128 // TODO: Implement the error case
129 _loadComponents: {
130 value: function() {
131
132 this.componentsToLoad = this.components.children[0].children.length;
133
134 for(var i = 0, component; component = this.components.children[0].children[i]; i++) {
135 var req = new XMLHttpRequest();
136 //req.identifier = "searchRequest";
137 req.open("GET", component.dataFile);
138 req.addEventListener("load", this, false);
139 req.addEventListener("error", this, false);
140 req.send();
141 }
142 }
143 },
144
145 handleLoad: {
146 value: function(evt) {
147 var componentData, component, piID, piObj, section;
148
149 componentData = JSON.parse(evt.target.responseText);
150
151 component = componentData.name;
152
153 // Build the PI data and create a new object for Ninja PI
154 piID = component + "Pi";
155 piObj = [];
156 section = {};
157 section.label = component + " Properties";
158 section.Section = [];
159
160 for(var j = 0, props; props = componentData.properties[j]; j++) {
161 var row = {};
162 row.type = this.getControlType(props.type);
163 row.id = props.name;
164 row.prop = props.name;
165 row.defaultValue = props["default"];
166 row.label = props.name;
167 row.items = props.possibleValues;
168
169 section.Section.push([row]);
170 }
171
172 PIData[piID] = [];
173 PIData[piID].push(section);
174
175 // Setup the component hash object to store references to each component data
176 this.componentsData[componentData.component] = componentData;
177
178 this.componentsLoaded++;
179
180 if(this.componentsLoaded === this.componentsToLoad) {
181 // console.log("all loaded");
182 // Here we need to stop some sort of loading animation
183 }
184
185 }
186 },
187
188 // PI conversion method. This will convert the property type into a Ninja component
189 getControlType: {
190 value: function(type) {
191 switch(type) {
192 case "string":
193 return "textbox";
194 case "boolean":
195 return "checkbox";
196 case "select":
197 return "dropdown";
198 case "number":
199 return "hottext";
200 default:
201 alert("Conversion not implemented for ", type);
202 }
203 }
204 },
205
206 /*********************************************************************