aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/controllers/elements/component-controller.js8
-rw-r--r--js/data/pi/pi-data.js20
-rw-r--r--js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js60
3 files changed, 59 insertions, 29 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 7a8acb3a..1b0591be 100644
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -15,8 +15,11 @@ exports.ComponentController = Montage.create(ElementController, {
15 case "label": 15 case "label":
16 return this.application.ninja.currentDocument.getComponentFromElement(el).label; 16 return this.application.ninja.currentDocument.getComponentFromElement(el).label;
17 break; 17 break;
18 case "enabled":
19 return this.application.ninja.currentDocument.getComponentFromElement(el).enabled;
20 break;
18 default: 21 default:
19 return ElementController.getProperty(el, prop); 22 return ElementController.getProperty(el, prop, true);
20 } 23 }
21 } 24 }
22 }, 25 },
@@ -27,6 +30,9 @@ exports.ComponentController = Montage.create(ElementController, {
27 case "label": 30 case "label":
28 this.application.ninja.currentDocument.getComponentFromElement(el).label = value; 31 this.application.ninja.currentDocument.getComponentFromElement(el).label = value;
29 break; 32 break;
33 case "enabled":
34 this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value;
35 break;
30 default: 36 default:
31 ElementController.setProperty(el, p, value); 37 ElementController.setProperty(el, p, value);
32 } 38 }
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 9edb0399..de5cd34d 100644
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -525,26 +525,6 @@ exports.PiData = Montage.create( Montage, {
525 ] 525 ]
526 } 526 }
527 ] 527 ]
528 },
529
530 componentPi: {
531 value: [
532 {
533 label: "Button",
534
535 Section: [
536 [
537 {
538 type: "textbox",
539 id: "Label",
540 prop: "label",
541 defaultValue: "Button",
542 label: "Label"
543 }
544 ]
545 ]
546 }
547 ]
548 } 528 }
549}); 529});
550 530
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;