aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Components
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-03 15:50:35 -0800
committerValerio Virgillito2012-02-03 15:50:35 -0800
commitdbd3a60478db35b0b12baa2ca54a0712d880951f (patch)
tree68d970c3399e5c0efddd4ad81921098b8daecdda /js/panels/Components
parente6e539f345f5e1ac36a595db5d1a1c3700715e88 (diff)
downloadninja-dbd3a60478db35b0b12baa2ca54a0712d880951f.tar.gz
button component using json data
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/panels/Components')
-rw-r--r--js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js60
1 files changed, 52 insertions, 8 deletions
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index 8c81b3ab..d9decd2c 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -4,11 +4,12 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
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 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component,
9 NJUtils = require("js/lib/NJUtils").NJUtils; 9 NJUtils = require("js/lib/NJUtils").NJUtils;
10 10
11var treeControlModule = require("js/components/tree.reel"); 11var treeControlModule = require("js/components/tree.reel");
12var PIData = require("js/data/pi/pi-data").PiData;
12 13
13var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, { 14var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, {
14 15
@@ -29,6 +30,11 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
29 "name": "label", 30 "name": "label",
30 "type": "string", 31 "type": "string",
31 "default": "Button" 32 "default": "Button"
33 },
34 {
35 "name": "enabled",
36 "type": "boolean",
37 "default": "true"
32 } 38 }
33 ] 39 ]
34 } 40 }
@@ -43,8 +49,48 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
43 _loadComponents: { 49 _loadComponents: {
44 value: function() { 50 value: function() {
45 this.components = [ 51 this.components = [
46 {component: "Button", data: "montage/ui/button.reel/button.json"} 52 {name: "Button", data: "montage/ui/button.reel/button.json"}
47 ]; 53 ];
54
55 // Build the PI objects for each component
56 for(var i = 0, component; component = this.components[i]; i++) {
57 var piIdentifier = component.name + "Pi";
58 var piObj = [];
59 var section = {};
60
61
62 section.label = component.name + " Properties";
63 section.Section = [];
64
65 for(var j = 0, props; props = this._testButtonJson.properties[j]; j++) {
66 var row = {};
67 row.type = this.getControlType(props.type);
68 row.id = props.name;
69 row.prop = props.name;
70 row.defaultValue = props["default"];
71 row.label = props.name;
72
73 section.Section.push([row]);
74 }
75
76 PIData[piIdentifier] = [];
77 PIData[piIdentifier].push(section);
78
79 }
80
81 }
82 },
83
84 getControlType: {
85 value: function(type) {
86 switch(type) {
87 case "string":
88 return "textbox";
89 case "boolean":
90 return "checkbox";
91 default:
92 alert("Conversion not implemented for ", type);
93 }
48 } 94 }
49 }, 95 },
50 96
@@ -135,7 +181,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
135 value: function(name) { 181 value: function(name) {
136 var el; 182 var el;
137 el = NJUtils.makeNJElement(name, "Button", "component"); 183 el = NJUtils.makeNJElement(name, "Button", "component");
138 //el.elementModel.pi = "buttonPi"; 184 el.elementModel.pi = "ButtonPi";
139 el.setAttribute("type", "button"); 185 el.setAttribute("type", "button");
140 return el; 186 return el;
141 } 187 }
@@ -151,11 +197,9 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
151 if(componentType == "Button"){ 197 if(componentType == "Button"){
152 componentEl = NJUtils.makeNJElement("button", componentType, "component");//, {"type": "button"}); 198 componentEl = NJUtils.makeNJElement("button", componentType, "component");//, {"type": "button"});
153 componentEl.setAttribute("type", "button"); 199 componentEl.setAttribute("type", "button");
154 //componentEl.innerHTML = "Button";
155 200
156 componentInstance = this.application.ninja.currentDocument._window.addComponent(componentEl, {type: componentType, path: "montage/ui/button.reel", name: "Button"}, this.callback); 201 componentInstance = this.application.ninja.currentDocument._window.addComponent(componentEl, {type: componentType, path: "montage/ui/button.reel", name: "Button"}, this.callback);
157 202
158
159 }else if(componentType == "Checkbox"){ 203 }else if(componentType == "Checkbox"){
160 compW = 53; 204 compW = 53;
161 compH = 53; 205 compH = 53;